Skip to content

Commit 240baf5

Browse files
committed
Enable more packages
This now builds _all_ packages, by extracting the netlist overlay from the pre-flake concat-overlay.nix. - adds graphviz to the packages outputs to get testing farther (although tests still currently only work in a `devShell`) - uses `-plugin` instead of `-examples` in the example `homeConfiguration` - adds `overrides` to `cabalProject2nix`
1 parent abfcaa9 commit 240baf5

File tree

4 files changed

+72
-56
lines changed

4 files changed

+72
-56
lines changed

flake.nix

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,17 @@
2626
# These don’t work yet.
2727
# "ghc942" "ghcHEAD"
2828
];
29-
excludedPackages = ["concat-hardware"];
30-
# need display, graphviz for testing. disable test for now.
31-
noCheckPackages = ["concat-graphics" "concat-plugin"];
29+
excludedPackages = [];
30+
noCheckPackages = [
31+
# Only works on Linux and Darwin, and I’m not sure how to expose the
32+
# `open` executable on Nix/darwin.
33+
"concat-graphics"
34+
# Just fails.
35+
"concat-hardware"
36+
# TODO: Tests pass with `cabal new-test`, but not with `cabal test`, and
37+
# I’m guessing the latter is what `callCabal2nix` uses.
38+
"concat-plugin"
39+
];
3240
noHaddockPackages = ["concat-examples" "concat-inline" "concat-plugin"];
3341

