nixin-krops/krops.nix

140 lines
3.5 KiB
Nix

let
krops = builtins.fetchGit {
url = "https://cgit.krebsco.de/krops/";
};
lib = import "${krops}/lib";
pkgs = import "${krops}/pkgs" { };
importJson = (import <nixpkgs> { }).lib.importJSON;
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;
};
}
];
arachnide = pkgs.krops.writeDeploy "deploy-server-arachnide" {
source = source "arachnide";
target = lib.mkTarget "operator@192.168.12.2" // {
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;
};
};
grille-pain = pkgs.krops.writeDeploy "deploy-server-grille-pain" {
source = source "grille-pain";
target = lib.mkTarget "operator@192.168.12.7" // {
port = "144";
sudo = true;
};
};
franky = pkgs.krops.writeDeploy "deploy-server-franky" {
source = source "franky";
target = lib.mkTarget "operator@192.168.12.9" // {
port = "4222";
sudo = true;
};
};
sanji = pkgs.krops.writeDeploy "deploy-server-sanji" {
source = source "sanji";
target = lib.mkTarget "operator@192.168.12.5" // {
port = "4222";
sudo = true;
};
};
zoro = pkgs.krops.writeDeploy "deploy-server-zoro" {
source = source "zoro";
target = lib.mkTarget "operator@192.168.12.8" // {
port = "4222";
sudo = true;
};
};
dromadaire = pkgs.krops.writeDeploy "deploy-server-dromadaire" {
source = source "dromadaire";
target = lib.mkTarget "operator@192.168.12.11" // {
port = "144";
sudo = true;
};
};
plancha = pkgs.krops.writeDeploy "deploy-server-plancha" {
source = source "plancha";
target = lib.mkTarget "operator@192.168.12.12" // {
port = "144";
sudo = true;
};
};
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" {
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
'';
};
in
{
arachnide = arachnide;
framboise = framboise;
grille-pain = grille-pain;
franky = franky;
sanji = sanji;
zoro = zoro;
dromadaire = dromadaire;
plancha = plancha;
all = pkgs.writeScript "deploy-all-servers" (
lib.concatStringsSep "\n" [
arachnide
framboise
grille-pain
franky
sanji
zoro
dromadaire
plancha
]
);
register-runner = register-runner;
gen-token-arachnide = gen-token-arachnide;
}