Skip to content

Commit fc87a1c

Browse files
Add tarballs with static binaries (#2025)
* Add tarballs with static binaries * Expose nix-tools hydraJobs in the main flake * Pass pkgs to flake-compat * Move exes into a bin sub dir * Use static nix-tools * Use static nix-tools * Clearer nix-tools tarball code * Add cabal and hpack to the nix-tools tarball * Simplify nix-tools tarball * Update nix-tools tarball * Use cabal-install from nix-tools tarball * Remove nix-tools wrapper script * New clothes for nix-tools's tarball * Temporarily disable the tarball * Update nix-tools tarball and s/attrValues/attrNames * Add s/internal-nix-tools/unchecked-nix-tools * Add s/unchecked-nix-tools/nix-tools-unchecked * Get `cabal-install` from `nix-tools` * Qualify the nix-tools tarball with host platform * Add comments * Bump nix-tools tarball --------- Co-authored-by: Hamish Mackenzie <Hamish.K.Mackenzie@gmail.com>
1 parent 07c70ba commit fc87a1c

File tree

12 files changed

+233
-224
lines changed

12 files changed

+233
-224
lines changed

build.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ in rec {
7474
inherit (pkgs) stdenv lib writeScript coreutils glibc git
7575
openssh nixFlakes gawk bash curl findutils;
7676
# Update scripts use the internal nix-tools and cabal-install (compiled with a fixed GHC version)
77-
nix-tools = haskell.internal-nix-tools;
77+
nix-tools = haskell.nix-tools-unchecked;
7878
cabal-install = haskell.internal-cabal-install;
7979
inherit (haskell) update-index-state-hashes cabal-issue-8352-workaround;
8080
};
8181
update-stackage = haskell.callPackage ./scripts/update-stackage.nix {
8282
inherit (pkgs) stdenv lib writeScript coreutils glibc git
8383
openssh nixFlakes gawk bash curl findutils;
8484
# Update scripts use the internal nix-tools and cabal-install (compiled with a fixed GHC version)
85-
nix-tools = haskell.internal-nix-tools;
85+
nix-tools = haskell.nix-tools-unchecked;
8686
cabal-install = haskell.internal-cabal-install;
8787
inherit (haskell) cabal-issue-8352-workaround;
8888
};

builder/comp-builder.nix

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,8 @@ let
294294
(if cabalFile != null
295295
then ''cp -v $cabalFilePath ${package.identifier.name}.cabal''
296296
else
297-
# When building hpack package we use the internal nix-tools
298-
# (compiled with a fixed GHC version)
299297
lib.optionalString (cabal-generator == "hpack") ''
300-
${buildPackages.haskell-nix.internal-nix-tools}/bin/hpack
298+
${buildPackages.haskell-nix.nix-tools-unchecked}/bin/hpack
301299
''
302300
) + lib.optionalString (prePatch != null) "\n${prePatch}";
303301
}

flake.nix

Lines changed: 102 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,11 @@
6666
};
6767
};
6868

69-
outputs = { self, nixpkgs, nixpkgs-unstable, nixpkgs-2105, nixpkgs-2111, nixpkgs-2205, nixpkgs-2211, nixpkgs-2305, flake-utils, ... }@inputs:
70-
let compiler = "ghc928";
69+
outputs = { self, nixpkgs, nixpkgs-unstable, nixpkgs-2105, nixpkgs-2111, nixpkgs-2205, nixpkgs-2211, nixpkgs-2305, flake-compat, flake-utils, ... }@inputs:
70+
let
71+
callFlake = import flake-compat;
72+
73+
compiler = "ghc928";
7174
config = import ./config.nix;
7275

