2018-04-05 19:31:39 +02:00
|
|
|
{ name }: rec {
|
|
|
|
|
2018-06-04 12:55:49 +02:00
|
|
|
krops = builtins.fetchGit {
|
|
|
|
url = https://cgit.krebsco.de/krops/;
|
|
|
|
rev = "4e466eaf05861b47365c5ef46a31a188b70f3615";
|
2018-04-05 19:31:39 +02:00
|
|
|
};
|
|
|
|
|
2018-06-04 12:55:49 +02:00
|
|
|
lib = import "${krops}/lib";
|
2018-04-05 19:31:39 +02:00
|
|
|
|
|
|
|
# TODO document why pkgs should be used like this
|
2018-06-04 12:55:49 +02:00
|
|
|
pkgs = import "${krops}/pkgs" {};
|
2018-04-05 19:31:39 +02:00
|
|
|
|
|
|
|
krebs-source = {
|
|
|
|
nixpkgs.git = {
|
2018-08-22 12:55:30 +02:00
|
|
|
ref = (lib.importJSON ./nixpkgs.json).rev;
|
2018-04-05 19:31:39 +02:00
|
|
|
url = https://github.com/NixOS/nixpkgs;
|
|
|
|
};
|
2018-04-06 12:08:29 +02:00
|
|
|
stockholm.file = toString ../.;
|
2018-04-05 19:31:39 +02:00
|
|
|
stockholm-version.pipe = toString (pkgs.writeDash "${name}-version" ''
|
|
|
|
set -efu
|
|
|
|
cd $HOME/stockholm
|
|
|
|
V=$(${pkgs.coreutils}/bin/date +%y.%m)
|
|
|
|
if test -d .git; then
|
|
|
|
V=$V.git.$(${pkgs.git}/bin/git describe --always --dirty)
|
|
|
|
case $V in (*-dirty)
|
|
|
|
V=$V@''${HOSTNAME-$(${pkgs.nettools}/bin/hostname)}
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
printf %s "$V"
|
|
|
|
'');
|
|
|
|
};
|
|
|
|
|
|
|
|
source ={ test }: lib.evalSource [
|
|
|
|
krebs-source
|
|
|
|
{
|
|
|
|
nixos-config.symlink = "stockholm/krebs/1systems/${name}/config.nix";
|
|
|
|
secrets =
|
|
|
|
if test
|
|
|
|
then {
|
2018-05-09 11:11:50 +02:00
|
|
|
file = toString <stockholm/krebs/0tests/data/secrets>;
|
2018-04-05 19:31:39 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
pass = {
|
|
|
|
dir = "${lib.getEnv "HOME"}/brain";
|
|
|
|
name = "krebs-secrets/${name}";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
# usage: $(nix-build --no-out-link --argstr name HOSTNAME -A deploy)
|
2018-06-04 12:55:49 +02:00
|
|
|
deploy = pkgs.krops.writeDeploy "${name}-deploy" {
|
2018-04-05 19:31:39 +02:00
|
|
|
source = source { test = false; };
|
|
|
|
target = "root@${name}/var/src";
|
|
|
|
};
|
|
|
|
|
|
|
|
# usage: $(nix-build --no-out-link --argstr name HOSTNAME -A test)
|
2018-06-04 12:55:49 +02:00
|
|
|
test = pkgs.krops.writeTest "${name}-test" {
|
2018-04-05 19:31:39 +02:00
|
|
|
source = source { test = true; };
|
2018-06-04 12:55:49 +02:00
|
|
|
target = "${lib.getEnv "HOME"}/tmp/${name}-krops-test-src";
|
2018-04-05 19:31:39 +02:00
|
|
|
};
|
2018-09-07 19:46:20 +02:00
|
|
|
|
|
|
|
ci = pkgs.krops.writeTest "${name}-test" {
|
|
|
|
source = source { test = true; };
|
|
|
|
target = "${lib.getEnv "HOME"}/stockholm-build";
|
|
|
|
};
|
2018-04-05 19:31:39 +02:00
|
|
|
}
|