diff options
author | tv <tv@krebsco.de> | 2022-03-22 00:55:53 +0100 |
---|---|---|
committer | tv <tv@krebsco.de> | 2022-03-22 01:01:35 +0100 |
commit | 44ec31fe02c282660be239f3a7899b62f56ab4d3 (patch) | |
tree | 89ffa26693159d98009c23bfe6ad35e6ff50a404 /lib | |
parent | 2ad9dc3617862d60cd9af4186741a767a7a28c6f (diff) |
lib.haskell.substitutePkgs: add dependencies
Diffstat (limited to 'lib')
-rw-r--r-- | lib/haskell.nix | 18 |
1 files changed, 8 insertions, 10 deletions
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); } |