3442
cabalPackages = pkgs: hpkgs:
@@ -46,7 +54,9 @@
4654
then pkgs.haskell.lib.dontHaddock v1
4755
else v1;
4856
in {"${name}" = v2;})
49-
(inputs.self.lib.cabalProject2nix ./cabal.project pkgs hpkgs);
57+
(inputs.self.lib.cabalProject2nix ./cabal.project pkgs hpkgs (old: {
58+
nativeBuildInputs = old.nativeBuildInputs ++ [pkgs.graphviz];
59+
}));
5060
in
5161
{
5262
overlays = {
@@ -56,6 +66,14 @@
5666
inputs.self.overlays.haskell;
5767

5868
haskell = inputs.self.lib.haskellOverlay cabalPackages;
69+
70+
## Only needed if you are using `concat-hardware`.
71+
netlist-default =
72+
inputs.self.lib.overlayHaskellPackages
73+
supportedGhcVersions
74+
inputs.self.overlays.netlist-haskell;
75+
76+
netlist-haskell = import ./nix/netlist-overlay.nix;
5977
};
6078

6179
homeConfigurations =
@@ -73,7 +91,7 @@
7391
({pkgs, ...}: {
7492
home.packages = [
7593
(pkgs.haskellPackages.ghcWithPackages (hpkgs: [
76-
hpkgs.concat-examples
94+
hpkgs.concat-plugin
7795
]))
7896
];
7997

@@ -97,7 +115,10 @@
97115
inherit system;
98116
## NB: This uses `inputs.self.overlays.default` because packages need to
99117
## be able to find other packages in this flake as dependencies.
100-
overlays = [inputs.self.overlays.default];
118+
overlays = [
119+
inputs.self.overlays.netlist-default
120+
inputs.self.overlays.default
121+
];
101122
};
102123
in {
103124
packages =

nix/concat-overlay.nix

Lines changed: 25 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,26 @@
1-
self: super: let
2-
netlistSrc = super.fetchFromGitHub {
3-
owner = "ku-fpg";
4-
repo = "netlist";
5-
rev = "0f50a9cfd947885cac7fc392a5295cffe0b3ac31";
6-
sha256 = "tg0UMslWZin6EeUbOruC9jt1xsgYIuk9vGi7uBSOUCw=";
7-
fetchSubmodules = true;
8-
};
9-
in {
10-
haskellPackages = super.haskellPackages.override (old: {
11-
overrides =
12-
super.lib.composeExtensions (old.overrides or (_: _: {}))
13-
(hself: hsuper: let
14-
defaultMod = drv:
15-
super.haskell.lib.disableLibraryProfiling
16-
(super.haskell.lib.dontHaddock drv);
17-
callCabal2nix = hself.callCabal2nix;
18-
in {
19-
# Prerequisites
20-
netlist =
21-
defaultMod (callCabal2nix "netlist" (netlistSrc + /netlist) {});
22-
verilog =
23-
defaultMod (callCabal2nix "netlist" (netlistSrc + /verilog) {});
24-
netlist-to-verilog =
25-
defaultMod
26-
(callCabal2nix "netlist" (netlistSrc + /netlist-to-verilog) {});
27-
netlist-to-vhdl =
28-
defaultMod
29-
(callCabal2nix "netlist" (netlistSrc + /netlist-to-vhdl) {});
30-
31-
# ConCat packages
32-
concat-known = defaultMod (callCabal2nix "concat-known" ../known {});
33-
concat-satisfy =
34-
defaultMod (callCabal2nix "concat-satisfy" ../satisfy {});
35-
concat-inline =
36-
defaultMod (callCabal2nix "concat-inline" ../inline {});
37-
concat-classes =
38-
defaultMod (callCabal2nix "concat-classes" ../classes {});
39-
concat-plugin =
40-
defaultMod (callCabal2nix "concat-plugin" ../plugin {});
41-
concat-examples =
42-
defaultMod (callCabal2nix "concat-examples" ../examples {});
43-
concat-graphics =
44-
defaultMod (callCabal2nix "concat-graphics" ../graphics {});
45-
concat-hardware =
46-
defaultMod (callCabal2nix "concat-hardware" ../hardware {});
47-
});
48-
});
1+
self: super: {
2+
haskellPackages = super.haskellPackages.extend (self.lib.composeExtensions
3+
(import ./nix/netlist-overlay.nix self super)
4+
(hself: hsuper: let
5+
defaultMod = drv:
6+
super.haskell.lib.disableLibraryProfiling
7+
(super.haskell.lib.dontHaddock drv);
8+
callCabal2nix = hself.callCabal2nix;
9+
in {
10+
concat-known = defaultMod (callCabal2nix "concat-known" ../known {});
11+
concat-satisfy =
12+
defaultMod (callCabal2nix "concat-satisfy" ../satisfy {});
13+
concat-inline =
14+
defaultMod (callCabal2nix "concat-inline" ../inline {});
15+
concat-classes =
16+
defaultMod (callCabal2nix "concat-classes" ../classes {});
17+
concat-plugin =
18+
defaultMod (callCabal2nix "concat-plugin" ../plugin {});
19+
concat-examples =
20+
defaultMod (callCabal2nix "concat-examples" ../examples {});
21+
concat-graphics =
22+
defaultMod (callCabal2nix "concat-graphics" ../graphics {});
23+
concat-hardware =
24+
defaultMod (callCabal2nix "concat-hardware" ../hardware {});
25+
}));
4926
}

nix/lib.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,12 @@ in {
111111
};
112112
};
113113

114-
cabalProject2nix = cabalProject: pkgs: hpkgs:
114+
cabalProject2nix = cabalProject: pkgs: hpkgs: overrides:
115115
builtins.mapAttrs
116116
(name: path:
117117
bash-strict-mode.lib.shellchecked pkgs
118-
(hpkgs.callCabal2nix name "${builtins.dirOf cabalProject}/${path}" {}))
118+
((hpkgs.callCabal2nix name "${builtins.dirOf cabalProject}/${path}" {})
119+
.overrideAttrs
120+
overrides))
119121
(parseCabalProject cabalProject);
120122
}

nix/netlist-overlay.nix

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
final: prev: hfinal: hprev: let
2+
netlistSrc = final.fetchFromGitHub {
3+
owner = "ku-fpg";
4+
repo = "netlist";
5+
rev = "0f50a9cfd947885cac7fc392a5295cffe0b3ac31";
6+
sha256 = "tg0UMslWZin6EeUbOruC9jt1xsgYIuk9vGi7uBSOUCw=";
7+
fetchSubmodules = true;
8+
};
9+
in {
10+
netlist = hfinal.callCabal2nix "netlist" (netlistSrc + /netlist) {};
11+
verilog = hfinal.callCabal2nix "netlist" (netlistSrc + /verilog) {};
12+
netlist-to-verilog =
13+
hfinal.callCabal2nix "netlist" (netlistSrc + /netlist-to-verilog) {};
14+
netlist-to-vhdl =
15+
hfinal.callCabal2nix "netlist" (netlistSrc + /netlist-to-vhdl) {};
16+
}

0 commit comments

Comments
 (0)