haskell.nix icon indicating copy to clipboard operation
haskell.nix copied to clipboard

How can you disable tests with stackProject?

Open codygman opened this issue 5 years ago • 5 comments

I think it'll be something like this maybe?

let
  sources = import ./nix/sources.nix;
  haskellNix = import sources."haskell.nix" {};
  nixpkgsSrc = haskellNix.sources.nixpkgs-2003;
  nixpkgsArgs = haskellNix.nixpkgsArgs;
  pkgs = import nixpkgsSrc nixpkgsArgs ;
  project = pkgs.haskell-nix.stackProject {
    src = pkgs.nix-gitignore.gitignoreSource [] ./.;
    compiler-nix-name = "ghc883";
    haskellNix = haskellNix;
  };
in project.overrideAttrs (old: {
    # override something from the list at https://input-output-hk.github.io/haskell.nix/reference/library/#stackproject
})

codygman avatar Jul 24 '20 19:07 codygman

I presume that we want to avoid even building the test (since the tests are not run unless we explicitly ask for them to be run).

Try:

  modules = [{ packages.packagename.components.tests.testname.buildable = false; }];

or add a flagname flag to the packagename.cabal file with a if flag( flagname) buildable: False in the test:

   modules = [ { packages.packagename.flags.flagname = true; } ];

I don't think overrideAttrs will work on project you might need to pass it explicitly.

hamishmack avatar Jul 24 '20 23:07 hamishmack

Thanks @hamishmack! They key piece preventing me from figuring this out was understanding I could override modules like that in the modules argument of stackProject.

For others who might need to know this, the solution (I think, it's still building) was basically:

let
  sources = import ./nix/sources.nix;
  haskellNix = import sources."haskell.nix" {};
  nixpkgsSrc = haskellNix.sources.nixpkgs-2003;
  nixpkgsArgs = haskellNix.nixpkgsArgs;

in
{ pkgs ? import nixpkgsSrc nixpkgsArgs }:
pkgs.haskell-nix.stackProject {
  src = pkgs.nix-gitignore.gitignoreSource [] ./.;
  compiler-nix-name = "ghc883";
  modules = [{ packages.myproj.components.tests.test.buildable = false; }];
}

codygman avatar Jul 25 '20 00:07 codygman

Hm, it seems I ran into another issue with the above code:

error: The option `packages.myproj.components.tests.test.buildable' has conflicting definitions, in `/nix/store/kifzr1a2pl3rygqnavfzlp1rpn454lx1-haskell.nix-src/modules/plan.nix' and `<unknown-file>'.

Here's a github actions job testing the change given how I implemented it:

https://github.com/codygman/haskell-nix-stack-workflow/runs/908772081?check_suite_focus=true

This one works, but in another project I have that same method gives the error above. I'll have to figure out the differences between the two later.

codygman avatar Jul 25 '20 00:07 codygman

Try:

modules = [{ packages.myproj.components.tests.test.buildable = pkgs.lib.mkForce false; }];

hamishmack avatar Jul 25 '20 02:07 hamishmack

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 28 '22 21:09 stale[bot]