From 140bdfdf6c87c1822e0c4ec8f497a20ad1d4cf19 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 1 Dec 2018 04:20:50 +0100 Subject: populate: add derivation type --- lib/types/populate.nix | 15 +++++++++++++++ pkgs/populate/default.nix | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/lib/types/populate.nix b/lib/types/populate.nix index 2cd3267..49996f6 100644 --- a/lib/types/populate.nix +++ b/lib/types/populate.nix @@ -11,6 +11,14 @@ else throw "cannot determine type"; type = lib.types.enum known-types; }; + derivation = lib.mkOption { + apply = x: + if lib.types.str.check x + then { text = x; } + else x; + default = null; + type = lib.types.nullOr (lib.types.either lib.types.str source-types.derivation); + }; file = lib.mkOption { apply = x: if lib.types.absolute-pathname.check x @@ -47,6 +55,13 @@ }); source-types = { + derivation = lib.types.submodule { + options = { + text = lib.mkOption { + type = lib.types.str; + }; + }; + }; file = lib.types.submodule { options = { path = lib.mkOption { diff --git a/pkgs/populate/default.nix b/pkgs/populate/default.nix index 939ffb3..dcb26b9 100644 --- a/pkgs/populate/default.nix +++ b/pkgs/populate/default.nix @@ -20,6 +20,10 @@ let fi ''; + pop.derivation = target: source: shell' target /* sh */ '' + nix-build -E ${quote source.text} -o ${quote target.path} + ''; + pop.file = target: source: let configAttrs = ["useChecksum"]; config = filterAttrs (name: _: elem name configAttrs) source; -- cgit v1.2.3