Skip to content

Remove flake utils #2027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0db76f7
Remove flake-utils
andreabedini Aug 24, 2023
4281da6
Merge branch 'master' into remove-flake-utils
hamishmack Aug 28, 2023
91181f2
WIP
andreabedini Aug 24, 2023
faccb70
Try to depend on pkgs rather than system
andreabedini Aug 24, 2023
c1cd8fc
Use builtins
andreabedini Aug 25, 2023
b35fafb
Try putting back internal as it was
andreabedini Aug 25, 2023
6a7a253
Remove/update some comments
andreabedini Sep 1, 2023
e599703
Better name for forEachSystem'
andreabedini Sep 1, 2023
d909221
Minor changes
andreabedini Sep 1, 2023
aaf3cb8
Remove extra nixpkgs in default.nix
andreabedini Sep 1, 2023
25bf2e2
Use flake-compat override-inputs to implement sourcesOverride
andreabedini Sep 1, 2023
48b828d
Deprecate using overlaysOverrideable
andreabedini Sep 1, 2023
5ee6346
Move internal.compat to default.nix
andreabedini Sep 1, 2023
4707c53
Adapt ci.nix
andreabedini Sep 1, 2023
de48118
ghc945 -> ghc947
andreabedini Sep 1, 2023
43ceb39
Merge remote-tracking branch 'upstream/master' into remove-flake-utils
andreabedini Sep 1, 2023
b09a7e4
Minor changes
andreabedini Sep 1, 2023
734b11b
Slightly more readable
andreabedini Sep 1, 2023
82b2c14
Fix
andreabedini Sep 1, 2023
a5ff33b
Bump haskell.nix in nix-tools flake.
andreabedini Sep 4, 2023
73c2de4
Merge remote-tracking branch 'upstream/master' into remove-flake-utils
andreabedini Sep 4, 2023
26c386d
Pre-fetch nixpkgs before calling flake-compat
andreabedini Sep 4, 2023
389bb93
Fix evalSystem in ci.nix
andreabedini Sep 4, 2023
379945a
Avoid issues with restricted evaluation
andreabedini Sep 4, 2023
083dc59
Trivial change
andreabedini Sep 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions ci-lib.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
# Generic nixpkgs, use *only* for lib functions that are stable across versions
pkgs,
lib ? pkgs.lib
}: rec {
{ lib }:
rec {
inherit (import ./dimension.nix) dimension;

# A filter for removing packages that aren't supported on the current platform
Expand Down
73 changes: 46 additions & 27 deletions ci.nix
Original file line number Diff line number Diff line change
@@ -1,29 +1,49 @@
# 'supportedSystems' restricts the set of systems that we will evaluate for. Useful when you're evaluating
# on a machine with e.g. no way to build the Darwin IFDs you need!
{ ifdLevel ? 3
# Whether or not we are evaluating in restricted mode. This is true in Hydra, but not in Hercules.
, restrictEval ? false
, checkMaterialization ? false
, compat
, system
, system ? builtins.currentSystem
, evalSystem ? builtins.currentSystem or "x86_64-linux"
, pkgs ? (compat { inherit system; }).pkgs }:
# NOTE: we apply checkMaterialization when defining nixpkgsArgs
, haskellNix ? import ./default.nix { inherit system ; }
}:
let
inherit (import ./ci-lib.nix { inherit pkgs; }) dimension platformFilterGeneric filterAttrsOnlyRecursive;
inherit (pkgs.haskell-nix) sources;
inherit (haskellNix) inputs;
inherit (inputs.nixpkgs) lib;
inherit
(import ./ci-lib.nix { inherit lib; })
dimension
platformFilterGeneric
filterAttrsOnlyRecursive;

# short names for nixpkgs versions
nixpkgsVersions = {
"R2205" = "nixpkgs-2205";
"R2211" = "nixpkgs-2211";
"R2305" = "nixpkgs-2305";
"unstable" = "nixpkgs-unstable";
"R2205" = inputs.nixpkgs-2205;
"R2211" = inputs.nixpkgs-2211;
"R2305" = inputs.nixpkgs-2305;
"unstable" = inputs.nixpkgs-unstable;
};
haskellNix = compat { inherit checkMaterialization system; };
nixpkgsArgs = haskellNix.nixpkgsArgs // {

nixpkgsArgs = {
# set checkMaterialization as per top-level argument
overlays = [
haskellNix.overlay
(final: prev: {
haskell-nix = prev.haskell-nix // {
inherit checkMaterialization;
};
})
];
# Needed for dwarf tests
config = haskellNix.nixpkgsArgs.config // {
permittedInsecurePackages = ["libdwarf-20210528" "libdwarf-20181024" "dwarfdump-20181024"];
config = haskellNix.config // {
permittedInsecurePackages = [
"libdwarf-20210528"
"libdwarf-20181024"
"dwarfdump-20181024"
];
};
};

