summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2017-07-22 23:44:23 +0200
committerlassulus <lassulus@lassul.us>2017-07-23 21:19:14 +0200
commit5f0d55de62f053296a04bc1a65ad184957f4ff08 (patch)
treeb798e2f0579b2b0d449079842be97f17660c21c8
parenta0828c8916c8674816e25cf01fa4b07c05eec6e8 (diff)
shell: add get-source command
-rw-r--r--shell.nix28
1 files changed, 21 insertions, 7 deletions
diff --git a/shell.nix b/shell.nix
index 5ea9ff3b7..58b956c04 100644
--- a/shell.nix
+++ b/shell.nix
@@ -2,6 +2,10 @@ let
lib = import ./lib;
pkgs = import <nixpkgs> { overlays = [(import ./krebs/5pkgs)]; };
+ #
+ # high level commands
+ #
+
# usage: deploy [--user=USER] --system=SYSTEM [--target=TARGET]
cmds.deploy = pkgs.writeDash "cmds.deploy" ''
set -efu
@@ -29,6 +33,22 @@ let
exec ${utils.build} config.system.build.toplevel
'';
+ #
+ # low level commands
+ #
+
+ # usage: get-source SOURCE_FILE
+ cmds.get-source = pkgs.writeDash "cmds.get-source" ''
+ set -efu
+ exec ${pkgs.nix}/bin/nix-instantiate \
+ --eval \
+ --json \
+ --readonly-mode \
+ --show-trace \
+ --strict \
+ "$1"
+ '';
+
init.args = pkgs.writeText "init.args" /* sh */ ''
args=$(${pkgs.utillinux}/bin/getopt -n "$command" -s sh \
-o s:t:u: \
@@ -90,13 +110,7 @@ let
};
populate = pkgs.writeDash "init.env.populate" ''
set -efu
- _source=$(${pkgs.nix}/bin/nix-instantiate \
- --eval \
- --json \
- --readonly-mode \
- --show-trace \
- --strict \
- "$source")
+ _source=$(get-source "$source")
echo $_source |
${pkgs.populate}/bin/populate \
"$target_user@$target_host:$target_port$target_path" \