mirror of
https://github.com/ilyakooo0/haskell.nix.git
synced 2024-09-11 06:55:40 +03:00
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).
60 lines
1.6 KiB
Nix
60 lines
1.6 KiB
Nix
# Test if derivations are content addressed building two derivations producing
|
|
# the same outputs and checking if the path stores are equals
|
|
{ stdenv, pkgs, lib, mkCabalProjectPkgSet, project', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name, evalPackages, CADerivationsEnabled }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cabalProject = ''
|
|
packages: .
|
|
allow-newer: aeson:*
|
|
'';
|
|
|
|
srcPlain = testSrc "cabal-simple";
|
|
|
|
# we alter the source adding an Haskell comment since they are ignored by ghc
|
|
srcWithComment = pkgs.runCommand "src-with-comment" { } ''
|
|
mkdir $out
|
|
install ${srcPlain}/* $out
|
|
echo " -- Altering source without altering executable..." >> $out/Main.hs
|
|
'';
|
|
|
|
projectPlain = project' {
|
|
inherit compiler-nix-name evalPackages cabalProject;
|
|
src = srcPlain;
|
|
modules = [{ contentAddressed = true; }];
|
|
};
|
|
|
|
projectWithComment = project' {
|
|
inherit compiler-nix-name evalPackages cabalProject;
|
|
src = srcWithComment;
|
|
modules = [{ contentAddressed = true; }];
|
|
};
|
|
|
|
exe-plain = projectPlain.hsPkgs.cabal-simple.components.exes.cabal-simple.exePath;
|
|
exe-withComment = projectWithComment.hsPkgs.cabal-simple.components.exes.cabal-simple.exePath;
|
|
|
|
in
|
|
recurseIntoAttrs {
|
|
|
|
meta.disabled = !CADerivationsEnabled;
|
|
|
|
run = stdenv.mkDerivation {
|
|
name = "ca-derivations-test";
|
|
|
|
buildCommand = ''
|
|
[ "${exe-plain}" != "${exe-withComment}" ] && exit 1
|
|
touch $out
|
|
'';
|
|
|
|
meta.platforms = platforms.all;
|
|
|
|
passthru = {
|
|
# Used for debugging with nix repl
|
|
inherit projectWithComment projectPlain;
|
|
};
|
|
};
|
|
|
|
}
|