compilerNixNames = nixpkgsName: nixpkgs:
# Include only the GHC versions that are supported by haskell.nix
nixpkgs.lib.filterAttrs (compiler-nix-name: _:
Expand Down Expand Up @@ -73,31 +93,30 @@
# of 'lib.systems.examples' are not understood between all versions
let lib = nixpkgs.lib;
in lib.optionalAttrs (nixpkgsName == "unstable"
&& ((system == "x86_64-linux" && __elem compiler-nix-name ["ghc8107" "ghc962" "ghc9820230704"])
|| (system == "aarch64-linux" && __elem compiler-nix-name ["ghc8107" "ghc962" "ghc9820230704"])
|| (system == "x86_64-darwin" && __elem compiler-nix-name ["ghc8107" "ghc962" "ghc9820230704"])
|| (system == "aarch64-darwin" && __elem compiler-nix-name ["ghc8107" "ghc962" "ghc9820230704"])
&& ((system == "x86_64-linux" && builtins.elem compiler-nix-name ["ghc8107" "ghc962" "ghc9820230704"])
|| (system == "aarch64-linux" && builtins.elem compiler-nix-name ["ghc8107" "ghc962" "ghc9820230704"])
|| (system == "x86_64-darwin" && builtins.elem compiler-nix-name ["ghc8107" "ghc962" "ghc9820230704"])
|| (system == "aarch64-darwin" && builtins.elem compiler-nix-name ["ghc8107" "ghc962" "ghc9820230704"])
)) {
inherit (lib.systems.examples) ghcjs;
} // lib.optionalAttrs (nixpkgsName == "unstable"
&& ((system == "x86_64-linux" && __elem compiler-nix-name ["ghc8107" "ghc902" "ghc926" "ghc927" "ghc928" "ghc947" "ghc962" "ghc9820230704"])
|| (system == "x86_64-darwin" && __elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
&& ((system == "x86_64-linux" && builtins.elem compiler-nix-name ["ghc8107" "ghc902" "ghc926" "ghc927" "ghc928" "ghc947" "ghc962" "ghc9820230704"])
|| (system == "x86_64-darwin" && builtins.elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
inherit (lib.systems.examples) mingwW64;
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && __elem compiler-nix-name ["ghc8107" "ghc902" "ghc922" "ghc923" "ghc924" "ghc926" "ghc927" "ghc928" "ghc947" "ghc962" "ghc9820230704"]) {
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && builtins.elem compiler-nix-name ["ghc8107" "ghc902" "ghc922" "ghc923" "ghc924" "ghc926" "ghc927" "ghc928" "ghc947" "ghc962" "ghc9820230704"]) {
# Musl cross only works on linux
# aarch64 cross only works on linux
inherit (lib.systems.examples) musl64 aarch64-multiplatform;
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && __elem compiler-nix-name ["ghc927" "ghc928"]) {
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && builtins.elem compiler-nix-name ["ghc927" "ghc928"]) {
# TODO fix this for the compilers we build with hadrian (ghc >=9.4)
inherit (lib.systems.examples) aarch64-multiplatform-musl;
} // lib.optionalAttrs (system == "aarch64-linux" && nixpkgsName == "unstable" && __elem compiler-nix-name ["ghc927" "ghc928" "ghc947" "ghc962" "ghc9820230704"]) {
} // lib.optionalAttrs (system == "aarch64-linux" && nixpkgsName == "unstable" && builtins.elem compiler-nix-name ["ghc927" "ghc928" "ghc947" "ghc962" "ghc9820230704"]) {
inherit (lib.systems.examples) aarch64-multiplatform-musl;
};
isDisabled = d: d.meta.disabled or false;
in
dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: nixpkgs-pin:
let pinnedNixpkgsSrc = sources.${nixpkgs-pin};
evalPackages = import pinnedNixpkgsSrc (nixpkgsArgs // { system = evalSystem; });
dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: pinnedNixpkgsSrc:
let evalPackages = import pinnedNixpkgsSrc (nixpkgsArgs // { system = evalSystem; });
in dimension "GHC version" (compilerNixNames nixpkgsName evalPackages) (compiler-nix-name: {runTests}:
let pkgs = import pinnedNixpkgsSrc (nixpkgsArgs // { inherit system; });
build = import ./build.nix { inherit pkgs evalPackages ifdLevel compiler-nix-name haskellNix; };
Expand Down
95 changes: 79 additions & 16 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,21 +1,42 @@
{...}@args:
{ system ? builtins.currentSystem
, sourcesOverride ? { }
, checkMaterialization ? false
, ...
}:

let
pins = (__fromJSON (__readFile ./flake.lock)).nodes;
nixpkgsPin = pins.nixpkgs-2211.locked;
flakeCompatPin = pins.flake-compat.locked;
nixpkgsSrc =
lock = builtins.fromJSON (builtins.readFile ./flake.lock);

# NOTE: This has to be whitelisted in restricted evaluation mode
flake-compat =
with lock.nodes.flake-compat.locked;
builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${nixpkgsPin.rev}.tar.gz";
sha256 = nixpkgsPin.narHash;
url = "https://github.com/input-output-hk/flake-compat/archive/${rev}.tar.gz";
sha256 = narHash;
};
pkgs = args.pkgs or (import nixpkgsSrc {});
flake-compat =
pkgs.fetchzip {
url = "https://github.com/input-output-hk/flake-compat/archive/${flakeCompatPin.rev}.tar.gz";
sha256 = flakeCompatPin.narHash;

# With flake-compat you will end up fetching the flake inputs with
# builtins.fetchTarball. This is simply because you don't have access to any
# nixpkgs before fetching the inputs.
#
# This won't work in restricted evaluation mode.
#
# Under the mild assumtion that https://github.com/NixOS is whitelisted, we
# can manually fetch nixpkgs and let flake-compat fetch the rest of the
# inputs with the nixpkgs just fetched.
#
# Manually fetch nixpkgs
nixpkgs =
with lock.nodes.nixpkgs.locked;
builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
sha256 = narHash;
};
self = import flake-compat {
#
# Instantiate the flake fetching the other inputs with the nixpkgs already
# fetched
self = (import flake-compat {
pkgs = import nixpkgs { };
# We bypass flake-compat's rootSrc cleaning by evading its detection of this as a git
# repo.
# This is done for 3 reasons:
Expand All @@ -26,7 +47,49 @@ let
# in `test/default.nix`). If `flake-compat` copies the whole git repo, any change to the
# repo causes a change of input for all tests.
src = { outPath = ./.; };
inherit pkgs;
override-inputs = sourcesOverride;
}).defaultNix;

inherit (self.inputs.nixpkgs) lib;

# coming from internal.compat
overlays = [ self.overlay ]
++ lib.optional checkMaterialization
(final: prev: {
haskell-nix = prev.haskell-nix // {
checkMaterialization = true;
};
});
nixpkgsArgs = {
inherit overlays;
inherit (self) config;
};
in self.defaultNix // (self.defaultNix.internal.compat
({ system = args.pkgs.system or builtins.currentSystem; } // args))
pkgs = import self.inputs.nixpkgs (nixpkgsArgs // {
localSystem = { inherit system; };
});
in
self // {
inherit nixpkgsArgs pkgs;
inherit (nixpkgsArgs) config overlays;
sources = self.inputs;
allOverlays = self.overlays;
pkgs-2105 = import self.inputs.nixpkgs-2105 (nixpkgsArgs // {
localSystem = { inherit system; };
});
pkgs-2111 = import self.inputs.nixpkgs-2111 (nixpkgsArgs // {
localSystem = { inherit system; };
});
pkgs-2205 = import self.inputs.nixpkgs-2205 (nixpkgsArgs // {
localSystem = { inherit system; };
});
pkgs-2211 = import self.inputs.nixpkgs-2211 (nixpkgsArgs // {
localSystem = { inherit system; };
});
pkgs-2305 = import self.inputs.nixpkgs-2305 (nixpkgsArgs // {
localSystem = { inherit system; };
});
pkgs-unstable = import self.inputs.nixpkgs-unstable (nixpkgsArgs // {
localSystem = { inherit system; };
});
hix = import ./hix/default.nix { inherit pkgs; };
}
19 changes: 0 additions & 19 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading