2018-04-05 17:31:39 +00:00
|
|
|
{ name }: rec {
|
|
|
|
|
2018-10-07 15:08:01 +00:00
|
|
|
krops = ../submodules/krops;
|
2018-04-05 17:31:39 +00:00
|
|
|
|
2018-06-04 10:55:49 +00:00
|
|
|
lib = import "${krops}/lib";
|
2018-04-05 17:31:39 +00:00
|
|
|
|
|
|
|
# TODO document why pkgs should be used like this
|
2018-06-04 10:55:49 +00:00
|
|
|
pkgs = import "${krops}/pkgs" {};
|
2018-04-05 17:31:39 +00:00
|
|
|
|
2018-11-28 20:30:46 +00:00
|
|
|
krebs-source = { test ? false }: rec {
|
|
|
|
nixpkgs = if test then {
|
2019-01-28 22:05:38 +00:00
|
|
|
derivation = let
|
|
|
|
rev = (lib.importJSON ./nixpkgs.json).rev;
|
|
|
|
sha256 = (lib.importJSON ./nixpkgs.json).sha256;
|
|
|
|
in ''
|
|
|
|
with import (builtins.fetchTarball {
|
|
|
|
url = "https://github.com/nixos/nixpkgs/archive/${rev}.tar.gz";
|
|
|
|
sha256 = "${sha256}";
|
|
|
|
}) {};
|
2019-01-03 20:32:23 +00:00
|
|
|
pkgs.fetchFromGitHub {
|
2018-11-28 20:30:46 +00:00
|
|
|
owner = "nixos";
|
|
|
|
repo = "nixpkgs";
|
2019-01-28 22:05:38 +00:00
|
|
|
rev = "${rev}";
|
|
|
|
sha256 = "${sha256}";
|
2019-01-03 20:32:23 +00:00
|
|
|
}
|
|
|
|
'';
|
2018-11-28 20:30:46 +00:00
|
|
|
} else {
|
|
|
|
git = {
|
|
|
|
ref = (lib.importJSON ./nixpkgs.json).rev;
|
|
|
|
url = https://github.com/NixOS/nixpkgs;
|
|
|
|
};
|
2018-04-05 17:31:39 +00:00
|
|
|
};
|
2018-04-06 10:08:29 +00:00
|
|
|
stockholm.file = toString ../.;
|
2018-04-05 17:31:39 +00:00
|
|
|
stockholm-version.pipe = toString (pkgs.writeDash "${name}-version" ''
|
|
|
|
set -efu
|
2018-11-28 20:30:46 +00:00
|
|
|
cd ${lib.escapeShellArg stockholm.file}
|
2018-04-05 17:31:39 +00:00
|
|
|
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 [
|
2018-11-28 20:30:46 +00:00
|
|
|
(krebs-source { test = test; })
|
2018-04-05 17:31:39 +00:00
|
|
|
{
|
|
|
|
nixos-config.symlink = "stockholm/krebs/1systems/${name}/config.nix";
|
2018-11-27 20:14:40 +00:00
|
|
|
secrets = if test then {
|
2019-06-13 21:30:54 +00:00
|
|
|
file = toString ./0tests/data/secrets;
|
2018-11-27 20:14:40 +00:00
|
|
|
} else {
|
|
|
|
pass = {
|
|
|
|
dir = "${lib.getEnv "HOME"}/brain";
|
|
|
|
name = "krebs-secrets/${name}";
|
|
|
|
};
|
|
|
|
};
|
2018-04-05 17:31:39 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
# usage: $(nix-build --no-out-link --argstr name HOSTNAME -A deploy)
|
2018-06-04 10:55:49 +00:00
|
|
|
deploy = pkgs.krops.writeDeploy "${name}-deploy" {
|
2018-04-05 17:31:39 +00:00
|
|
|
source = source { test = false; };
|
|
|
|
target = "root@${name}/var/src";
|
|
|
|
};
|
|
|
|
|
2018-09-09 08:23:20 +00:00
|
|
|
# usage: $(nix-build --no-out-link --argstr name HOSTNAME --argstr target PATH -A test)
|
|
|
|
test = { target }: pkgs.krops.writeTest "${name}-test" {
|
2018-10-09 11:48:52 +00:00
|
|
|
force = true;
|
2018-09-09 08:23:20 +00:00
|
|
|
inherit target;
|
2018-04-05 17:31:39 +00:00
|
|
|
source = source { test = true; };
|
2018-09-07 17:46:20 +00:00
|
|
|
};
|
2018-04-05 17:31:39 +00:00
|
|
|
}
|