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).
66 lines
1.8 KiB
Nix
66 lines
1.8 KiB
Nix
# Test a package set
|
|
{ stdenv, lib, util, cabalProject', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name, evalPackages }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
modules = [
|
|
{
|
|
# Package has no exposed modules which causes
|
|
# haddock: No input file(s)
|
|
packages.cabal-sublib.doHaddock = false;
|
|
}
|
|
];
|
|
|
|
# The ./pkgs.nix works for linux & darwin, but not for windows
|
|
project = cabalProject' {
|
|
inherit compiler-nix-name evalPackages;
|
|
src = testSrc "cabal-sublib";
|
|
inherit modules;
|
|
cabalProject = ''
|
|
packages: .
|
|
allow-newer: aeson:*
|
|
'';
|
|
};
|
|
|
|
packages = project.hsPkgs;
|
|
|
|
in recurseIntoAttrs {
|
|
ifdInputs = {
|
|
inherit (project) plan-nix;
|
|
};
|
|
run = stdenv.mkDerivation {
|
|
name = "cabal-sublib-test";
|
|
|
|
buildCommand = ''
|
|
exe="${packages.cabal-sublib.components.exes.cabal-sublib.exePath}"
|
|
|
|
size=$(command stat --format '%s' "$exe")
|
|
printf "size of executable $exe is $size. \n" >& 2
|
|
|
|
# fixme: run on target platform when cross-compiled
|
|
printf "checking whether executable runs... " >& 2
|
|
cat ${haskellLib.check packages.cabal-sublib.components.exes.cabal-sublib}/test-stdout
|
|
|
|
'' +
|
|
# Musl and Aarch are statically linked..
|
|
optionalString (!stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64 && !stdenv.hostPlatform.isMusl) (''
|
|
printf "checking that executable is dynamically linked to system libraries... " >& 2
|
|
'' + optionalString (stdenv.isLinux && !stdenv.hostPlatform.isMusl) ''
|
|
ldd $exe | grep libgmp
|
|
'' + optionalString stdenv.isDarwin ''
|
|
otool -L $exe |grep .dylib
|
|
'') + ''
|
|
|
|
touch $out
|
|
'';
|
|
|
|
meta.platforms = platforms.all;
|
|
|
|
passthru = {
|
|
# Used for debugging with nix repl
|
|
inherit packages project;
|
|
};
|
|
};
|
|
}
|