Skip to content

Commit 3b6ae81

Browse files
committed
Move cabal-install, nix-tools building logic to overlay files
1 parent 1de979c commit 3b6ae81

File tree

3 files changed

+56
-138
lines changed

3 files changed

+56
-138
lines changed

overlays/cabal-install.nix

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,26 @@
1-
{ stdenv, fetchurl, lib }:
2-
3-
stdenv.mkDerivation rec {
4-
pname = "cabal-install";
5-
version = "3.14.1.1";
6-
7-
src = fetchurl {
8-
url = "https://downloads.haskell.org/~cabal/cabal-install-${version}/cabal-install-${version}-x86_64-linux-alpine3_18.tar.xz";
9-
sha256 = "sha256-KA273YDQ3grmr0dkNghQkUjLLs8JZ80lW1q8skHZWd4=";
10-
};
11-
12-
# Prevent Nix from automatically unpacking the source
13-
dontUnpack = true;
14-
15-
# No build steps are required
16-
buildPhase = "";
17-
18-
installPhase = ''
19-
mkdir -p $out/bin
20-
# Manually extract the tarball
21-
tar -xJf ${src}
22-
# Move the 'cabal' binary to $out/bin
23-
cp -v cabal $out/bin/
24-
# Ensure the binary is executable
25-
chmod +x $out/bin/cabal
26-
'';
27-
28-
# No dependencies are needed since the binary is statically linked
29-
buildInputs = [];
30-
31-
meta = with lib; {
32-
description = "The cabal-install tool (binary distribution)";
33-
homepage = "https://www.haskell.org/cabal/";
34-
license = licenses.bsd3;
35-
platforms = platforms.linux;
36-
maintainers = [];
37-
};
1+
final: prev:
2+
{ bootstrap-cabal-install =
3+
let
4+
cabal-install-src = final.pkgs.fetchurl {
5+
url = "https://hackage.haskell.org/package/cabal-install-3.14.1.1/cabal-install-3.14.1.1.tar.gz";
6+
sha256 = "sha256-8R02Srh/tGJ1qYfmBFOFdzIUd4CoxZJGDuyKFtu2us4=";
7+
};
8+
cabal-install-pkgs = final.haskell-nix.cabalProjectWithPlan
9+
{ src = cabal-install-src;
10+
compiler-nix-name = "ghc912";
11+
cabalProject = ''
12+
packages:
13+
./cabal-install.cabal
14+
package cabal-install
15+
tests: false
16+
'';
17+
}
18+
(_: {
19+
"extra-hackages" = [];
20+
"index-state-max" = "2025-01-17T00:00:00Z";
21+
"projectNix" = ../materialized/cabal-install-3.14.1.1;
22+
"sourceRepos" = [];
23+
"src" = cabal-install-src;
24+
});
25+
in cabal-install-pkgs.hsPkgs.cabal-install.components.exes.cabal;
3826
}

overlays/default.nix

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,13 @@
11
{ sources }:
22
let
33
overlays = {
4-
cabal-install-overlay = final: prev:
5-
{ bootstrap-cabal-install =
6-
let
7-
cabal-install-src = final.pkgs.fetchurl {
8-
url = "https://hackage.haskell.org/package/cabal-install-3.14.1.1/cabal-install-3.14.1.1.tar.gz";
9-
sha256 = "sha256-8R02Srh/tGJ1qYfmBFOFdzIUd4CoxZJGDuyKFtu2us4=";
10-
};
11-
cabal-install-pkgs = final.haskell-nix.cabalProjectWithPlan
12-
{ src = cabal-install-src;
13-
compiler-nix-name = "ghc912";
14-
cabalProject = ''
15-
packages:
16-
./cabal-install.cabal
17-
package cabal-install
18-
tests: false
19-
'';
20-
}
21-
(_: {
22-
"extra-hackages" = [];
23-
"index-state-max" = "2025-01-17T00:00:00Z";
24-
"projectNix" = ../materialized/cabal-install-3.14.1.1;
25-
"sourceRepos" = [];
26-
"src" = cabal-install-src;
27-
});
28-
in cabal-install-pkgs.hsPkgs.cabal-install.components.exes.cabal;
29-
};
4+
cabal-install-overlay = import ./cabal-install.nix;
305

316
haskell = import ./haskell.nix { inherit sources; };
327

338
# Here is where we import nix-tools into the overlays that haskell.nix is
349
# going to use.
35-
nix-tools = (final: prev:
36-
let
37-
38-
# Import the overlay from nix-tools' subdirectory
39-
nix-tools-exes = final.callPackage ./nix-tools.nix {};
40-
41-
in
42-
{
43-
haskell-nix =
44-
prev.haskell-nix // {
45-
nix-tools =
46-
let nix-tools-pkgs = final.haskell-nix.cabalProjectWithPlan
47-
{ src = ../nix-tools; compiler-nix-name = "ghc912"; }
48-
(_: {
49-
"extra-hackages" = [];
50-
"index-state-max" = "2025-01-17T00:00:00Z";
51-
"projectNix" = ../materialized/nix-tools;
52-
"sourceRepos" = [
53-
(final.pkgs.fetchgit {
54-
url = "https://github.com/kronor-io/hackage-db";
55-
sha256 = "11g395vrrsaasl1ssk8qfbcc9wx6aygipsldyclgn4szpm4xzm7h";
56-
rev = "83f819cb08742d3c86a83b407d45c1f6c1c7e299";
57-
})
58-
];
59-
"src" = ../nix-tools;
60-
});
61-
in {
62-
exes = {
63-
truncate-index = nix-tools-pkgs.hsPkgs.nix-tools.components.exes.truncate-index;
64-
make-install-plan = nix-tools-pkgs.hsPkgs.nix-tools.components.exes.make-install-plan;
65-
plan-to-nix = nix-tools-pkgs.hsPkgs.nix-tools.components.exes.plan-to-nix;
66-
hackage-to-nix = nix-tools-pkgs.hsPkgs.nix-tools.components.exes.hackage-to-nix;
67-
};
68-
};
69-
};
70-
});
10+
nix-tools = import ./nix-tools.nix;
7111

7212
bootstrap = import ./bootstrap.nix;
7313
ghc = import ./ghc.nix;

overlays/nix-tools.nix

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,30 @@
1-
{ stdenv, fetchurl, lib }:
2-
3-
stdenv.mkDerivation rec {
4-
pname = "nix-tools";
5-
version = "0.1.0.0";
6-
7-
src = fetchurl {
8-
url = "https://pgnb.s3.ap-south-2.amazonaws.com/nix-tools-alpine-amd.tar.xz";
9-
sha256 = "sha256-/qff9cYlWGvlWPHgsgC9OXxidK4lrF754u91gh9BbTA=";
10-
};
11-
12-
# Prevent Nix from automatically unpacking the source
13-
dontUnpack = true;
14-
15-
# No build steps are required
16-
buildPhase = "";
17-
18-
installPhase = ''
19-
mkdir -p $out/bin
20-
# Manually extract the tarball
21-
tar -xJf ${src}
22-
23-
# Move all binaries to $out/bin
24-
find ./dist-newstyle/ -type f -executable | xargs -I {} cp -v {} $out/bin/
25-
26-
# Ensure the binaries are executable
27-
chmod +x $out/bin/*
28-
'';
29-
30-
# No dependencies are needed since the binary is statically linked
31-
buildInputs = [];
32-
33-
meta = with lib; {
34-
description = "nix-tools";
35-
homepage = "https://github.com/input-output-hk/haskell.nix";
36-
license = licenses.bsd3;
37-
platforms = platforms.linux;
38-
maintainers = [];
39-
};
1+
final: prev:
2+
{
3+
haskell-nix =
4+
prev.haskell-nix // {
5+
nix-tools =
6+
let nix-tools-pkgs = final.haskell-nix.cabalProjectWithPlan
7+
{ src = ../nix-tools; compiler-nix-name = "ghc912"; }
8+
(_: {
9+
"extra-hackages" = [];
10+
"index-state-max" = "2025-01-17T00:00:00Z";
11+
"projectNix" = ../materialized/nix-tools;
12+
"sourceRepos" = [
13+
(final.pkgs.fetchgit {
14+
url = "https://github.com/kronor-io/hackage-db";
15+
sha256 = "11g395vrrsaasl1ssk8qfbcc9wx6aygipsldyclgn4szpm4xzm7h";
16+
rev = "83f819cb08742d3c86a83b407d45c1f6c1c7e299";
17+
})
18+
];
19+
"src" = ../nix-tools;
20+
});
21+
in {
22+
exes = {
23+
truncate-index = nix-tools-pkgs.hsPkgs.nix-tools.components.exes.truncate-index;
24+
make-install-plan = nix-tools-pkgs.hsPkgs.nix-tools.components.exes.make-install-plan;
25+
plan-to-nix = nix-tools-pkgs.hsPkgs.nix-tools.components.exes.plan-to-nix;
26+
hackage-to-nix = nix-tools-pkgs.hsPkgs.nix-tools.components.exes.hackage-to-nix;
27+
};
28+
};
29+
};
4030
}

0 commit comments

Comments
 (0)