!RbXGJhHMsnQcNIDFWN:nixos.org

Haskell in Nixpkgs/NixOS

719 Members
For discussions and questions about Haskell with Nix, cabal2nix and haskellPackages in nixpkgs | Current Docs: https://haskell4nix.readthedocs.io/143 Servers

Load older messages


SenderMessageTime
30 Nov 2024
@vcunat:matrix.orgvcunat Unless the script excludes haskellPackages by some mistake. 17:56:19
@vcunat:matrix.orgvcunat No, I reran with --print and it looks OK. 18:28:01
@sternenseemann:systemli.orgsterni (he/him)Yeah, there are just some rebuilds in variants of the haskell package set, but I think those jobs are only built by haskell-updates18:42:45
@prsteele:matrix.orgPatrick Steele

In my dev shell, I can run

cabal build test:tests

to compile an executable that runs my tests. Is there an easy way to get a Nix derivation to build this, without manually wrapping cabal-the-command-line-program?

(I know tests are run when I compile the associated program with Nix; I'm interested in compiling the test executable to run in CI, and I don't want to depend on cabal-install because it likes to look at Hackage)

20:05:20
@prsteele:matrix.orgPatrick Steele
In reply to @sternenseemann:systemli.org
Patrick Steele: overrides defaults to haskell.packageOverrides by default, so changing that attribute applies something globally. Any changes to either of course need to be written in a way that preserve previous overrides via lib.composeExtensions if you care about that.
Thank you.
20:07:02
@prsteele:matrix.orgPatrick Steele pkgs.haskell.lib.setBuildTarget seems to come really close to what I want 20:16:36
@sternenseemann:systemli.orgsterni (he/him) you can fiddle around it probably. The problem is iirc that Cabal refuses to install executables that are test-suites, so you have to write a custom installPhase 20:18:51
@sternenseemann:systemli.orgsterni (he/him)consequently there's not really proper support for this thing at the moment20:19:10
@prsteele:matrix.orgPatrick Steele thanks for confirming my growing suspicion; what gets tossed in result/ when I build haskell.lib.setBuildTarget whatever "test:tests" looks like only the library build, not anything I can run 20:20:15
@alexfmpe:matrix.orgalexfmpeYou can make cabal not look at hackage FWIW 20:22:13
@alexfmpe:matrix.orgalexfmpehttps://cabal.readthedocs.io/en/3.4/cabal-project.html#cfg-field-active-repositories20:22:48
@prsteele:matrix.orgPatrick Steele ya, my current workaround for the hackage issue is --config-file /dev/null, but if you have a better solution --- reading, thanks 20:23:00
@alexfmpe:matrix.orgalexfmpe(still need to give its a pkg db via nix)20:23:04
@prsteele:matrix.orgPatrick Steele actually I have --config-file /dev/null --active-repositories=:none and I haven't tested removing the second flag 20:23:43
@alexfmpe:matrix.orgalexfmpeHmm I dunno if you can pass this via CLI20:24:47
@prsteele:matrix.orgPatrick SteeleI mean, this is working for me, somehow. (And was failing without it.) Annoyingly I can't replicate what Github Actions are doing locally, so I can't even reproduce this locally20:25:28
@prsteele:matrix.orgPatrick Steele
            test =
              let
                shell = self.devShells.${system}.default;
              in
              pkgs.writeShellApplication {
                name = "test";
                runtimeInputs = [ pkgs.cabal-install ] ++ shell.nativeBuildInputs;
                text = ''
                  cabal --config-file /dev/null --active-repositories=:none test --test-show-details=always "$@"
                '';
              };

is how I'm coercing tests to run in CI

20:26:04
@alexfmpe:matrix.orgalexfmpeHuh why do you want to build with nix but not run with nix?20:28:16
@prsteele:matrix.orgPatrick SteeleI do want to run with Nix, I'm not claiming this is idiomatic. My initial question is me trying to figure out how to get Nix to just run the tests directly20:28:46
@alexfmpe:matrix.orgalexfmpewhy not "nix-shell --run 'cabal test all'20:28:46
@alexfmpe:matrix.orgalexfmpe* why not "nix-shell --run 'cabal test all'"20:28:56
@alexfmpe:matrix.orgalexfmpe* why not "nix-shell --run 'cabal test all'"20:29:05
@prsteele:matrix.orgPatrick SteeleWould that have different behavior? In my mind those are awfully close20:29:21
@alexfmpe:matrix.orgalexfmpeThis is what I do if I want to CI the dev shell itself20:29:44
@prsteele:matrix.orgPatrick SteeleI'll give it a try20:30:05
@alexfmpe:matrix.orgalexfmpeOtherwise I just let the nix derivation do everything20:30:15
@alexfmpe:matrix.orgalexfmpeYou seem to be using flakes though. I think that's 'nix develop' or something rather than nix-shell20:31:09
@alexfmpe:matrix.orgalexfmpe
In reply to @prsteele:matrix.org
Would that have different behavior? In my mind those are awfully close
This would build your project (not the deps) outside of nix
20:32:23
@prsteele:matrix.orgPatrick SteeleI see20:42:38
@prsteele:matrix.orgPatrick Steelethank you20:42:46

Show newer messages


Back to Room ListRoom Version: 6