nixin-krops/krops.nix

141 lines
3.5 KiB
Nix
Raw Normal View History

2024-12-18 21:54:04 +00:00
let
krops = builtins.fetchGit {
url = "https://cgit.krebsco.de/krops/";
};
lib = import "${krops}/lib";
2024-12-26 10:24:03 +00:00
pkgs = import "${krops}/pkgs" { };
importJson = (import <nixpkgs> { }).lib.importJSON;
2024-12-18 21:54:04 +00:00
2024-12-26 10:24:03 +00:00
source =
name:
lib.evalSource [
{
config.file = toString ./config/${name};
modules.file = toString ./modules;
nixos-config.symlink = "config/configuration.nix";
secrets.pass = {
dir = toString ~/.password-store/nixin-password-store/krops;
name = "${name}";
};
nixpkgs.git = {
ref = (importJson ./nixpkgs.json).rev;
url = "https://github.com/NixOS/nixpkgs";
shallow = true;
};
}
];
2024-12-18 21:54:04 +00:00
arachnide = pkgs.krops.writeDeploy "deploy-server-arachnide" {
source = source "arachnide";
target = lib.mkTarget "operator@192.168.12.2" // {
2024-12-18 21:54:04 +00:00
port = "144";
sudo = true;
};
};
framboise = pkgs.krops.writeDeploy "deploy-server-framboise" {
source = source "framboise";
target = lib.mkTarget "operator@192.168.12.10" // {
port = "144";
sudo = true;
};
2024-12-25 17:24:33 +00:00
};
grille-pain = pkgs.krops.writeDeploy "deploy-server-grille-pain" {
source = source "grille-pain";
target = lib.mkTarget "operator@192.168.12.7" // {
2024-12-25 17:24:33 +00:00
port = "144";
sudo = true;
};
2024-12-18 21:54:04 +00:00
};
2024-12-27 20:46:00 +00:00
franky = pkgs.krops.writeDeploy "deploy-server-franky" {
source = source "franky";
target = lib.mkTarget "operator@192.168.12.9" // {
port = "4222";
sudo = true;
};
};
2024-12-26 20:25:26 +00:00
sanji = pkgs.krops.writeDeploy "deploy-server-sanji" {
source = source "sanji";
target = lib.mkTarget "operator@192.168.12.5" // {
2024-12-26 20:25:26 +00:00
port = "4222";
sudo = true;
};
};
2024-12-27 13:10:48 +00:00
zoro = pkgs.krops.writeDeploy "deploy-server-zoro" {
source = source "zoro";
target = lib.mkTarget "operator@192.168.12.8" // {
port = "4222";
sudo = true;
};
};
2024-12-18 21:54:04 +00:00
dromadaire = pkgs.krops.writeDeploy "deploy-server-dromadaire" {
source = source "dromadaire";
target = lib.mkTarget "operator@192.168.12.11" // {
port = "144";
sudo = true;
};
2024-12-18 21:54:04 +00:00
};
2024-12-26 21:27:37 +00:00
plancha = pkgs.krops.writeDeploy "deploy-server-plancha" {
source = source "plancha";
2025-01-02 13:14:31 +00:00
target = lib.mkTarget "operator@192.168.12.12" // {
2024-12-26 21:27:37 +00:00
port = "144";
sudo = true;
};
};
2024-12-20 23:28:35 +00:00
register-runner = pkgs.krops.writeCommand "register-forgejo-runner" {
source = source "arachnide";
target = lib.mkTarget "douzeb@192.168.36.9" // {
port = "144";
sudo = true;
};
command = targetPath: ''
forgejo forgejo-cli actions register --name local-runner --secret $(head -n 1 /var/src/secrets/forgejo-runner-secret)
'';
};
gen-token-arachnide = pkgs.krops.writeCommand "generate-token-arachnide" {
2024-12-20 23:28:35 +00:00
source = source "arachnide";
target = lib.mkTarget "douzeb@192.168.36.9" // {
port = "144";
sudo = true;
};
command = targetPath: ''
mkdir -p /etc/forgejo
echo "TOKEN=$(forgejo forgejo-cli actions generate-runner-token)" > /etc/forgejo/runner.token
cat /etc/forgejo/runner.token
'';
};
2024-12-26 10:24:03 +00:00
in
{
2024-12-18 21:54:04 +00:00
arachnide = arachnide;
framboise = framboise;
2024-12-25 17:24:33 +00:00
grille-pain = grille-pain;
2024-12-27 20:46:00 +00:00
franky = franky;
2024-12-26 20:25:26 +00:00
sanji = sanji;
2024-12-27 13:10:48 +00:00
zoro = zoro;
2024-12-26 21:27:37 +00:00
dromadaire = dromadaire;
plancha = plancha;
2024-12-26 10:24:03 +00:00
all = pkgs.writeScript "deploy-all-servers" (
lib.concatStringsSep "\n" [
arachnide
framboise
grille-pain
2024-12-27 20:46:00 +00:00
franky
2024-12-26 20:25:26 +00:00
sanji
2024-12-27 13:10:48 +00:00
zoro
2024-12-26 10:24:03 +00:00
dromadaire
2024-12-26 21:27:37 +00:00
plancha
2024-12-26 10:24:03 +00:00
]
);
2024-12-20 23:28:35 +00:00
register-runner = register-runner;
gen-token-arachnide = gen-token-arachnide;
2024-12-18 21:54:04 +00:00
}