From c63305cb6b7fa96fb86f7d5ab0701985d1a61b29 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Thu, 17 Dec 2020 09:47:33 +0100 Subject: [PATCH] Restructure krops deployments --- deploy.nix | 45 +++++++++++++++++++++++++++++++++++++ lib/krops.nix | 35 ----------------------------- machines/nunotaba/krops.nix | 3 --- machines/sayuri/krops.nix | 3 --- 4 files changed, 45 insertions(+), 41 deletions(-) create mode 100644 deploy.nix delete mode 100644 lib/krops.nix delete mode 100644 machines/nunotaba/krops.nix delete mode 100644 machines/sayuri/krops.nix diff --git a/deploy.nix b/deploy.nix new file mode 100644 index 0000000..c6fa56a --- /dev/null +++ b/deploy.nix @@ -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 = { }; +} diff --git a/lib/krops.nix b/lib/krops.nix deleted file mode 100644 index ab4ed97..0000000 --- a/lib/krops.nix +++ /dev/null @@ -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" - ]; - }; -} diff --git a/machines/nunotaba/krops.nix b/machines/nunotaba/krops.nix deleted file mode 100644 index 8ea98a9..0000000 --- a/machines/nunotaba/krops.nix +++ /dev/null @@ -1,3 +0,0 @@ -import ../../lib/krops.nix rec { - hostname = "nunotaba"; -} diff --git a/machines/sayuri/krops.nix b/machines/sayuri/krops.nix deleted file mode 100644 index f235161..0000000 --- a/machines/sayuri/krops.nix +++ /dev/null @@ -1,3 +0,0 @@ -import ../../lib/krops.nix { - hostname = "sayuri"; -}