Skip to content

Add a projectArgs CLI argument to hix run #2378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 28, 2025

Conversation

demaledetti
Copy link
Contributor

hix run could be even more useful if it allowed tweaking the build on the fly by passing custom arguments to callCabalProjectToNix.

For example latest hlint wants latest ghc:

$ nix run github:input-output-hk/haskell.nix#hix -- run github:ndmitchell/hlint#hlint:exe:hlint -- --version 2>&1 | tail -n 20

       error: builder for '/nix/store/kaywxgj98har99969q8hjrzgnj6b7997-haskell-project-plan-to-nix-pkgs.drv' failed with exit code 1;
       last 15 log lines:
       > Configuration is affected by the following files:
       > - cabal.project
       > Warning: The package list for 'hackage.haskell.org' is 20235 days old.
       > Run 'cabal update' to get the latest list of available packages.
       > Resolving dependencies...
       > Error: [Cabal-7107]
       > Could not resolve dependencies:
       > [__0] trying: hlint-3.10 (user goal)
       > [__1] trying: ghc-lib-parser-9.12.2.20250421 (dependency of hlint +/-ghc-lib)
       > [__2] next goal: base (dependency of hlint)
       > [__2] rejecting: base-4.18.3.0/installed-4.18.3.0 (conflict: ghc-lib-parser => base>=4.19 && <4.22)
       > [__2] rejecting: base; 4.21.0.0, 4.20.1.0, 4.20.0.1, 4.20.0.0, 4.19.2.0, 4.19.1.0, 4.19.0.0, 4.18.3.0, 4.18.2.1, 4.18.2.0, 4.18.1.0, 4.18.0.0, 4.17.2.1, 4.17.2.0, 4.17.1.0, 4.17.0.0, 4.16.4.0, 4.16.3.0, 4.16.2.0, 4.16.1.0, 4.16.0.0, 4.15.1.0, 4.15.0.0, 4.14.3.0, 4.14.2.0, 4.14.1.0, 4.14.0.0, 4.13.0.0, 4.12.0.0, 4.11.1.0, 4.11.0.0, 4.10.1.0, 4.10.0.0, 4.9.1.0, 4.9.0.0, 4.8.2.0, 4.8.1.0, 4.8.0.0, 4.7.0.2, 4.7.0.1, 4.7.0.0, 4.6.0.1, 4.6.0.0, 4.5.1.0, 4.5.0.0, 4.4.1.0, 4.4.0.0, 4.3.1.0, 4.3.0.0, 4.2.0.2, 4.2.0.1, 4.2.0.0, 4.1.0.0, 4.0.0.0, 3.0.3.2, 3.0.3.1 (constraint from non-reinstallable package requires installed instance)
       > [__2] fail (backjumping, conflict set: base, ghc-lib-parser, hlint)
       > After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hlint, ghc-lib-parser, base
       >
       For full logs, run:
         nix log /nix/store/kaywxgj98har99969q8hjrzgnj6b7997-haskell-project-plan-to-nix-pkgs.drv

Works great if we pass compiler-nix-name:

$ nix run github:demaledetti/haskell.nix/hix-run-projectArgs#hix -- run github:ndmitchell/hlint#hlint:exe:hlint --projectArgs '{compiler-nix-name="ghc9122";}' -- --version 2> /dev/null
HLint v3.10, (C) Neil Mitchell 2006-2025

Another example of a useful tool failing to build with the defaults:

