Commit e6d45588 authored by Silvan Mosberger's avatar Silvan Mosberger Committed by Silvan Mosberger
Browse files

tests.haskell.cabalSdist: Prevent rebuilds when Nix files change

The generated file sets its own directory as the source, including the
generated file itself, which causes rebuilds when that file is
reformatted. We can avoid this by overriding the source with a filtered
version and using that throughout the tests.

See https://github.com/NixOS/nixpkgs/pull/320572 for more context
parent 7cb66fd5
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
{ lib, haskellPackages, runCommand }:
{ lib, haskell, haskellPackages, runCommand }:

let
  localRaw = haskellPackages.callPackage ./local/generated.nix {};
  src = lib.fileset.toSource {
    root = ./local;
    fileset = lib.fileset.unions [
      ./local/app
      ./local/CHANGELOG.md
      ./local/local.cabal
    ];
  };
  # This prevents the source from depending on the formatting of the ./local/generated.nix file
  localRaw = haskell.lib.compose.overrideSrc {
    inherit src;
  } (haskellPackages.callPackage ./local/generated.nix {});
in
lib.recurseIntoAttrs rec {

@@ -20,14 +31,14 @@ lib.recurseIntoAttrs rec {
  assumptionLocalHasDirectReference = runCommand "localHasDirectReference" {
    drvPath = builtins.unsafeDiscardOutputDependency localRaw.drvPath;
  } ''
    grep ${./local} $drvPath >/dev/null
    grep ${src} $drvPath >/dev/null
    touch $out
  '';

  localHasNoDirectReference = runCommand "localHasNoDirectReference" {
    drvPath = builtins.unsafeDiscardOutputDependency localFromCabalSdist.drvPath;
  } ''
    grep -v ${./local} $drvPath >/dev/null
    grep -v ${src} $drvPath >/dev/null
    touch $out
  '';
}