summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2022-04-27 22:07:43 +0200
committermakefu <github@syntax-fehler.de>2022-04-27 22:07:43 +0200
commitbdd36774f5e0854553b13433ef85260c6c074b3e (patch)
tree656d0a2755c098a9e69c373a8c4f39fa82cb8d1e /lib
parentc3adb252afa29f0140f29c935201cfbb100b5697 (diff)
parent92d5eacd6d9e530c4d1ea0dec2652417b0fde78a (diff)
Merge remote-tracking branch 'lass/master'
Diffstat (limited to 'lib')
-rw-r--r--lib/default.nix15
-rw-r--r--lib/haskell.nix20
2 files changed, 24 insertions, 11 deletions
diff --git a/lib/default.nix b/lib/default.nix
index 94a81439e..7c3b0370e 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -2,8 +2,23 @@ let
nixpkgs-lib = import <nixpkgs/lib>;
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;
+ 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;
diff --git a/lib/haskell.nix b/lib/haskell.nix
index b1889caf0..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;
@@ -35,7 +30,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}"
@@ -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);
}