diff options
Diffstat (limited to 'pkgs/populate/rust.nix')
| -rw-r--r-- | pkgs/populate/rust.nix | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/pkgs/populate/rust.nix b/pkgs/populate/rust.nix new file mode 100644 index 0000000..cbf6fad --- /dev/null +++ b/pkgs/populate/rust.nix @@ -0,0 +1,43 @@ +# Populate's arguments, checked and as JSON, for the program in this +# directory, which delivers the sources. +{ coreutils, findutils, git, jq, nix, openssh, pass, passage, program, rsync +, writers +}: + +with import ../../lib; + +let + checks = import ./checks.nix; +in + +{ backup ? false, force ? false, prune ? false, source, target }: +assert checks.checkTargetPath target.path; +assert all checks.checkSourceName (attrNames source); +assert checks.checkInputs source; +let + # Store paths in the arguments stay dependencies of the script, so + # building it builds them. + spec = toJSON { + version = 1; + inherit backup force prune source; + target = { + inherit (target) host path; + user = target.user or null; + port = if target.port or null == null then null else toString target.port; + sudo = target.sudo or false; + extraOptions = target.extraOptions or []; + }; + }; +in +writers.writeDash "populate.${target.host}" /* sh */ '' + set -efu + echo + "$0" >&2 + PATH=${makeBinPath [ + coreutils findutils git jq nix openssh pass passage rsync + ]}''${PATH:+:$PATH} + export PATH + # The JSON is a single line, which can't be the delimiter. + exec ${program}/bin/populate - <<'EOF' + ${spec} + EOF +'' |
