Restructure krops deployments

This commit is contained in:
Simon Bruder 2020-12-17 09:47:33 +01:00
parent c1008ad61e
commit c63305cb6b
No known key found for this signature in database
GPG key ID: 6F03E0000CC5B62F
4 changed files with 45 additions and 41 deletions

45
deploy.nix Normal file
View file

@ -0,0 +1,45 @@
# Deploy with: nix build -f ./deploy.nix HOSTNAME && ./result
let
sources = import ./nix/sources.nix;
krops = sources.krops;
lib = import "${krops}/lib";
kropsPkgs = import "${krops}/pkgs" { };
kropsDeploy =
{ hostname
, target ? null
, extraSources ? { }
}:
let
source = lib.evalSource [
({
nixpkgs.git = {
ref = sources.nixpkgs.rev;
url = https://github.com/NixOS/nixpkgs;
shallow = true;
};
config.file = toString ./.;
nixos-config.symlink = "config/machines/${hostname}/configuration.nix";
secrets.pass = {
dir = toString ~/.password-store;
name = "nixos/machines/${hostname}";
};
} // extraSources)
];
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
builtins.mapAttrs (hostname: configuration: kropsDeploy { inherit hostname; } // configuration)
{
nunotaba = { };
sayuri = { };
}

View file

@ -1,35 +0,0 @@
{ hostname
, target ? null
, extraSources ? { }
}:
let
sources = import ../nix/sources.nix;
krops = sources.krops;
lib = import "${krops}/lib";
pkgs = import "${krops}/pkgs" { };
source = lib.evalSource [
({
nixpkgs.git = {
ref = sources.nixpkgs.rev;
url = https://github.com/NixOS/nixpkgs;
shallow = true;
};
config.file = toString ../.;
nixos-config.symlink = "config/machines/${hostname}/configuration.nix";
secrets.pass = {
dir = toString ~/.password-store;
name = "nixos/machines/${hostname}";
};
} // extraSources)
];
in
pkgs.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"
];
};
}

View file

@ -1,3 +0,0 @@
import ../../lib/krops.nix rec {
hostname = "nunotaba";
}

View file

@ -1,3 +0,0 @@
import ../../lib/krops.nix {
hostname = "sayuri";
}