aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/default.nix17
-rw-r--r--lib/types/populate.nix34
2 files changed, 51 insertions, 0 deletions
diff --git a/lib/default.nix b/lib/default.nix
index f720a08..0a99f97 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -42,6 +42,23 @@ let {
in
flatten [] (source.${source.type}.inputs or {});
+ # Tells whether a source's inputs get drawn from other sources by a
+ # generated flake in .populate/flakes, instead of by rewriting the lock
+ # file of the flake in the source. Symlink sources point at other
+ # sources, whose lock files stay as they are.
+ hasGeneratedFlake = source:
+ lib.flakeFollows source != [] &&
+ (source.type == "symlink" || !(source.${source.type}.rewriteLock or true));
+
+ # Tells whether a flake or flake-input source gets delivered as a copy,
+ # which gets patched, gets its lock file rewritten, or is materialized.
+ derivesFlake = source: let
+ source' = source.${source.type};
+ in
+ lib.elem source.type [ "flake" "flake-input" ] &&
+ (source'.materialize or false || source'.patches or [] != [] ||
+ (source'.rewriteLock or true && lib.flakeFollows source != []));
+
maybeHostName = default: let
# We're parsing /etc/hostname here because reading
# /proc/sys/kernel/hostname yields ""
diff --git a/lib/types/populate.nix b/lib/types/populate.nix
index 4523dad..a278ffd 100644
--- a/lib/types/populate.nix
+++ b/lib/types/populate.nix
@@ -125,6 +125,10 @@
path = lib.mkOption {
type = lib.types.absolute-pathname;
};
+ rewriteLock = lib.mkOption {
+ default = true;
+ type = lib.types.bool;
+ };
useChecksum = lib.mkOption {
default = false;
type = lib.types.bool;
@@ -185,6 +189,19 @@
default = {};
type = flake-inputs;
};
+ materialize = lib.mkOption {
+ default = false;
+ type = lib.types.bool;
+ };
+ patches = lib.mkOption {
+ apply = map toString;
+ default = [];
+ type = lib.types.listOf lib.types.path;
+ };
+ rewriteLock = lib.mkOption {
+ default = true;
+ type = lib.types.bool;
+ };
};
};
flake-input = lib.types.submodule {
@@ -200,6 +217,19 @@
default = {};
type = flake-inputs;
};
+ materialize = lib.mkOption {
+ default = false;
+ type = lib.types.bool;
+ };
+ patches = lib.mkOption {
+ apply = map toString;
+ default = [];
+ type = lib.types.listOf lib.types.path;
+ };
+ rewriteLock = lib.mkOption {
+ default = true;
+ type = lib.types.bool;
+ };
name = lib.mkOption {
type = lib.types.str;
};
@@ -224,6 +254,10 @@
ref = lib.mkOption {
type = lib.types.str; # TODO lib.types.git.ref
};
+ rewriteLock = lib.mkOption {
+ default = true;
+ type = lib.types.bool;
+ };
url = lib.mkOption {
type = lib.types.str; # TODO lib.types.git.url
};