nixos-config/deploy.nix

65 lines
1.6 KiB
Nix
Raw Normal View History

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
, secrets ? true
2020-12-17 09:47:33 +01:00
, extraSources ? { }
}:
let
source = lib.evalSource [
{
2020-12-17 09:47:33 +01:00
nixpkgs.git = {
ref = sources.nixpkgs.rev;
url = https://github.com/NixOS/nixpkgs;
shallow = true;
};
config.file = {
path = toString ./.;
filters = [
{
type = "exclude";
pattern = ".git";
}
{
type = "exclude";
pattern = "*.qcow2";
}
];
};
2020-12-17 09:47:33 +01:00
nixos-config.symlink = "config/machines/${hostname}/configuration.nix";
}
(lib.mkIf secrets {
2020-12-17 09:47:33 +01:00
secrets.pass = {
dir = toString ~/.password-store;
name = "nixos/machines/${hostname}";
};
})
extraSources
2020-12-17 09:47:33 +01:00
];
in
kropsPkgs.krops.writeDeploy "deploy-${hostname}" {
source = source;
target = lib.mkTarget (if target == null then "root@${hostname}" else target) // {
extraOptions = [
# force allocation of tty to allow aborting with ^C and to show build progress
"-t"
];
};
};
in
2021-01-06 23:41:33 +01:00
builtins.mapAttrs (hostname: configuration: kropsDeploy ({ inherit hostname; } // configuration))
2020-12-17 09:47:33 +01:00
{
nunotaba = { };
sayuri = { };
2021-01-17 14:00:41 +01:00
ayu = {
target = "root@192.168.100.56";
secrets = false;
};
2020-12-17 09:47:33 +01:00
}