Skip to content

maintainers/scripts/haskell: Fix relative imports to work with nix and lix - #581707

Merged
maralorn merged 1 commit into
NixOS:masterfrom
maralorn:maralorn/maintainers-scripts-haskell-fix-relative-imports-to-work-with-nix-and-lix
Nov 1, 2026
Merged

maralorn merged 1 commit into
NixOS:masterfrom
maralorn:maralorn/maintainers-scripts-haskell-fix-relative-imports-to-work-with-nix-and-lix

Conversation

@maralorn

@maralorn maralorn commented Nov 1, 2026

Copy link
Copy Markdown
Member

Running these scripts with lix has regressed in #554512 This is because nix changed the way it resolves relative imports after lix was forked.

This PR uses an import method which behaves identically on nix and lix.

AI Disclaimer: I typed and tested all of this myself but an LLM helped me debug and suggest the solution.

Things done

…nd_ lix

Running these scripts with lix has regressed in NixOS#554512
This is because nix changed the way it resolves relative imports after lix was forked.

This PR uses an import method which behaves identically on nix and lix.

AI Disclaimer: I typed and tested all of this myself but an LLM helped me debug and suggest the solution.

@wolfgangwalther wolfgangwalther left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just looking to fix the script myself as well...

TIL, that nix-shell -p also takes expressions.

LGTM.

@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person. 6.topic: haskell General-purpose, statically typed, purely functional programming language labels Nov 1, 2026
@maralorn
maralorn added this pull request to the merge queue Nov 1, 2026
@maralorn

maralorn commented Nov 1, 2026

Copy link
Copy Markdown
Member Author

@wolfgangwalther Are you also looking at the follow-up problem with the transitive-broken going wrong? Because I would look into that next, if you are not.

Merged via the queue into NixOS:master with commit 236e487 Nov 1, 2026
32 checks passed
@maralorn
maralorn deleted the maralorn/maintainers-scripts-haskell-fix-relative-imports-to-work-with-nix-and-lix branch November 1, 2026 11:11
@wolfgangwalther

Copy link
Copy Markdown
Contributor

Are you also looking at the follow-up problem with the transitive-broken going wrong?

I am just right now looking at that, yes.

@wolfgangwalther

Copy link
Copy Markdown
Contributor

Are you also looking at the follow-up problem with the transitive-broken going wrong?

I am just right now looking at that, yes.

I give up - again.

On my first attempt (#572089 (comment)), I concluded that <pkg>.meta.broken behaves differently, whether config.allowBroken is enabled or not.

In my second attempt today, I discovered, that there seems to be a difference between packages using meta.broken directly and the new meta.problems.broken: The former has changed behavior as described above, the latter does not.

Observe:

  • config.allowBroken = false (default), haskellPackages.aasam.meta.broken == true
  • config.allowBroken = true, haskellPackages.aasam.meta.broken == false (this is the changed behavior after stdenv/problems: use generated problems for legacy field values #557381)
  • config.allowBroken = false (default), gtk2.meta.broken == true
  • config.allowBroken = true, gtk2.meta.broken == true

haskellPackages.aasam uses meta.broken directly, like all other hackage packages. gtk2 uses meta.problems.broken.

I think #557381 is just faulty.

There's probably a simple way to work around this, but I didn't immediately find it.

@wolfgangwalther

Copy link
Copy Markdown
Contributor

Or maybe... allowBroken just doesn't allow meta.problems.broken? There possibly is just a new nixpkgs option that we ought to use instead...

Seems like there is config.problems indeed, but I did not look further into that. We might just need to change allowBroken to that instead.

@@ -1,5 +1,5 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -E 'with import ../../.. {}; mkShell { packages = [ bash coreutils haskellPackages.cabal2nix-unstable.bin git (import ../../../ci {}).fmt.pkg ]; }'
#! nix-shell -i bash -I nixpkgs=. -p bash coreutils haskellPackages.cabal2nix-unstable.bin git "(import <nixpkgs/ci> {}).fmt.pkg"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#554512 deliberately avoided using -I nixpkgs=. because that is resolved relative to the caller's CWD, rather than relative to the script itself. This is discussed in #425551.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's not pretty. Any idea how we can solve Bothe problems at once?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: haskell General-purpose, statically typed, purely functional programming language 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants