Skip to content

Commit

Permalink
Fix format script
Browse files Browse the repository at this point in the history
The previous script was failing, as it was supposed to.
It was trying to match a file named `'**/*.nix'`, rather
than expanding the intended pattern.

Bash doesn't do shell expansion inside of quotes.
It must be written unquoted, else `*` and other
special characters are treated literally.

`'**/*.nix'` -> `**/*.nix`

The new version will expand correctly.

Additionally, I've enabled `globstar` to make the
expansion match all files ending with `.nix`
recursively, including the top level. Without this,
the pattern will only match up one level.

`globstar` is documented here:
<https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html>
  • Loading branch information
sebaszv committed Nov 11, 2024
1 parent 2d424af commit 82d6ce9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
format = pkgs.writeShellApplication {
name = "format";
runtimeInputs = with pkgs; [ nixpkgs-fmt ];
text = "nixpkgs-fmt '**/*.nix'";
text = ''
shopt -s globstar
nixpkgs-fmt -- **/*.nix
'';
};

# only run this locally, as Actions will run out of disk space
Expand Down

0 comments on commit 82d6ce9

Please sign in to comment.