Skip to content

lib.customisation: add uncurried form of makeScopeWithSplicing#245957

Merged
Artturin merged 2 commits intomasterfrom
unknown repository
Aug 20, 2023
Merged

lib.customisation: add uncurried form of makeScopeWithSplicing#245957
Artturin merged 2 commits intomasterfrom
unknown repository

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.

@github-actions github-actions bot added 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: qt/kde Object-oriented framework for GUI creation 6.topic: xfce The Xfce Desktop Environment 6.topic: steam Steam game store/launcher (store.steampowered.com) 6.topic: lua Lua is a powerful, efficient, lightweight, embeddable scripting language. 6.topic: lib The Nixpkgs function library labels Jul 28, 2023
@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
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Jul 28, 2023
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
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.

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

Labels

6.topic: lib The Nixpkgs function library 6.topic: lua Lua is a powerful, efficient, lightweight, embeddable scripting language. 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: qt/kde Object-oriented framework for GUI creation 6.topic: steam Steam game store/launcher (store.steampowered.com) 6.topic: xfce The Xfce Desktop Environment 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants