Skip to content

haskell.lib.combineInputs: init#416246

Closed
9999years wants to merge 1 commit intoNixOS:masterfrom
9999years:haskell-lib-combine-inputs
Closed

haskell.lib.combineInputs: init#416246
9999years wants to merge 1 commit intoNixOS:masterfrom
9999years:haskell-lib-combine-inputs

Conversation

@9999years
Copy link
Copy Markdown
Contributor

This adds a new haskell.lib.combineInputs function which encapsulates the logic used by haskellPackages.shellFor to compute package dependencies.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • Nixpkgs 25.11 Release Notes (or backporting 24.11 and 25.05 Nixpkgs Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
  • NixOS 25.11 Release Notes (or backporting 24.11 and 25.05 NixOS Release notes)
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other contributing documentation in corresponding paths.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 6.topic: haskell General-purpose, statically typed, purely functional programming language label Jun 12, 2025
This adds a new `haskell.lib.combineInputs` function which encapsulates
the logic used by `haskellPackages.shellFor` to compute package
dependencies.
@9999years 9999years force-pushed the haskell-lib-combine-inputs branch from 879a610 to 223c859 Compare June 13, 2025 00:35
@github-actions github-actions 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. labels Jun 13, 2025
@maralorn
Copy link
Copy Markdown
Member

Before having looked into it in detail I can say that I like this very much.

I don’t remember the exact details but I remember doing dirty things like applying head to (shellFor { ... }).buildInputs to get a ghc.withPackages which had everything I wanted …

@9999years
Copy link
Copy Markdown
Contributor Author

Glad to hear it! It's not causing any rebuilds and the tests pass, so I'm pretty confident it's equivalent.

Copy link
Copy Markdown
Member

@maralorn maralorn left a comment

Choose a reason for hiding this comment

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

Great PR, thank you. Although after staring at it for a while I am a bit blurry on the motivation. What is this function useful for besides using it in shellFor? (I know this kinda contradicts my previous comment.)

I left a few comments before I realized you were just pasting code. Feel free to dismiss.

Bonus points for documenting the function in the manual.

# }
# ...
# ]
cabalDepsForSelected = builtins.map (p: p.getCabalDeps) (builtins.filter (p: p != null) packages);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Theoretically could use lib.pipe, not sure if better.

#
# isNotSelected lens [ frontend backend common ]
# => true
isNotSelected = input: pkgs.lib.all (p: input.outPath or null != p.outPath) packages;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think lib is in scope.

Suggested change
isNotSelected = input: pkgs.lib.all (p: input.outPath or null != p.outPath) packages;
isNotSelected = input: lib.all (p: input.outPath or null != p.outPath) packages;

# `backend`, then zipperCombinedPkgs needs to be careful to filter out
# `common`, because cabal will end up ignoring that built version,
# assuming new-style commands.
zipperCombinedPkgs = vals: pkgs.lib.concatMap (drvList: pkgs.lib.filter isNotSelected drvList) vals;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This function name seems weird to me. 😆

@9999years 9999years closed this Jul 10, 2025
@9999years 9999years deleted the haskell-lib-combine-inputs branch July 10, 2025 23:04
@maralorn
Copy link
Copy Markdown
Member

Uh, @9999years , don't you want this merged anymore? I was just waiting for some reaction on my feedback. Didn't mean to discourage you.

@9999years
Copy link
Copy Markdown
Contributor Author

@maralorn I don't have a compelling use-case for this at the moment, but feel free to push it over the line if you're interested in it.

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants