Repository navigation
maintainers/scripts: format with treefmt config - #554512
Conversation
wolfgangwalther
left a comment
There was a problem hiding this comment.
This SGTM, but I'd like to have @sternenseemann have a look in case I missed something in my earlier reasoning about this change.
|
@sternenseemann any chance you can take a look? |
|
It's annoying enough for me to have to start up a new nix-shell with nixfmt every time I want to regenerate hackage packages ever since nixfmt is not available in the nixpkgs dev shell anymore. So let's do this and if a problem is reported later, we can always fix / switch again. |
|
As mentioned in #578893 (comment), this broke the script for Lix. So we will have to do this differently... |
Fixed in #581707 |
|
My fix does not cover maintainers/scripts/update-ruby-packages which is also affected by this change. We might want to also do that. Not sure who to ping about that. |
…nd_ lix Running these scripts with lix has regressed in NixOS#554512 This is because nix changed the way it resolves relative imports after lix was forked. This PR uses an import method which behaves identically on nix and lix. AI Disclaimer: I typed and tested all of this myself but an LLM helped me debug and suggest the solution.
…nd_ lix Running these scripts with lix has regressed in NixOS#554512 This is because nix changed the way it resolves relative imports after lix was forked. This PR uses an import method which behaves identically on nix and lix. AI Disclaimer: I typed and tested all of this myself but an LLM helped me debug and suggest the solution.
Followup to #554040 (comment)
Prior art: 37aac0f
Scripts should avoid running formatters directly. If possible, we should always use
treefmtas configured by CI.nixfmtused may be a different version to the one pinned by CI*.nixfilesOne way to handle this would be to have multiple chained
nix-shellshebangs, however that's a little messy and also makes enabling--purea bit awkward.A more robust approach, recommended by #425551, is to use an explicit
mkShellexpression vianix-shell's-Eflag.In addition to allowing arbitrary expressions like
(import ../../ci {}).fmt.pkg, another major advantage of-E 'import ../.. {}over-I nixpkgs=.is that paths resolve consistently regardless of where the script is run from;-Iresolves relative to the CWD, while-Eresolves relative to the script file.Things done
./result/bin/.