forked from aristanetworks/nix-serve-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
109 lines (89 loc) · 3.07 KB
/
flake.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
{ inputs = {
nixpkgs.url = github:NixOS/nixpkgs/master;
utils.url = github:numtide/flake-utils;
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = { nixpkgs, utils, ... }:
let
compiler = "ghc92";
overlay = pkgsNew: pkgsOld: {
cabal2nix-unwrapped =
pkgsNew.haskell.lib.justStaticExecutables
pkgsNew.haskell.packages."${compiler}".cabal2nix;
haskell = pkgsOld.haskell // {
packages = pkgsOld.haskell.packages // {
"${compiler}" = pkgsOld.haskell.packages."${compiler}".override (old: {
overrides =
pkgsNew.lib.fold pkgsNew.lib.composeExtensions (old.overrides or (_: _: { })) [
(pkgsNew.haskell.lib.packageSourceOverrides {
nix-serve-ng = ./.;
})
(haskellPackagesNew: haskellPackagesOld: {
nix-serve-ng =
pkgsNew.haskell.lib.overrideCabal
haskellPackagesOld.nix-serve-ng
(old: {
executableSystemDepends = (old.executableSystemDepends or []) ++ [
pkgsNew.boost.dev
];
});
})
];
});
};
};
nix-serve-ng =
pkgsNew.haskell.lib.justStaticExecutables
pkgsNew.haskell.packages."${compiler}".nix-serve-ng;
};
in
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
config = { };
overlays = [ overlay ];
inherit system;
};
inherit (pkgs) nix-serve-ng;
in
rec {
packages.default = nix-serve-ng;
defaultPackage = packages.default;
apps.default = {
type = "app";
program = "${nix-serve-ng}/bin/nix-serve";
};
defaultApp = apps.default;
devShells.default =
(pkgs.haskell.lib.doBenchmark
pkgs.haskell.packages."${compiler}".nix-serve-ng
).env;
devShell = devShells.default;
}) // rec {
overlays = {
# The default overlay only adds the exports for
# `pkgs.haskell.packages."${compiler}".nix-serve-ng` and
# `pkgs.nix-serve-ng`
default = [ overlay ];
# This overlay additionally overrides `pkgs.nix-serve` to refer to
# `pkgs.nix-serve-ng`
override =
let
replace = pkgsNew: pkgsOld: {
nix-serve = pkgsNew.nix-serve-ng;
};
in
[ overlay replace ];
};
# The NixOS module is a thin wrapper around the overlay to replace
# `nix-serve` with `nix-serve-ng`
#
# You can continue to use the old `services.nix-serve` NixOS options.
nixosModules.default = {
nixpkgs.overlays = overlays.override;
};
};
}