treewide: remove nixfmt from update scripts' shebangs#433588
treewide: remove nixfmt from update scripts' shebangs#433588wolfgangwalther wants to merge 1 commit intoNixOS:masterfrom
Conversation
We expect all of these update scripts to be run inside a nixpkgs' nix-shell environment, which will provide the correct nixfmt including treefmt configuration.
MattSturgeon
left a comment
There was a problem hiding this comment.
I'd still like to investigate having the update scripts load the nixpkgs shell themselves and/or detect whether they are in one, so that that can display a helpful error message. Expecting maintainers to just know they should already be in the shell is not ideal.
But for now, expecting maintainers to enter the shell themselves (or use direnv) is acceptable, and this PR brings consistency to the remaining update scripts.
LGTM
|
Maybe it would be possible to replace the calls to |
That requires experimental features, so is probably a non-starter for some maintainers. Additionally, (as with most flakes-commands) using On the other hand, you can enter the shell once and continue to use the same formatter without re-evaluating it, regardless of whether your repo is dirty. |
I don't think this part would matter, because these can be enabled one-off via CLI for that command.
Once you know you have to do it, it's fine. But if you don't - you'll have literally no idea and will think this is broken. Copying the repo to the store is a small price to pay for that, I think. It does have other benefits, too - it actually runs Although just replacing |
|
Unlike more user-interactive workflows and/or git hooks where copying nixpkgs to store would be noticeable and frustrating, an update script could probably get away it as it does other slow actions anyway. But the perfectionist in me would still like to explore other options before resorting to an unnecessary copy-to-store. That said, I believe it is also compatible with #425551, so long as the CWD is somewhere within the nixpkgs working tree? It wouldn't work if the user was trying to run update scripts from outside their nixpkgs repo, of course. Include an additional shebang to load the nixpkgs shell is another option, but isn't really compatible with #425551 because it'd have to reference the CWD. For me I think the ideal solution looks like some combination of That said, Or maybe we could expose the nixpkgs shell itself in the |
To me this doesn't seem like a small price. @MattSturgeon all of your suggestions sound good to me.
I personally wouldn't have a problem with this. I'd rather the script be explicit about its dependencies. Removing In fact, I would prefer if update.sh also used a pure shell. I just tested this, and it works: |
This works by accident, because we don't use any configuration for We should not think about |
I have no problem switching it to use |
|
Correct. |
|
Not cleaned up yet, but this does seem to work: It'll use the same
|
| @@ -1,5 +1,5 @@ | |||
| #!/usr/bin/env nix-shell | |||
| #!nix-shell -I nixpkgs=./. -i bash -p curl jq nix gnused nixfmt | |||
| #!nix-shell -I nixpkgs=./. -i bash -p curl jq nix gnused | |||
There was a problem hiding this comment.
This will break dotnet updates because this is called from a pure shell.
There was a problem hiding this comment.
| #!nix-shell -I nixpkgs=./. -i bash -p curl jq nix gnused | |
| #!nix-shell --pure -I nixpkgs=./. -i bash -E 'with import <nixpkgs> {}; mkShell { inputsFrom = [ (import <nixpkgs/ci> { nixpkgs = <nixpkgs>; }).fmt.shell ]; packages = [ curl jq nix gnused cacert ]; }' |
There was a problem hiding this comment.
This will break dotnet updates because this is called from a pure shell.
Would an alternative be to remove --pure from the other shell?
There was a problem hiding this comment.
It seems better to be explicit about the dependencies. If the dependency is missing, it'll do a bunch of time consuming work and then fail without telling the user what they did wrong. Also if they happen to have the wrong treefmt/nixfmt in PATH already, it'll do something bad without failing.
|
Having a consistent shebang across all the update scripts is a meaningful increase in consistency and quality. Since it relies on an ambient In that issue, @infinisil suggests something like the following (with an appropriate number of That accomplishes the following:
This all sums up, in my mind, to a greater chance that the update script will work. |
|
I'm not going to follow up on this, realistically. The underlying issue is tracked in #425551. |
We expect all of these update scripts to be run inside a nixpkgs' nix-shell environment, which will provide the correct nixfmt including treefmt configuration.
We already did this as part of b68cc63, but more occurences sneaked in or were left over.
Things done
Add a 👍 reaction to pull requests you find important.