aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/kops
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2018-02-28 21:02:21 +0100
committertv <tv@krebsco.de>2018-02-28 21:02:21 +0100
commite89cf20d4310070a877c2e24a287659546b561c9 (patch)
tree18e19a41b65d03782a955235b2a67407157eaa9f /pkgs/kops
import stockholm's deployment tools
https://cgit.krebsco.de/stockholm 877b4104370c1ea9698a449e376e2842d7c372fd
Diffstat (limited to 'pkgs/kops')
-rw-r--r--pkgs/kops/default.nix48
1 files changed, 48 insertions, 0 deletions
diff --git a/pkgs/kops/default.nix b/pkgs/kops/default.nix
new file mode 100644
index 0000000..fc52327
--- /dev/null
+++ b/pkgs/kops/default.nix
@@ -0,0 +1,48 @@
+let
+ lib = import ../../lib // {
+ isLocalTarget = let
+ origin = lib.mkTarget "";
+ in target:
+ target.host == origin.host &&
+ target.user == origin.user;
+ };
+in
+
+{ nix, openssh, populate, writeDash, writeJSON }: {
+
+ writeDeploy = name: { source, target }: let
+ target' = lib.mkTarget target;
+ in
+ writeDash name ''
+ set -efu
+
+ ${populate}/bin/populate \
+ ${target'.user}@${target'.host}:${target'.port}${target'.path} \
+ < ${writeJSON "${name}-source.json" source}
+
+ ${openssh}/bin/ssh \
+ ${target'.user}@${target'.host} -p ${target'.port} \
+ nixos-rebuild switch -I ${target'.path}
+ '';
+
+ writeTest = name: { source, target }: let
+ target' = lib.mkTarget target;
+ in
+ assert lib.isLocalTarget target';
+ writeDash name ''
+ set -efu
+
+ ${populate}/bin/populate --force \
+ ${target'.path} \
+ < ${writeJSON "${name}-source.json" source}
+
+ ${nix}/bin/nix-build \
+ -A config.system.build.toplevel \
+ -I ${target'.path} \
+ --arg modules '[<nixos-config>]' \
+ --no-out-link \
+ --show-trace \
+ '<nixpkgs/nixos/lib/eval-config.nix>'
+ '';
+
+}