lib.customisation: uncurry makeScopeWithSplicing#245824
Merged
2 commits merged intomasterfrom Jul 28, 2023
unknown repository
Merged
lib.customisation: uncurry makeScopeWithSplicing#2458242 commits merged intomasterfrom unknown repository
2 commits merged intomasterfrom
unknown repository
Conversation
12 tasks
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 switch to attrset-passing form, to provide some minimal level of sanity-checking.
Artturin
reviewed
Jul 28, 2023
Member
There was a problem hiding this comment.
diff --git a/lib/customisation.nix b/lib/customisation.nix
index a46913dc5bde..4dfe75023b96 100644
--- a/lib/customisation.nix
+++ b/lib/customisation.nix
@@ -279,7 +279,7 @@ rec {
/* Like the above, but aims to support cross compilation. It's still ugly, but
hopefully it helps a little bit. */
- makeScopeWithSplicing = { splicePackages, newScope }: { otherSplices, keep, extra, f }:
+ makeScopeWithSplicing = { splicePackages, newScope, otherSplices, keep, extra, f }:
let
spliced0 = splicePackages {
pkgsBuildBuild = otherSplices.selfBuildBuild;
@@ -296,8 +296,7 @@ rec {
# N.B. the other stages of the package set spliced in are *not*
# overridden.
overrideScope = g: (makeScopeWithSplicing
- { inherit splicePackages newScope; }
- { inherit otherSplices keep extra;
+ { inherit splicePackages newScope otherSplices keep extra;
f = lib.fixedPoints.extends g f;
});
packages = f;
diff --git a/pkgs/top-level/splice.nix b/pkgs/top-level/splice.nix
index 57cedb12a2f5..01407c107a16 100644
--- a/pkgs/top-level/splice.nix
+++ b/pkgs/top-level/splice.nix
@@ -144,7 +144,7 @@ in
newScope = extra: lib.callPackageWith (splicedPackagesWithXorg // extra);
# prefill 2 fields of the function for convenience
- makeScopeWithSplicing = lib.makeScopeWithSplicing { inherit splicePackages; inherit (pkgs) newScope; };
+ makeScopeWithSplicing = a: lib.makeScopeWithSplicing ({ inherit splicePackages; inherit (pkgs) newScope; } // a);
# generate 'otherSplices' for 'makeScopeWithSplicing'
generateSplicesForMkScope = attr:Alternative which would not require 2 input sets, which looks nicer if lib.makeScopeWithSplicing is used directly, IMO.
Member
There was a problem hiding this comment.
functionArgs won't work on pkgs.makeScopeWithSplicing though
These are often unneeded by the user.
Artturin
approved these changes
Jul 28, 2023
Member
|
This is not okay, this is a breaking change to |
Author
You're right. For some reason I thought Will revert and reintroduce with a new name for the uncurried version. |
Author
|
I have merged #245955 |
Member
|
Thanks! |
12 tasks
Author
|
Reimplemented with a different name and a backward-compatible shim: #245957 |
This pull request was closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.nixalso declares a makeScopeWithSplicing, but it takes two fewer arguments.Let's switch to attrset-passing form, to provide some minimal level of sanity-checking.
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)