7376
traceNames = prefix: builtins.mapAttrs (n: v:
@@ -79,11 +82,20 @@
7982

8083
traceHydraJobs = x: x // { inherit (traceNames "" x) hydraJobs; };
8184

85+
# systems supported by haskell.nix
86+
systems = [
87+
"x86_64-linux"
88+
"x86_64-darwin"
89+
# TODO switch back on when ci.iog.io has builders for aarch64-linux
90+
# "aarch64-linux"
91+
"aarch64-darwin"
92+
];
93+
8294
in traceHydraJobs ({
8395
inherit config;
8496
overlay = self.overlays.combined;
8597
overlays = import ./overlays { sources = inputs; };
86-
internal = rec {
98+
internal = {
8799
nixpkgsArgs = {
88100
inherit config;
89101
overlays = [ self.overlay ];
@@ -139,85 +151,93 @@
139151
# supported by haskell.nix, e.g. with remote builders, in order to check this flake.
140152
# If you want to run the tests for just your platform, run `./test/tests.sh` or
141153
# `nix-build -A checks.$PLATFORM`
142-
} // flake-utils.lib.eachSystem [
143-
"x86_64-linux"
144-
"x86_64-darwin"
145-
# TODO switch back on when ci.iog.io has builders for aarch64-linux
146-
# "aarch64-linux"
147-
"aarch64-darwin" ] (system: rec {
148-
legacyPackages = (self.internal.compat { inherit system; }).pkgs;
149-
legacyPackagesUnstable = (self.internal.compat { inherit system; }).pkgs-unstable;
150-
151-
# FIXME: Currently `nix flake check` requires `--impure` because coverage-golden
152-
# (and maybe other tests) import projects that use builtins.currentSystem
153-
checks = builtins.listToAttrs (map (pkg: {
154-
name = pkg.name;
155-
value = pkg;
156-
}) (nixpkgs.lib.collect nixpkgs.lib.isDerivation (import ./test rec {
157-
haskellNix = self.internal.compat { inherit system; };
158-
compiler-nix-name = compiler;
159-
pkgs = haskellNix.pkgs;
160-
})));
161-
# Exposed so that buildkite can check that `allow-import-from-derivation=false` works for core of haskell.nix
162-
roots = legacyPackagesUnstable.haskell-nix.roots compiler;
163-
164-
packages = (self.internal.compat { inherit system; }).hix.apps;
165-
166-
allJobs =
167-
let
168-
inherit (import ./ci-lib.nix { pkgs = legacyPackagesUnstable; }) stripAttrsForHydra filterDerivations;
169-
ci = import ./ci.nix { inherit (self.internal) compat; inherit system; };
170-
in stripAttrsForHydra (filterDerivations ci);
171-
172-
requiredJobs =
173-
let
174-
inherit (legacyPackages) lib;
175-
names = x: lib.filter (n: n != "recurseForDerivations" && n != "meta")
176-
(builtins.attrNames x);
177-
in
178-
builtins.listToAttrs (
179-
lib.concatMap (nixpkgsVer:
180-
let nixpkgsJobs = allJobs.${nixpkgsVer};
181-
in lib.concatMap (compiler-nix-name:
182-
let ghcJobs = nixpkgsJobs.${compiler-nix-name};
183-
in builtins.map (crossPlatform: {
184-
name = "required-${nixpkgsVer}-${compiler-nix-name}-${crossPlatform}";
185-
value = legacyPackages.releaseTools.aggregate {
186-
name = "haskell.nix-${nixpkgsVer}-${compiler-nix-name}-${crossPlatform}";
187-
meta.description = "All ${nixpkgsVer} ${compiler-nix-name} ${crossPlatform} jobs";
188-
constituents = lib.collect lib.isDerivation ghcJobs.${crossPlatform};
189-
};
190-
}) (names ghcJobs)
191-
) (names nixpkgsJobs)
192-
) (names allJobs));
193-
194-
hydraJobs = allJobs;
195-
196-
devShells = with self.legacyPackages.${system}; {
197-
default =
198-
mkShell {
199-
buildInputs = [
200-
nixUnstable
201-
cabal-install
202-
haskell-nix.compiler.${compiler}
203-
];
204-
};
205-
} // __mapAttrs (compiler-nix-name: compiler:
206-
mkShell {
207-
buildInputs = [
208-
compiler
209-
haskell-nix.cabal-install.${compiler-nix-name}
210-
];
211-
}
212-
) (
213-
# Exclude old versions of GHC to speed up `nix flake check`
214-
builtins.removeAttrs haskell-nix.compiler
215-
[ "ghc844"
216-
"ghc861" "ghc862" "ghc863" "ghc864"
217-
"ghc881" "ghc882" "ghc883"
218-
"ghc8101" "ghc8102" "ghc8103" "ghc8104" "ghc8105" "ghc8106" "ghc810420210212"
219-
"ghc901"
220-
"ghc921" "ghc922" "ghc923"]);
154+
} // flake-utils.lib.eachSystem systems (system:
155+
let
156+
legacyPackages = (self.internal.compat { inherit system; }).pkgs;
157+
nix-tools-hydraJobs =
158+
let cf = callFlake { pkgs = legacyPackages; inherit system; src = ./nix-tools; };
159+
in cf.defaultNix.hydraJobs;
160+
in rec {
161+
inherit legacyPackages;
162+
legacyPackagesUnstable = (self.internal.compat { inherit system; }).pkgs-unstable;
163+
164+
# FIXME: Currently `nix flake check` requires `--impure` because coverage-golden
165+
# (and maybe other tests) import projects that use builtins.currentSystem
166+
checks = builtins.listToAttrs (map (pkg: {
167+
name = pkg.name;
168+
value = pkg;
169+
}) (nixpkgs.lib.collect nixpkgs.lib.isDerivation (import ./test rec {
170+
haskellNix = self.internal.compat { inherit system; };
171+
compiler-nix-name = compiler;
172+
pkgs = haskellNix.pkgs;
173+
})));
174+
# Exposed so that buildkite can check that `allow-import-from-derivation=false` works for core of haskell.nix
175+
roots = legacyPackagesUnstable.haskell-nix.roots compiler;
176+
177+
packages = (self.internal.compat { inherit system; }).hix.apps;
178+
179+
allJobs =
180+
let
181+
inherit (import ./ci-lib.nix { pkgs = legacyPackagesUnstable; }) stripAttrsForHydra filterDerivations;
182+
ci = import ./ci.nix { inherit (self.internal) compat; inherit system; };
183+
in stripAttrsForHydra (filterDerivations ci);
184+
185+
requiredJobs =
186+
let
187+
inherit (legacyPackages) lib;
188+
names = x: lib.filter (n: n != "recurseForDerivations" && n != "meta")
189+
(builtins.attrNames x);
190+
in
191+
builtins.listToAttrs (
192+
lib.concatMap (nixpkgsVer:
193+
let nixpkgsJobs = allJobs.${nixpkgsVer};
194+
in lib.concatMap (compiler-nix-name:
195+
let ghcJobs = nixpkgsJobs.${compiler-nix-name};
196+
in builtins.map (crossPlatform: {
197+
name = "required-${nixpkgsVer}-${compiler-nix-name}-${crossPlatform}";
198+
value = legacyPackages.releaseTools.aggregate {
199+
name = "haskell.nix-${nixpkgsVer}-${compiler-nix-name}-${crossPlatform}";
200+
meta.description = "All ${nixpkgsVer} ${compiler-nix-name} ${crossPlatform} jobs";
201+
constituents = lib.collect lib.isDerivation ghcJobs.${crossPlatform};
202+
};
203+
}) (names ghcJobs)
204+
) (names nixpkgsJobs)
205+
) (names allJobs));
206+
207+
hydraJobs =
208+
allJobs
209+
# Include hydraJobs from nix-tools subflake.
210+
# NOTE: These derivations do not depend on the haskell.nix in ./. but
211+
# on the version of haskell.nix locked in the subflake. They are
212+
# evaluated within their own flake and independently of anything
213+
# else. Here we only expose them in the main flake.
214+
// { nix-tools = nix-tools-hydraJobs.${system} or {}; };
215+
216+
devShells = with self.legacyPackages.${system}; {
217+
default =
218+
mkShell {
219+
buildInputs = [
220+
nixUnstable
221+
cabal-install
222+
haskell-nix.compiler.${compiler}
223+
];
224+
};
225+
} // __mapAttrs (compiler-nix-name: compiler:
226+
mkShell {
227+
buildInputs = [
228+
compiler
229+
haskell-nix.cabal-install.${compiler-nix-name}
230+
];
231+
}
232+
) (
233+
# Exclude old versions of GHC to speed up `nix flake check`
234+
builtins.removeAttrs haskell-nix.compiler
235+
[ "ghc844"
236+
"ghc861" "ghc862" "ghc863" "ghc864"
237+
"ghc881" "ghc882" "ghc883"
238+
"ghc8101" "ghc8102" "ghc8103" "ghc8104" "ghc8105" "ghc8106" "ghc810420210212"
239+
"ghc901"
240+
"ghc921" "ghc922" "ghc923"]);
221241
}));
222242

223243
# --- Flake Local Nix Configuration ----------------------------

lib/call-cabal-project-to-nix.nix

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ let
7373
nix-tools = if args.nix-tools or null != null
7474
then args.nix-tools
7575
else evalPackages.haskell-nix.nix-tools-unchecked;
76-
cabal-install = if args.cabal-install or null != null
77-
then args.cabal-install
78-
else evalPackages.haskell-nix.cabal-install-unchecked.${compiler-nix-name};
76+
cabal-install = nix-tools.exes.cabal;
7977
forName = pkgs.lib.optionalString (name != null) (" for " + name);
8078
nameAndSuffix = suffix: if name == null then suffix else name + "-" + suffix;
8179

@@ -368,11 +366,14 @@ let
368366
} // pkgs.lib.optionalAttrs (checkMaterialization != null) {
369367
inherit checkMaterialization;
370368
}) (evalPackages.runCommand (nameAndSuffix "plan-to-nix-pkgs") {
371-
nativeBuildInputs = [
372-
nix-tools.exes.make-install-plan
373-
nix-tools.exes.plan-to-nix
374-
dummy-ghc dummy-ghc-pkg cabal-install evalPackages.rsync evalPackages.gitMinimal evalPackages.allPkgConfigWrapper ]
375-
++ pkgs.lib.optional supportHpack nix-tools.exes.hpack;
369+
nativeBuildInputs =
370+
# The things needed from nix-tools
371+
[ nix-tools.exes.make-install-plan
372+
nix-tools.exes.plan-to-nix
373+
nix-tools.exes.cabal
374+
]
375+
++ pkgs.lib.optional supportHpack nix-tools.exes.hpack
376+
++ [dummy-ghc dummy-ghc-pkg evalPackages.rsync evalPackages.gitMinimal evalPackages.allPkgConfigWrapper ];
376377
# Needed or stack-to-nix will die on unicode inputs
377378
LOCALE_ARCHIVE = pkgs.lib.optionalString (evalPackages.stdenv.buildPlatform.libc == "glibc") "${evalPackages.glibcLocales}/lib/locale/locale-archive";
378379
LANG = "en_US.UTF-8";

modules/cabal-project.nix

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,6 @@ in {
9090
default = null;
9191
description = "nix-tools to use when converting the `plan.json` to nix";
9292
};
93-
cabal-install = mkOption {
94-
type = nullOr package;
95-
default = null;
96-
description = "cabal-install to use when running `cabal configure`";
97-
};
9893
configureArgs = mkOption {
9994
type = nullOr (separatedString " ");
10095
default = "";

modules/stack-project.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ with types;
3737
};
3838
nix-tools = mkOption {
3939
type = package;
40-
default = config.evalPackages.haskell-nix.internal-nix-tools; # When building stack projects we use the internal nix-tools (compiled with a fixed GHC version)
40+
default = config.evalPackages.haskell-nix.nix-tools-unchecked; # When building stack projects we use the internal nix-tools (compiled with a fixed GHC version)
4141
description = "nix-tools to use when converting the `plan.json` to nix";
4242
};
4343

nix-tools/cabal.project

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ with-compiler: ghc-9.2.8
44

55
packages: nix-tools
66

7+
-- haskell.nix expects nix-tools to provide the cabal and hpack executables
8+
-- so we put these two packages here, so they will be present even if nix-tools
9+
-- dependencies change
10+
extra-packages: cabal-install, hpack
11+
712
test-show-details: direct
813

914
allow-newer:

0 commit comments

Comments
 (0)