Skip to content

Commit 313ac10

Browse files
Try #1546:
2 parents 3a81e80 + 08bf47c commit 313ac10

File tree

82 files changed

+536
-428
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+536
-428
lines changed

.buildkite/pipeline.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,9 @@ steps:
4444
- nix build .#roots.x86_64-linux --option allow-import-from-derivation false
4545
agents:
4646
system: x86_64-linux
47+
48+
- label: 'Check that evaluation of hydra jobs works without using remote builders'
49+
command:
50+
- nix-instantiate release.nix -A required-unstable-ghc8107-x86_64-darwin-native --show-trace --builders ''
51+
agents:
52+
system: x86_64-linux

build.nix

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ in
88
{ nixpkgs ? haskellNix.sources.nixpkgs-2111
99
, nixpkgsArgs ? haskellNix.nixpkgsArgs
1010
, pkgs ? import nixpkgs nixpkgsArgs
11+
, evalPackages ? import nixpkgs nixpkgsArgs
1112
, nixpkgsForHydra ? haskellNix.sources.nixpkgs-2105
12-
, pkgsForHydra ? import nixpkgsForHydra nixpkgsArgs
13+
, pkgsForHydra ? import nixpkgsForHydra (nixpkgsArgs // { inherit (pkgs) system; })
1314
, ifdLevel ? 1000
1415
, compiler-nix-name ? throw "No `compiler-nix-name` passed to build.nix"
1516
}:
@@ -19,12 +20,13 @@ let
1920
buildHaskell = pkgs.buildPackages.haskell-nix;
2021
tool = buildHaskell.tool;
2122
in rec {
22-
tests = import ./test/default.nix { inherit pkgs ifdLevel compiler-nix-name; };
23+
tests = import ./test/default.nix { inherit pkgs evalPackages ifdLevel compiler-nix-name; };
2324

2425
tools = pkgs.lib.optionalAttrs (ifdLevel >= 3) (
2526
pkgs.recurseIntoAttrs ({
26-
cabal-latest = tool compiler-nix-name "cabal" "latest";
27+
cabal-latest = tool compiler-nix-name "cabal" { inherit evalPackages; };
2728
hlint-latest = tool compiler-nix-name "hlint" {
29+
inherit evalPackages;
2830
version = {
2931
"ghc865" = "3.2.8";
3032
"ghc882" = "3.3.6";
@@ -33,7 +35,7 @@ in rec {
3335
}.compiler-nix-name or "latest";
3436
};
3537
} // pkgs.lib.optionalAttrs (!__elem compiler-nix-name ["ghc921" "ghc922" "ghc923"]) {
36-
hls-latest = tool compiler-nix-name "haskell-language-server" "latest";
38+
hls-latest = tool compiler-nix-name "haskell-language-server" { inherit evalPackages; };
3739
})
3840
);
3941

@@ -85,7 +87,7 @@ in rec {
8587
# These are pure parts of maintainer-script so they can be built by hydra
8688
# and added to the cache to speed up buildkite.
8789
maintainer-script-cache = pkgs.recurseIntoAttrs (
88-
(pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
90+
(pkgs.lib.optionalAttrs (pkgsForHydra.system == "x86_64-linux") {
8991
inherit (maintainer-scripts) check-hydra;
9092
})
9193
// (pkgs.lib.optionalAttrs (ifdLevel > 2) {

builder/default.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ pkgs, buildPackages, stdenv, lib, haskellLib, ghc, compiler-nix-name, fetchurl, pkgconfig, nonReinstallablePkgs, hsPkgs, compiler }:
1+
{ pkgs, buildPackages, evalPackages, stdenv, lib, haskellLib, ghc, compiler-nix-name, fetchurl, pkgconfig, nonReinstallablePkgs, hsPkgs, compiler }:
22

33
let
44
# Builds a single component of a package.
@@ -46,6 +46,7 @@ let
4646
hoogleLocal = let
4747
nixpkgsHoogle = import (pkgs.path + /pkgs/development/haskell-modules/hoogle.nix);
4848
in { packages ? [], hoogle ? pkgs.buildPackages.haskell-nix.tool "ghc8107" "hoogle" {
49+
inherit evalPackages;
4950
version = "5.0.18.3";
5051
index-state = pkgs.haskell-nix.internalHackageIndexState;
5152
}
@@ -66,7 +67,7 @@ let
6667

6768
# Same as haskellPackages.shellFor in nixpkgs.
6869
shellFor = haskellLib.weakCallPackage pkgs ./shell-for.nix {
69-
inherit hsPkgs ghcForComponent makeConfigFiles hoogleLocal haskellLib buildPackages compiler;
70+
inherit hsPkgs ghcForComponent makeConfigFiles hoogleLocal haskellLib buildPackages evalPackages compiler;
7071
inherit (buildPackages) glibcLocales;
7172
};
7273

builder/shell-for.nix

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ lib, stdenv, mkShell, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib, buildPackages, compiler }:
1+
{ lib, stdenv, mkShell, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib, buildPackages, evalPackages, compiler }:
22

33
{ # `packages` function selects packages that will be worked on in the shell itself.
44
# These packages will not be built by `shellFor`, but their
@@ -133,7 +133,12 @@ let
133133
# inherit (hsPkgs) hoogle;
134134
} // (
135135
lib.optionalAttrs (args ? tools && args.tools ? hoogle) {
136-
hoogle = buildPackages.haskell-nix.tool compiler.nix-name "hoogle" args.tools.hoogle;
136+
hoogle = buildPackages.haskell-nix.hackage-tool (
137+
haskellLib.versionOrModToMods args.tools.hoogle ++ [{
138+
name = "hoogle";
139+
compiler-nix-name = compiler.nix-name;
140+
inherit evalPackages;
141+
}]);
137142
}
138143
));
139144

@@ -147,7 +152,7 @@ in
147152
nativeBuildInputs = [ ghcEnv ]
148153
++ nativeBuildInputs
149154
++ mkDrvArgs.nativeBuildInputs or []
150-
++ lib.attrValues (buildPackages.haskell-nix.tools compiler.nix-name tools)
155+
++ lib.attrValues (buildPackages.haskell-nix.tools evalPackages compiler.nix-name tools)
151156
# If this shell is a cross compilation shell include
152157
# wrapper script for running cabal build with appropriate args.
153158
# Includes `--with-compiler` in case the `cabal.project` file has `with-compiler:` in it.

changelog.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
11
This file contains a summary of changes to Haskell.nix and `nix-tools`
22
that will impact users.
33

4+
## Jul 22, 2022
5+
* Removed reliance on `builtins.currentSystem`. It was used it to provide
6+
`pkgs.evalPackages` via an overlay that it used to run derivations
7+
used in imports from derivation (IFDs).
8+
9+
These derivations are now run on `buildPackages` by default.
10+
11+
Passsing `evalPackages` to a project function will change where all the
12+
derivations used in IFDs are run for that project (including shell tools):
13+
evalPackages = import nixpkgs haskellNix.nixpkgsArgs;
14+
15+
Passing `evalSystem` instead will use create a suitable `nixpkgs` using `pkgs.path`
16+
and `pkgs.overlay`:
17+
evalSystem = "x86_64-linux";
18+
or
19+
evalSystem = builtins.currentSystem;
20+
21+
The `haskellLib.cleanGit` function is also affected by this change. If you are cross
22+
compiling and using `cleanGit` you should probably do something like:
23+
pkgs = import nixpkgs haskellNix.nixpkgsArgs;
24+
evalPackages = import nixpkgs (haskellNix.nixpkgsArgs // { system = evalSystem; });
25+
p = pkgs.pkgsCross.mingwW64.haskell-nix.cabalProject {
26+
inherit evalPackages;
27+
src = evalPackages.haskell-nix.haskellLib.cleanGit { src = ./.; };
28+
};
29+
430
## Feb 16, 2022
531
* Removed lookupSha256 argument from project functions.
632
Pass a `sha256map` instead.

ci.nix

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,11 @@
7878
in
7979
dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: nixpkgs-pin:
8080
let pinnedNixpkgsSrc = sources.${nixpkgs-pin};
81-
# We need this for generic nixpkgs stuff at the right version
82-
genericPkgs = import pinnedNixpkgsSrc {};
83-
in dimension "GHC version" (compilerNixNames nixpkgsName genericPkgs) (compiler-nix-name: {runTests}:
84-
dimension "System" (systems nixpkgsName genericPkgs compiler-nix-name) (systemName: system:
81+
evalPackages = import pinnedNixpkgsSrc nixpkgsArgs;
82+
in dimension "GHC version" (compilerNixNames nixpkgsName evalPackages) (compiler-nix-name: {runTests}:
83+
dimension "System" (systems nixpkgsName evalPackages compiler-nix-name) (systemName: system:
8584
let pkgs = import pinnedNixpkgsSrc (nixpkgsArgs // { inherit system; });
86-
build = import ./build.nix { inherit pkgs ifdLevel compiler-nix-name; };
85+
build = import ./build.nix { inherit pkgs evalPackages ifdLevel compiler-nix-name; };
8786
platformFilter = platformFilterGeneric pkgs system;
8887
in filterAttrsOnlyRecursive (_: v: platformFilter v && !(isDisabled v)) ({
8988
# Native builds
@@ -96,14 +95,14 @@ dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: nixpkgs-pin:
9695
} // pkgs.lib.optionalAttrs (ifdLevel >= 1) {
9796
iserv-proxy = pkgs.ghc-extra-projects."${compiler-nix-name}".getComponent "iserv-proxy:exe:iserv-proxy";
9897
} // pkgs.lib.optionalAttrs (ifdLevel >= 3) {
99-
hello = (pkgs.haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2"; inherit compiler-nix-name; }).getComponent "exe:hello";
98+
hello = (pkgs.haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2"; inherit evalPackages compiler-nix-name; }).getComponent "exe:hello";
10099
});
101100
}
102101
//
103-
dimension "Cross system" (crossSystems nixpkgsName genericPkgs compiler-nix-name system) (crossSystemName: crossSystem:
102+
dimension "Cross system" (crossSystems nixpkgsName evalPackages compiler-nix-name system) (crossSystemName: crossSystem:
104103
# Cross builds
105104
let pkgs = import pinnedNixpkgsSrc (nixpkgsArgs // { inherit system crossSystem; });
106-
build = import ./build.nix { inherit pkgs ifdLevel compiler-nix-name; };
105+
build = import ./build.nix { inherit pkgs evalPackages ifdLevel compiler-nix-name; };
107106
in pkgs.recurseIntoAttrs (pkgs.lib.optionalAttrs (ifdLevel >= 1) ({
108107
roots = pkgs.haskell-nix.roots' compiler-nix-name ifdLevel;
109108
ghc = pkgs.buildPackages.haskell-nix.compiler."${compiler-nix-name}";

flake.nix

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
};
6060
};
6161

62-
outputs = { self, nixpkgs, nixpkgs-unstable, nixpkgs-2105, flake-utils, ... }@inputs:
62+
outputs = { self, nixpkgs, nixpkgs-unstable, nixpkgs-2105, nixpkgs-2111, nixpkgs-2205, flake-utils, ... }@inputs:
6363
let compiler = "ghc923";
6464
config = import ./config.nix;
6565
in {
@@ -101,6 +101,12 @@
101101
};
102102
pkgs = import nixpkgs
103103
(nixpkgsArgs // { localSystem = { inherit system; }; });
104+
pkgs-2105 = import nixpkgs-2105
105+
(nixpkgsArgs // { localSystem = { inherit system; }; });
106+
pkgs-2111 = import nixpkgs-2111
107+
(nixpkgsArgs // { localSystem = { inherit system; }; });
108+
pkgs-2205 = import nixpkgs-2205
109+
(nixpkgsArgs // { localSystem = { inherit system; }; });
104110
pkgs-unstable = import nixpkgs-unstable
105111
(nixpkgsArgs // { localSystem = { inherit system; }; });
106112
hix = import ./hix/default.nix { inherit pkgs; };

hix/project.nix

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,20 @@ let
5656
nixpkgsArgs = config.haskellNix.nixpkgsArgs // {
5757
overlays = config.haskellNix.nixpkgsArgs.overlays ++ config.overlays;
5858
};
59-
pkgs = import config.nixpkgs config.nixpkgsArgs;
60-
project = config.pkgs.haskell-nix.project [
59+
_module.args.pkgs = import config.nixpkgs config.nixpkgsArgs;
60+
project = pkgs.haskell-nix.project [
6161
(import ../modules/hix-project.nix)
6262
userDefaults
6363
projectDefaults
6464
commandArgs'
65-
{
65+
({config, ...}: {
6666
src =
6767
if __pathExists (toString (src.origSrcSubDir or src) + "/.git")
68-
then config.pkgs.haskell-nix.haskellLib.cleanGit {
68+
then config.evalPackages.haskell-nix.haskellLib.cleanGit {
6969
inherit src name;
7070
}
7171
else src;
72-
}
72+
})
7373
];
7474
})
7575
];

lib/cabal-project-parser.nix

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ let
122122
# This works because `cabal configure` does not include any of the `/nix/sore/`
123123
# paths in the `plan.json` (so materialized plan-nix will still work as expeced).
124124
# See tests/unit.nix for examples of input and output.
125-
parseRepositoryBlock = cabalProjectFileName: sha256map: inputMap: cabal-install: nix-tools: block:
125+
parseRepositoryBlock = evalPackages: cabalProjectFileName: sha256map: inputMap: cabal-install: nix-tools: block:
126126
let
127127
lines = pkgs.lib.splitString "\n" block;
128128
# The first line will contain the repository name.
@@ -138,7 +138,7 @@ let
138138
# The $HOME/.cabal/packages/${name} after running `cabal v2-update` to download the repository
139139
repoContents = if inputMap ? ${attrs.url}
140140
# If there is an input use it to make `file:` url and create a suitable `.cabal/packages/${name}` directory
141-
then pkgs.evalPackages.runCommand name ({
141+
then evalPackages.runCommand name ({
142142
nativeBuildInputs = [ cabal-install ];
143143
preferLocalBuild = true;
144144
}) ''
@@ -155,9 +155,9 @@ let
155155
cabal v2-update ${name}
156156
cp -r $HOME/.cabal/packages/${name} $out
157157
''
158-
else pkgs.evalPackages.runCommand name ({
159-
nativeBuildInputs = [ cabal-install pkgs.evalPackages.curl nix-tools ];
160-
LOCALE_ARCHIVE = pkgs.lib.optionalString (pkgs.evalPackages.stdenv.buildPlatform.libc == "glibc") "${pkgs.evalPackages.glibcLocales}/lib/locale/locale-archive";
158+
else evalPackages.runCommand name ({
159+
nativeBuildInputs = [ cabal-install evalPackages.curl nix-tools ];
160+
LOCALE_ARCHIVE = pkgs.lib.optionalString (evalPackages.stdenv.buildPlatform.libc == "glibc") "${evalPackages.glibcLocales}/lib/locale/locale-archive";
161161
LANG = "en_US.UTF-8";
162162
preferLocalBuild = true;
163163
} // pkgs.lib.optionalAttrs (sha256 != null) {
@@ -175,15 +175,15 @@ let
175175
${pkgs.lib.optionalString (attrs ? key-threshold) "key-threshold: ${attrs.key-threshold}"}
176176
EOF
177177
178-
export SSL_CERT_FILE=${pkgs.evalPackages.cacert}/etc/ssl/certs/ca-bundle.crt
178+
export SSL_CERT_FILE=${evalPackages.cacert}/etc/ssl/certs/ca-bundle.crt
179179
cabal v2-update ${name}
180180
cp -r $HOME/.cabal/packages/${name} $out
181181
'';
182182
# Output of hackage-to-nix
183183
hackage = import (
184-
pkgs.evalPackages.runCommand ("hackage-to-nix-" + name) {
185-
nativeBuildInputs = [ cabal-install pkgs.evalPackages.curl nix-tools ];
186-
LOCALE_ARCHIVE = pkgs.lib.optionalString (pkgs.evalPackages.stdenv.buildPlatform.libc == "glibc") "${pkgs.evalPackages.glibcLocales}/lib/locale/locale-archive";
184+
evalPackages.runCommand ("hackage-to-nix-" + name) {
185+
nativeBuildInputs = [ cabal-install evalPackages.curl nix-tools ];
186+
LOCALE_ARCHIVE = pkgs.lib.optionalString (evalPackages.stdenv.buildPlatform.libc == "glibc") "${evalPackages.glibcLocales}/lib/locale/locale-archive";
187187
LANG = "en_US.UTF-8";
188188
preferLocalBuild = true;
189189
} ''
@@ -196,11 +196,11 @@ let
196196
};
197197
};
198198

199-
parseRepositories = cabalProjectFileName: sha256map: inputMap: cabal-install: nix-tools: projectFile:
199+
parseRepositories = evalPackages: cabalProjectFileName: sha256map: inputMap: cabal-install: nix-tools: projectFile:
200200
let
201201
# This will leave the name of repository in the first line of each block
202202
blocks = pkgs.lib.splitString "\nrepository " ("\n" + projectFile);
203-
repoBlocks = builtins.map (parseRepositoryBlock cabalProjectFileName sha256map inputMap cabal-install nix-tools) (pkgs.lib.lists.drop 1 blocks);
203+
repoBlocks = builtins.map (parseRepositoryBlock evalPackages cabalProjectFileName sha256map inputMap cabal-install nix-tools) (pkgs.lib.lists.drop 1 blocks);
204204
in {
205205
extra-hackages = pkgs.lib.lists.map (block: block.hackage) repoBlocks;
206206
repos = pkgs.lib.lists.foldl' (x: block: x // block.repo) {} repoBlocks;

0 commit comments

Comments
 (0)