-
-
Notifications
You must be signed in to change notification settings - Fork 15k
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
Fix some nixos-rebuild lints #147449
Fix some nixos-rebuild lints #147449
Conversation
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.
I am not sure if it is worth switching all [ to [[. Also I personally would drop all the optional quotes inside the [[ and would also chain multiple up.
Maybe we should add a style guide entry before changing those to make sure we are all on the same track.
@@ -89,7 +90,7 @@ while [ "$#" -gt 0 ]; do | |||
fi | |||
if [ "$1" != system ]; then | |||
profile="/nix/var/nix/profiles/system-profiles/$1" | |||
mkdir -p -m 0755 "$(dirname "$profile")" | |||
mkdir -m 0755 "$(dirname "$profile")" |
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.
I am not sure if this path could be taken twice because if the directory would exist right now the command would error. Or is that the weird case in mkdir where -p is implied?
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.
Sorry, I didn't mean to push that change. I got rid of this locally but forgot to force push.
You're right, -p
also doesn't fail if the directory already exists. We could easily fix that case, but I guess the original question of the intention re. ancestor directories still stands.
if [[ -z $flake ]]; then | ||
pathToConfig="$(nixBuild '<nixpkgs/nixos>' --no-out-link -A system "${extraBuildFlags[@]}")" | ||
else | ||
pathToConfig="$(nixFlakeBuild "$flake#$flakeAttr.config.system.build.toplevel" "${extraBuildFlags[@]}" "${lockFlags[@]}")" | ||
fi | ||
copyToTarget "$pathToConfig" | ||
targetHostCmd nix-env -p "$profile" --set "$pathToConfig" | ||
elif [ "$action" = test -o "$action" = build -o "$action" = dry-build -o "$action" = dry-activate ]; then | ||
elif [[ "$action" = test ]] || [[ "$action" = build ]] || [[ "$action" = dry-build ]] || [[ "$action" = dry-activate ]]; then |
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.
elif [[ "$action" = test ]] || [[ "$action" = build ]] || [[ "$action" = dry-build ]] || [[ "$action" = dry-activate ]]; then | |
elif [[ "$action" = test || "$action" = build || "$action" = dry-build || "$action" = dry-activate ]]; then |
I think we should at least remove the optional ]] [[ in between. It makes the code shorter and for me personally way easier to understand. I would also be fine with keeping the -o to reduce the diff.
6bdb8c3
to
d2c5732
Compare
@ofborg eval |
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.
tested by checking out my system revision and applying this as a patch
git apply - <<< $(curl https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/147449.patch)
and rebuilding nix build ".#nixos-rebuild" && sudo ./result/bin/nixos-rebuild switch -I nixpkgs=$(pwd)
doesn't need to target staging |
The script already uses non-POSIX features like `[[` and `local`, so I assume it's safe to assume it shouldn't be treated as POSIX `sh`.
d2c5732
to
311bfc8
Compare
Is the auto-request for reviews intentional or caused by the momentary massive diff between this branch and the target branch when switching from |
reverse master and staging in this to go from staging to master
then change the base branch in the github PR from instructions made by jonringer |
Is this somewhere front and centre in the contribution docs? Seems really important. |
Motivation for this change
Existing issues requesting ShellCheck compliance: #133088, #21166. Request from @Artturin.
Open questions
There's one warning-level issue still reported by ShellCheck:
The simplest "solution" would be to remove the
-p
, but I'm not sure whether I can assume that/nix/var/nix/profiles/system-profiles
will always exist when runningnixos-rebuild
. The less simple solution would be tomkdir
each of the ancestor directories in turn, but I'm not sure whether all of them should have mode 0755.I'll take care of
SSHOPTS
in a separate PR, since it's a more risky change.Things done
sandbox = true
set 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/
)nixos/doc/manual/md-to-db.sh
to update generated release notes@Artturin ^