$ nix run github:input-output-hk/haskell.nix#hix -- run github:karknu/rws#rws:exe:rws 2>&1 | tail -n 22
       error: builder for '/nix/store/ykxwaw346zbmbdanviqbmiwjcffh13dn-haskell-project-plan-to-nix-pkgs.drv' failed with exit code 1;
       last 18 log lines:
       > Configuration is affected by the following files:
       > - cabal.project
       > Warning: The package list for 'hackage.haskell.org' is 20235 days old.
       > Run 'cabal update' to get the latest list of available packages.
       > Resolving dependencies...
       > Error: [Cabal-7107]
       > Could not resolve dependencies:
       > [__0] trying: rws-0.1.1.2 (user goal)
       > [__1] next goal: binary (dependency of rws)
       > [__1] rejecting: binary-0.8.9.1/installed-0.8.9.1 (conflict: rws => binary>=0.5 && <0.6)
       > [__1] skipping: binary; 0.8.9.3, 0.8.9.2, 0.8.9.1, 0.8.9.0, 0.8.8.0, 0.8.7.0, 0.8.6.0, 0.8.5.1, 0.8.5.0, 0.8.4.1, 0.8.4.0, 0.8.3.0, 0.8.2.1, 0.8.2.0, 0.8.1.0, 0.8.0.1, 0.8.0.0, 0.7.6.1, 0.7.6.0, 0.7.5.0, 0.7.4.0, 0.7.3.0, 0.7.2.3, 0.7.2.2, 0.7.2.1, 0.7.2.0, 0.7.1.0, 0.7.0.1, 0.7.0.0, 0.6.4.0, 0.6.3.0, 0.6.2.0, 0.6.1.0, 0.6.0.0 (has the same characteristics that caused the previous version to fail: excluded by constraint '>=0.5 && <0.6' from 'rws')
       > [__1] trying: binary-0.5.1.1
       > [__2] next goal: base (dependency of rws)
       > [__2] rejecting: base-4.18.3.0/installed-4.18.3.0 (conflict: binary +/-applicative-in-base +/-bytestring-in-base +/-split-base => base<2.2 || >=3 && <4.7)
       > [__2] rejecting: base; 4.21.0.0, 4.20.1.0, 4.20.0.1, 4.20.0.0, 4.19.2.0, 4.19.1.0, 4.19.0.0, 4.18.3.0, 4.18.2.1, 4.18.2.0, 4.18.1.0, 4.18.0.0, 4.17.2.1, 4.17.2.0, 4.17.1.0, 4.17.0.0, 4.16.4.0, 4.16.3.0, 4.16.2.0, 4.16.1.0, 4.16.0.0, 4.15.1.0, 4.15.0.0, 4.14.3.0, 4.14.2.0, 4.14.1.0, 4.14.0.0, 4.13.0.0, 4.12.0.0, 4.11.1.0, 4.11.0.0, 4.10.1.0, 4.10.0.0, 4.9.1.0, 4.9.0.0, 4.8.2.0, 4.8.1.0, 4.8.0.0, 4.7.0.2, 4.7.0.1, 4.7.0.0, 4.6.0.1, 4.6.0.0, 4.5.1.0, 4.5.0.0, 4.4.1.0, 4.4.0.0, 4.3.1.0, 4.3.0.0, 4.2.0.2, 4.2.0.1, 4.2.0.0, 4.1.0.0, 4.0.0.0, 3.0.3.2, 3.0.3.1 (constraint from non-reinstallable package requires installed instance)
       > [__2] fail (backjumping, conflict set: base, binary, rws)
       > After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: base, binary, rws
       >
       For full logs, run:
         nix log /nix/store/ykxwaw346zbmbdanviqbmiwjcffh13dn-haskell-project-plan-to-nix-pkgs.drv

configureArgs to the rescue to disable-tests and allow-newer:

$ nix run github:demaledetti/haskell.nix/hix-run-projectArgs#hix -- run github:karknu/rws#rws:exe:rws --projectArgs '{configureArgs = "--allow-newer=binary --disable-tests";}'  -- -i <(curl -s https://raw.githubusercontent.com/karknu/rws/refs/heads/master/samples/udp.pkt) -o /dev/stdout 2> /dev/null | nix run nixpkgs#tcpdump -- -enr -
reading from file -, link-type EN10MB (Ethernet), snapshot length 1600
01:00:00.000001 00:11:22:33:44:55 > 00:00:00:00:00:01, ethertype IPv4 (0x0800), length 50: 0.0.0.0.7 > 0.0.0.0.7: UDP, length 8

WARNING:

Before merging it's perhaps best to change the dependency on https://github.com/demaledetti/empty-set to be something under input-output-hk. This is why this pull request is marked as draft.

FAQ:

hamishmack added a commit that referenced this pull request May 28, 2025
hamishmack added a commit that referenced this pull request May 28, 2025
@hamishmack hamishmack marked this pull request as ready for review May 28, 2025 10:28
@hamishmack hamishmack merged commit 1bd57b0 into input-output-hk:master May 28, 2025
29 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants