forked from ivanovs-4/haskell-flake-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.nix
58 lines (50 loc) · 1.38 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{ flake-utils }:
let
# This function tries to capture a common haskell cabal package flake pattern.
simpleCabal2flake = import ./simpleCabal2flake.nix { inherit lib flake-utils; };
simpleCabalProject2flake = import ./simpleCabalProject2flake.nix { inherit lib flake-utils; };
haskellPackagesOverrideComposable = pkgs: hpOverrides:
pkgs.haskellPackages.override (oldAttrs: {
overrides =
pkgs.lib.composeExtensions
(oldAttrs.overrides or (_: _: { }))
hpOverrides;
});
tunePackages = pkgs: old: with pkgs.lib;
attrsets.mapAttrs (n: fs: trivial.pipe old.${n} fs);
jailbreakUnbreak = pkgs: pkg:
pkgs.haskell.lib.doJailbreak (pkg.overrideAttrs (_: { meta = { }; }));
loadOverlay = obj:
if obj == null
then [ ]
else [ (maybeImport obj) ];
maybeImport = obj:
if (builtins.typeOf obj == "path") || (builtins.typeOf obj == "string")
then
import obj
else
obj;
maybeCall = obj: args:
if (builtins.typeOf obj == "lambda")
then
obj args
else
obj;
foldCompose = builtins.foldl'
(f: g: a: f (g a))
(x: x);
lib = {
inherit
simpleCabal2flake
simpleCabalProject2flake
haskellPackagesOverrideComposable
tunePackages
jailbreakUnbreak
loadOverlay
maybeImport
maybeCall
foldCompose
;
};
in
lib