Skip to content

Commit 32ef742

Browse files
committed
[DEVOPS-1061] pkgs/generate.sh: Also generate cabal.project.freeze
1 parent 3fbbc13 commit 32ef742

5 files changed

+36
-23
lines changed

cabal.project

-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
packages:
22
*/*.cabal
33
*/test/*.cabal
4-
5-
-- not sure why the cabal solver wants to download and build a newer beam-sqlite
6-
constraints: beam-sqlite == 0.3.2.1
7-
-- allow-newer: all
8-
-- allow-older: all

cabal.project.freeze

Whitespace-only changes.

docs/how-to/build-cardano-sl-and-daedalus-from-source-code.md

+6-12
Original file line numberDiff line numberDiff line change
@@ -186,25 +186,19 @@ Enter the `nix-shell`:
186186

187187
[nix-shell:~/cardano-sl]$ nix-shell
188188

189-
Let cabal find its dependencies (already provided by the `nix-shell`):
190-
191-
[nix-shell:~/cardano-sl]$ cabal new-configure
192-
193-
After that, to build all cardano-sl packages:
189+
Then build all cardano-sl packages:
194190

195191
[nix-shell:~/cardano-sl]$ cabal new-build all
196192

193+
All dependencies necessary for the Cabal build are provided by the
194+
`nix-shell`. The package versions are pinned in the
195+
`cabal.project.freeze` file, which is automatically generated from
196+
`stack.yaml` (via `stack2nix`).
197+
197198
To start a GHCi session for a component (wallet-new for example), run:
198199

199200
[nix-shell:~/cardano-sl]$ cabal new-repl cardano-sl-wallet-new
200201

201-
### Known issues
202-
203-
- `cabal-install` is not provided by the Nix shell environment. You
204-
have to install it yourself.
205-
- There needs to be a package version override in `cabal.project` for
206-
some unknown reason.
207-
208202

209203
## Daedalus Wallet
210204

pkgs/regen.nix

+5
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,9 @@ in
3939
# Generate cardano-sl package set
4040
stack2nix --platform x86_64-linux --hackage-snapshot "${hackageSnapshot}" -j8 --test --bench --no-indent ./.. > default.nix.new
4141
mv default.nix.new default.nix
42+
43+
# Generate cabal new-freeze file from package set
44+
cp --remove-destination --no-preserve=mode \
45+
$(nix-build ../shell.nix -A cabalProjectFreeze --no-out-link) \
46+
../cabal.project.freeze
4247
''

shell.nix

+25-6
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@ with pkgs;
77
let
88
localLib = import ./lib.nix;
99

10-
getCardanoSLDeps = with lib;
11-
ps: filter (drv: !(localLib.isCardanoSL drv.name))
12-
(concatMap haskell.lib.getHaskellBuildInputs
13-
(attrValues (filterAttrs isWantedDep ps)));
14-
isWantedDep = name: drv: localLib.isCardanoSL name && !(drv ? "gitrev");
10+
# Filters a haskell package set and returns only the packages which
11+
# are (transitive) dependencies of the cardano-sl packages.
12+
getCardanoSLDeps = with lib; let
13+
notCardano = drv: !(localLib.isCardanoSL drv.name);
14+
isTopLevel = name: drv: localLib.isCardanoSL name && (drv ? "override");
15+
getTopLevelDrvs = ps: attrValues (filterAttrs isTopLevel ps);
16+
sorted = ps: attrValues (listToAttrs (map (drv: { name = drv.pname; value = drv; }) ps));
17+
in
18+
ps: sorted (filter notCardano (concatMap haskell.lib.getHaskellBuildInputs (getTopLevelDrvs ps)));
19+
1520
ghc = iohkPkgs.ghc.withPackages getCardanoSLDeps;
1621

1722
stackDeps = [
@@ -59,6 +64,20 @@ let
5964
exit
6065
'';
6166
};
67+
68+
# Writes out a cabal new-freeze file containing the exact same
69+
# dependency versions as are provided by this shell.
70+
cabalProjectFreeze = let
71+
contents = ''
72+
-- This file is automatically generated from stack.yaml.
73+
constraints: ${constraints}
74+
'';
75+
constraints = lib.concatMapStringsSep ",\n "
76+
makeConstraint (getCardanoSLDeps iohkPkgs);
77+
makeConstraint = dep: "${dep.pname} ==${dep.version}";
78+
in
79+
pkgs.writeText "cabal.project.freeze" contents;
80+
6281
in cardanoSL // {
63-
inherit fixStylishHaskell;
82+
inherit fixStylishHaskell cabalProjectFreeze;
6483
}

0 commit comments

Comments
 (0)