aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/populate/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/populate/default.nix')
-rw-r--r--pkgs/populate/default.nix20
1 files changed, 11 insertions, 9 deletions
diff --git a/pkgs/populate/default.nix b/pkgs/populate/default.nix
index adf8479..c1bd9b8 100644
--- a/pkgs/populate/default.nix
+++ b/pkgs/populate/default.nix
@@ -190,10 +190,14 @@ let
in
rsync' target config sourcePath;
- pop.flake = target: source: let
+ # Delivers the flake itself, as its input named null. Only inputs can be
+ # fetched on the target, so fetchOnTarget is always false here.
+ pop.flake = target: source:
+ pop.flake-input target (source // { name = null; fetchOnTarget = false; });
+
+ pop.flake-input = target: source: let
nix' = "${nix}/bin/nix --extra-experimental-features ${quote "nix-command flakes"}";
- input = source.input or null;
- inputPath = if input == null then [] else splitString "/" input;
+ inputPath = if source.name == null then [] else splitString "/" source.name;
fetchOnTarget = source.fetchOnTarget or false;
# Caches per-flake information, so it's obtained only once, even if
# several sources use the same flake.
@@ -211,12 +215,12 @@ let
'';
noInput = /* sh */ ''
>&2 printf 'error: flake %s has no input %s\n' \
- ${quote source.flake} ${quote (toString input)}
+ ${quote source.flake} ${quote (toString source.name)}
exit 1
'';
# jq filter selecting the flake or input in nix flake archive's output.
node =
- if input == null then "."
+ if source.name == null then "."
else concatMapStrings (name: ".inputs[${toJSON name}]") inputPath;
# jq filter selecting the locked input and its own inputs in nix flake
# metadata's output, as fetchTree arguments, the input first.
@@ -287,10 +291,8 @@ let
}
'';
in
- if fetchOnTarget && input == null then
- throw "krops: flake source ${target.path}: fetching on the target needs an input"
- else if !fetchOnTarget && !isLocalTarget target && target.sudo then
- throw "krops: flake source ${target.path}: copying to targets with sudo is not supported"
+ if !fetchOnTarget && !isLocalTarget target && target.sudo then
+ throw "krops: source ${target.path}: copying flakes to targets with sudo is not supported"
else if fetchOnTarget then /* sh */ ''
set -efu