-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
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
treewide: fix eval related to with lib;
removal
#339356
Conversation
I can't promise that this fixes every problem but I fixed what I saw Basically my approach was to use the following script:#!/usr/bin/env bash
# Get the list of files containing "with lib;"
files=$(rg -lFx "with lib;" ./nixos/)
optionstring=$(nix eval --impure --expr 'with import <nixpkgs> {}; builtins.attrNames (builtins.removeAttrs lib ["__unfix__" "licenses" "fix" "and" "or" "kernel" "options" "meta" "path"])' | sed 's/" "/ /g;s/" ]//g;s/\[ "//g')
IFS=' ' read -ra options <<< $optionstring
# Function to escape special characters for sed
escape_sed_pattern() {
echo "$1" | sed 's/[.[\*^$+()|]/\\&/g'
}
# Loop over each file
for file in $files; do
# delete empty before
sed -i '/with lib;/,$ b; /^$/d;' "$file"
# delete empty after
sed -i '/with lib;/{N;s/\n$//}' "$file"
# delete match
sed -i '/^\s*with lib;\s*$/d' "$file"
for str in "${options[@]}"; do
# Escape the string for use in sed
escaped_str=$(escape_sed_pattern "$str")\\b
# Prepend "lib" to the current string
lib_str="lib.$str"
# Escape the lib_str for use in sed
escaped_lib_str=$(escape_sed_pattern "$lib_str")
# Use sed to replace occurrences in the temporary file
sed -i '/inherit/!s/\([^-._0-9a-zA-Z]\)'"$escaped_str"'/\1'"$escaped_lib_str"'/g' "$file"
done
done Key modifications were to use an exclusion list against Then I diffed the result against |
Almost all of these fixes are not actually breaking. These symbols are in the Nix prelude, are available without any import, and also happen to be available from
These symbols are in the Nix prelude, are available without any import, and are not available in
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are four real issues here, three that affect eval/functionality and one that affects diagnostics. The rest of the files can be reverted or committed, it doesn't really matter.
I prefer to revert, since map
is shorter than lib.map
, but I'll leave that up to you, @eclairevoyant.
nixos/modules/services/continuous-integration/jenkins/default.nix
Outdated
Show resolved
Hide resolved
nixos/modules/services/continuous-integration/jenkins/default.nix
Outdated
Show resolved
Hide resolved
Thanks for pointing it out, I've removed those changes. |
please add this as well diff --git a/nixos/modules/services/hardware/thinkfan.nix b/nixos/modules/services/hardware/thinkfan.nix
index 9dd4c5434211..9733fbe5aa15 100644
--- a/nixos/modules/services/hardware/thinkfan.nix
+++ b/nixos/modules/services/hardware/thinkfan.nix
@@ -12,7 +12,7 @@ let
tuple = ts: lib.mkOptionType {
name = "tuple";
merge = lib.mergeOneOption;
- check = xs: all id (zipListsWith (t: x: t.check x) ts xs);
+ check = xs: lib.all lib.id (lib.zipListsWith (t: x: t.check x) ts xs);
description = "tuple of" + lib.concatMapStrings (t: " (${t.description})") ts;
};
level = ints.unsigned; |
That's already fixed (#339084) |
oh great, I guess it was not merged into unstable yet |
Description of changes
fixup for #335603, #335618
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.