Skip to content

Commit e4d4e89

Browse files
authored
Every file is a flake parts module (#2039)
Uses import-tree to turn every file into a flake-parts module. Passes compiler, inputMap and hsPkgs through the module argument system. Passes lib.asZip through the module argument system Passes static-libs through the flake.overlays attribute No "./*.nix" files are mentioned throughout and so they can be freely renamed.
2 parents 01ce547 + 436dec1 commit e4d4e89

13 files changed

+703
-683
lines changed

flake.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 2 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
haskellNix.url = "github:input-output-hk/haskell.nix";
1111
hydra-coding-standards.url = "github:cardano-scaling/hydra-coding-standards/0.6.5";
1212
hydra-spec.url = "github:cardano-scaling/hydra-formal-specification/7f78e005b95ff3b9c55995632ceb3d6ab96a305e";
13+
import-tree.url = "github:vic/import-tree";
1314
iohk-nix.url = "github:input-output-hk/iohk-nix";
1415
lint-utils = {
1516
url = "github:homotopic/lint-utils";
@@ -22,128 +23,7 @@
2223
process-compose-flake.url = "github:Platonic-Systems/process-compose-flake";
2324
};
2425

25-
outputs = { self, ... }@inputs:
26-
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
27-
imports = [
28-
inputs.hydra-coding-standards.flakeModule
29-
inputs.process-compose-flake.flakeModule
30-
./nix/hydra/demo.nix
31-
./nix/hydra/docker.nix
32-
];
33-
systems = [
34-
"x86_64-linux"
35-
"x86_64-darwin"
36-
"aarch64-darwin"
37-
"aarch64-linux"
38-
];
39-
perSystem = { config, lib, system, ... }:
40-
let
41-
compiler = "ghc967";
42-
43-
# nixpkgs enhanced with haskell.nix and crypto libs as used by iohk
44-
45-
pkgs = import inputs.nixpkgs {
46-
inherit system;
47-
overlays = [
48-
# This overlay contains libsodium and libblst libraries
49-
inputs.iohk-nix.overlays.crypto
50-
# This overlay contains pkg-config mappings via haskell.nix to use the
51-
# crypto libraries above
52-
inputs.iohk-nix.overlays.haskell-nix-crypto
53-
# Keep haskell.nix as the last overlay!
54-
#
55-
# Reason: haskell.nix modules/overlays needs to be last
56-
# https://github.com/input-output-hk/haskell.nix/issues/1954
57-
inputs.haskellNix.overlay
58-
# Custom static libs used for darwin build
59-
(import ./nix/static-libs.nix)
60-
inputs.nix-npm-buildpackage.overlays.default
61-
# Specific versions of tools we require
62-
(final: _prev: {
63-
inherit (inputs.aiken.packages.${system}) aiken;
64-
apply-refact = final.haskell-nix.tool compiler "apply-refact" "0.15.0.0";
65-
cabal-install = final.haskell-nix.tool compiler "cabal-install" "3.10.3.0";
66-
cabal-plan = final.haskell-nix.tool compiler "cabal-plan" { version = "0.7.5.0"; cabalProjectLocal = "package cabal-plan\nflags: +exe"; };
67-
cabal-fmt = config.treefmt.programs.cabal-fmt.package;
68-
fourmolu = config.treefmt.programs.fourmolu.package;
69-
haskell-language-server = final.haskell-nix.tool compiler "haskell-language-server" "2.11.0.0";
70-
weeder = final.haskell-nix.tool compiler "weeder" "2.9.0";
71-
inherit (inputs.cardano-node.packages.${system}) cardano-cli;
72-
inherit (inputs.cardano-node.packages.${system}) cardano-node;
73-
inherit (inputs.mithril.packages.${system}) mithril-client-cli;
74-
mithril-client-cli-unstable =
75-
final.writeShellScriptBin "mithril-client-unstable" ''
76-
exec ${inputs.mithril-unstable.packages.${system}.mithril-client-cli}/bin/mithril-client "$@"
77-
'';
78-
})
79-
];
80-
};
81-
82-
inputMap = { "https://intersectmbo.github.io/cardano-haskell-packages" = inputs.CHaP; };
83-
84-
hsPkgs = import ./nix/hydra/project.nix {
85-
inherit pkgs inputMap;
86-
compiler-nix-name = compiler;
87-
};
88-
89-
hydraPackages = import ./nix/hydra/packages.nix {
90-
inherit pkgs inputs hsPkgs self;
91-
gitRev = self.rev or "dirty";
92-
};
93-
94-
tx-cost-diff =
95-
pkgs.writers.writeHaskellBin
96-
"tx-cost-diff"
97-
{
98-
libraries =
99-
with pkgs.haskellPackages;
100-
[ aeson text bytestring lens lens-aeson shh ];
101-
} ''${builtins.readFile scripts/tx-cost-diff.hs}'';
102-
103-
allComponents = x:
104-
[ x.components.library ]
105-
++ lib.concatMap
106-
(y: builtins.attrValues x.components."${y}")
107-
[ "benchmarks" "exes" "sublibs" "tests" ];
108-
in
109-
{
110-
111-
_module.args = { inherit pkgs; };
112-
113-
legacyPackages = pkgs // hsPkgs;
114-
115-
packages =
116-
hydraPackages //
117-
{
118-
spec = inputs.hydra-spec.packages.${system}.default;
119-
inherit tx-cost-diff;
120-
};
121-
122-
coding.standards.hydra = {
123-
enable = true;
124-
haskellPackages = with hsPkgs; builtins.concatMap allComponents [
125-
hydra-cardano-api
126-
hydra-chain-observer
127-
hydra-cluster
128-
hydra-node
129-
hydra-tx
130-
hydra-prelude
131-
hydra-plutus
132-
hydra-plutus-extras
133-
hydra-test-utils
134-
hydra-tui
135-
hydraw
136-
];
137-
inherit (pkgs) weeder;
138-
haskellType = "haskell.nix";
139-
};
140-
141-
devShells = import ./nix/hydra/shell.nix {
142-
inherit pkgs hsPkgs hydraPackages system;
143-
ghc = pkgs.buildPackages.haskell-nix.compiler.${compiler};
144-
};
145-
};
146-
};
26+
outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./nix);
14727

