Skip to content
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

lib.customisation: add uncurried form of makeScopeWithSplicing #245957

Merged
merged 2 commits into from Aug 20, 2023
Merged

lib.customisation: add uncurried form of makeScopeWithSplicing #245957

merged 2 commits into from Aug 20, 2023

Conversation

ghost
Copy link

@ghost ghost commented Jul 28, 2023

Description of changes

Deeply-curried functions are pretty error-prone in untyped languages like Nix. This is a particularly bad case because top-level/splice.nix also declares a makeScopeWithSplicing, but it takes two fewer arguments.

Let's add a version that uses attrset-passing form, to provide some minimal level of sanity-checking.

This also provides defaults for keep and extra (these are often unneeded by the user).

Reimplements #245824.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • 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/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (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.

@ghost ghost requested a review from Artturin July 28, 2023 21:11
@ghost ghost mentioned this pull request Jul 28, 2023
12 tasks
@ghost ghost marked this pull request as ready for review July 28, 2023 21:12
lib/customisation.nix Outdated Show resolved Hide resolved
Adam Joseph added 2 commits August 14, 2023 02:50
Deeply-curried functions are pretty error-prone in untyped languages
like Nix.  This is a particularly bad case because
`top-level/splice.nix` *also* declares a makeScopeWithSplicing, but
it takes *two fewer arguments*.

Let's add a version that uses attrset-passing form, to provide some
minimal level of sanity-checking.

This also provides defaults for keep and extra (these are often
unneeded by the user).
@Artturin Artturin merged commit bde196d into NixOS:master Aug 20, 2023
5 checks passed
tjni added a commit that referenced this pull request Aug 20, 2023
tjni added a commit that referenced this pull request Aug 21, 2023
makeScopeWithSplicing =
splicePackages: newScope: otherSplices: keep: extra: f:
makeScopeWithSplicing' {
inherit splicePackages newScope otherSplices keep extra f;
Copy link
Contributor

Choose a reason for hiding this comment

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

This calls makeScopeWithSplicing' incorrectly:

       error: function 'makeScopeWithSplicing'' called with unexpected argument 'f'

       at /nix/store/n9fsxf3g69lp3rhkbb6biqpc18lp2gr8-source/lib/customisation.nix:291:5:

          290|   makeScopeWithSplicing' =
          291|     { splicePackages
             |     ^
          292|     , newScope

Copy link
Member

Choose a reason for hiding this comment

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

makeScopeWithSplicing' {
inherit splicePackages newScope otherSplices keep extra f;
};

/* Like the above, but aims to support cross compilation. It's still ugly, but
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, this comment is a bit confusing now; it should probably explicitly say "Like makeScope...".

github-actions bot pushed a commit to arcnmx/nixpkgs-lib that referenced this pull request Aug 22, 2023
github-actions bot pushed a commit to arcnmx/nixpkgs-lib that referenced this pull request Aug 29, 2023
@ghost ghost deleted the pr/lib/customization/makeScopeWithSplicing2 branch January 23, 2024 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants