From 32c9720ca46537af4715245797b78734e6a762d0 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 18 Mar 2022 13:48:56 +0100 Subject: lib: add evalModulesConfig --- lib/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib') diff --git a/lib/default.nix b/lib/default.nix index 94a81439e..55cf1765e 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -2,6 +2,12 @@ let nixpkgs-lib = import ; lib = with lib; nixpkgs-lib // builtins // { + evalModulesConfig = modules: let + eval = evalModules { + inherit modules; + }; + in filterAttrsRecursive (name: _: !hasPrefix "_" name) eval.config; + evalSource = import ./eval-source.nix; git = import ./git.nix { inherit lib; }; -- cgit v1.2.3 From 5903fb0b61e6e6524dd3bbdfaa81b7775a134304 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 18 Mar 2022 13:49:07 +0100 Subject: lib: add evalSubmodule --- lib/default.nix | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib') diff --git a/lib/default.nix b/lib/default.nix index 55cf1765e..7c3b0370e 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -10,6 +10,15 @@ let evalSource = import ./eval-source.nix; + evalSubmodule = submodule: modules: let + prefix = ["evalSubmodule"]; + in evalModulesConfig [ + { + options = removeAttrs (submodule.getSubOptions prefix) ["_module"]; + imports = modules; + } + ]; + git = import ./git.nix { inherit lib; }; haskell = import ./haskell.nix { inherit lib; }; krebs = import ./krebs lib; -- cgit v1.2.3 From 2ad9dc3617862d60cd9af4186741a767a7a28c6f Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 22 Mar 2022 00:57:44 +0100 Subject: lib.haskell.substitutePkgs: fix typo --- lib/haskell.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/haskell.nix b/lib/haskell.nix index b1889caf0..2143e9a32 100644 --- a/lib/haskell.nix +++ b/lib/haskell.nix @@ -35,7 +35,7 @@ rec { "${pkg}/bin/${exename}" else trace (toString [ - "lib.haskell.replacePkg:" + "lib.haskell.substitutePkgs:" "warning:" "while deriving ${sourceDescription}:" "no substitute found for ${elemAt parse 1}" -- cgit v1.2.3 From 44ec31fe02c282660be239f3a7899b62f56ab4d3 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 22 Mar 2022 00:55:53 +0100 Subject: lib.haskell.substitutePkgs: add dependencies --- lib/haskell.nix | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/haskell.nix b/lib/haskell.nix index 2143e9a32..4f0ee05ab 100644 --- a/lib/haskell.nix +++ b/lib/haskell.nix @@ -9,19 +9,14 @@ rec { # "${pkgs.bar}/bin/foo" for each {-pkg:bar-}"foo". # If a package doesn't exist, a warning gets printed. substitutePkgs = name: { callsite ? null, pkgs, path }: - pkgs.writeText name (substitutePkgs' { - inherit pkgs; + let sourceDescription = if callsite != null then "${name} in ${toString callsite}" else "${name} from ${toString path}"; - text = readFile path; - }); - substitutePkgs' = { pkgs, sourceDescription, text }: - let - f = s: + f = dependencies: s: let parse = match "(.*)([{]-pkg(:([^}]+))?-[}]\"([^\"]+)\")(.*)" s; prefix = elemAt parse 0; @@ -43,9 +38,12 @@ rec { exename; in if parse == null then - s + (pkgs.writeText name s).overrideAttrs (old: { + dependencies = old.dependencies or [] ++ dependencies; + }) + else - f (prefix + toJSON substitute + suffix); + f (dependencies ++ [pkg]) (prefix + toJSON substitute + suffix); in - f text; + f [] (readFile path); } -- cgit v1.2.3