14828
nixConfig = {
14929
extra-substituters = [

nix/coding-standards.nix

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
_: {
2+
3+
perSystem = { pkgs, hsPkgs, lib, ... }:
4+
let
5+
allComponents = x:
6+
[ x.components.library ]
7+
++ lib.concatMap
8+
(y: builtins.attrValues x.components."${y}")
9+
[ "benchmarks" "exes" "sublibs" "tests" ];
10+
11+
in
12+
{
13+
14+
15+
coding.standards.hydra = {
16+
enable = true;
17+
haskellPackages = with hsPkgs; builtins.concatMap allComponents [
18+
hydra-cardano-api
19+
hydra-chain-observer
20+
hydra-cluster
21+
hydra-node
22+
hydra-tx
23+
hydra-prelude
24+
hydra-plutus
25+
hydra-plutus-extras
26+
hydra-test-utils
27+
hydra-tui
28+
hydraw
29+
];
30+
inherit (pkgs) weeder;
31+
haskellType = "haskell.nix";
32+
};
33+
34+
};
35+
}

nix/configuration.nix

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{ inputs, ... }: {
2+
3+
imports = [
4+
inputs.hydra-coding-standards.flakeModule
5+
inputs.process-compose-flake.flakeModule
6+
];
7+
8+
perSystem = { pkgs, hsPkgs, ... }:
9+
let
10+
compiler = "ghc967";
11+
inputMap = { "https://intersectmbo.github.io/cardano-haskell-packages" = inputs.CHaP; };
12+
in
13+
{
14+
_module.args = { inherit compiler inputMap; };
15+
legacyPackages = pkgs // hsPkgs;
16+
};
17+
}

0 commit comments

Comments
 (0)