2020-12-17 09:47:33 +01:00
|
|
|
let
|
|
|
|
sources = import ./nix/sources.nix;
|
|
|
|
|
|
|
|
krops = sources.krops;
|
|
|
|
lib = import "${krops}/lib";
|
|
|
|
kropsPkgs = import "${krops}/pkgs" { };
|
|
|
|
|
|
|
|
kropsDeploy =
|
|
|
|
{ hostname
|
|
|
|
, target ? null
|
2021-01-06 23:45:29 +01:00
|
|
|
, secrets ? true
|
2020-12-17 09:47:33 +01:00
|
|
|
, extraSources ? { }
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
source = lib.evalSource [
|
2021-01-06 23:45:29 +01:00
|
|
|
{
|
2020-12-17 09:47:33 +01:00
|
|
|
nixpkgs.git = {
|
|
|
|
ref = sources.nixpkgs.rev;
|
|
|
|
url = https://github.com/NixOS/nixpkgs;
|
|
|
|
shallow = true;
|
|
|
|
};
|
2021-01-29 15:50:16 +01:00
|
|
|
nixos-hardware.git = {
|
|
|
|
ref = sources.nixos-hardware.rev;
|
|
|
|
url = https://github.com/NixOS/nixos-hardware;
|
|
|
|
};
|
2020-12-17 10:40:10 +01:00
|
|
|
config.file = {
|
|
|
|
path = toString ./.;
|
|
|
|
filters = [
|
|
|
|
{
|
|
|
|
type = "exclude";
|
|
|
|
pattern = ".git";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
type = "exclude";
|
|
|
|
pattern = "*.qcow2";
|
|
|
|
}
|
2021-02-07 11:30:42 +01:00
|
|
|
{
|
|
|
|
type = "include";
|
|
|
|
pattern = "/machines/${hostname}/";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
type = "exclude";
|
|
|
|
pattern = "/machines/*/";
|
|
|
|
}
|
2020-12-17 10:40:10 +01:00
|
|
|
];
|
|
|
|
};
|
2020-12-17 09:47:33 +01:00
|
|
|
nixos-config.symlink = "config/machines/${hostname}/configuration.nix";
|
2021-01-06 23:45:29 +01:00
|
|
|
}
|
|
|
|
(lib.mkIf secrets {
|
2020-12-17 09:47:33 +01:00
|
|
|
secrets.pass = {
|
|
|
|
dir = toString ~/.password-store;
|
|
|
|
name = "nixos/machines/${hostname}";
|
|
|
|
};
|
2021-01-06 23:45:29 +01:00
|
|
|
})
|
|
|
|
extraSources
|
2020-12-17 09:47:33 +01:00
|
|
|
];
|
|
|
|
in
|
|
|
|
kropsPkgs.krops.writeDeploy "deploy-${hostname}" {
|
|
|
|
source = source;
|
2021-01-28 17:08:08 +01:00
|
|
|
target = lib.mkTarget target // {
|
2020-12-17 09:47:33 +01:00
|
|
|
extraOptions = [
|
|
|
|
# force allocation of tty to allow aborting with ^C and to show build progress
|
|
|
|
"-t"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
2021-02-27 19:55:12 +01:00
|
|
|
lib.mapAttrs
|
2021-01-28 17:08:08 +01:00
|
|
|
(hostname: configuration: kropsDeploy ({ inherit hostname; } // configuration))
|
|
|
|
(import ./machines)
|