mirror of
https://github.com/simplex-chat/haskell.nix.git
synced 2026-06-03 09:17:32 +00:00
a443611ecf
This adds a way to specify the `evalSystem` or `evalPackages` explicitly when calling the `project` functions. Currently if we want to make a `flake` that supports multiple systems we have few options: * Require builders for all the supported systems (even just for `nix flake show`). * Pass `--impure` so that haskell.nix can see `builtins.currentSystem` to set up `pkgs.evalPackages` to use that. Unfortunately this prevents nix from caching some of the work it does and often results in it recalculating for each supported system when it would otherwise be cached and take no time at all. * Add an overlay to replace `evalPackages`. This works, but it is not straight forward. * Materialize the nix files for the project. This change allows `evalSystem = "x86_64-linux";` to be passed telling `haskell.nix` to run `cabal` and `nix-tools` on that system. The user will have to have a builder for that system, but does not need to have builders for the others (unless building outputs for them).
46 lines
1.4 KiB
Nix
46 lines
1.4 KiB
Nix
{ stdenv, lib, stackProject', recurseIntoAttrs, haskellLib, testSrc, compiler-nix-name, evalPackages }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
project = stackProject' {
|
|
inherit evalPackages;
|
|
src = testSrc "ghc-options";
|
|
};
|
|
packages = project.hsPkgs;
|
|
|
|
# Get the names of all packages. This is a test to see
|
|
# whether there is a broken "$locals" package present.
|
|
hasIdentifier = p: p != null && p ? identifier;
|
|
packageNames = mapAttrsToList (name: p:
|
|
# TODO work out why these are `ghcide` and `hnix` are here in the first place
|
|
# it might be because we have patches in `modules/configuration.nix`
|
|
lib.optionalString (!__elem name ["ghcide" "hnix"]) p.identifier.name)
|
|
(filterAttrs (name: hasIdentifier) packages);
|
|
|
|
in recurseIntoAttrs {
|
|
# This test is somehow broken for ghcjs
|
|
meta.disabled = stdenv.hostPlatform.isGhcjs || compiler-nix-name != "ghc865";
|
|
|
|
ifdInputs = {
|
|
inherit (project) stack-nix;
|
|
};
|
|
run = stdenv.mkDerivation {
|
|
name = "callStackToNix-test";
|
|
|
|
buildCommand = ''
|
|
printf "checking whether executable runs... " >& 2
|
|
cat ${haskellLib.check packages.test-ghc-options.components.exes.test-ghc-options-exe}/test-stdout
|
|
|
|
echo '${concatStringsSep " " packageNames}' > $out
|
|
'';
|
|
|
|
meta.platforms = platforms.all;
|
|
|
|
passthru = {
|
|
# Attributes used for debugging with nix repl
|
|
inherit project packages;
|
|
};
|
|
};
|
|
}
|