mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-15 10:46:15 +02:00
c4766d7b8b
When `nix fmt` is called without an argument, Nix appends the "." argument before calling the formatter. The comment in the code is: > Format the current flake out of the box This also happens when formatting sub-folders. This means that the formatter is now unable to distinguish, as an interface, whether the "." argument is coming from the flake or the user's intent to format the current folder. This decision should be up to the formatter. Treefmt, for example, will automatically look up the project's root and format all the files. This is the desired behaviour. But because the "." argument is passed, it cannot function as expected.
38 lines
927 B
Bash
Executable file
38 lines
927 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
source common.sh
|
|
|
|
TODO_NixOS # Provide a `shell` variable. Try not to `export` it, perhaps.
|
|
|
|
clearStoreIfPossible
|
|
rm -rf "$TEST_HOME"/.cache "$TEST_HOME"/.config "$TEST_HOME"/.local
|
|
|
|
cp ./simple.nix ./simple.builder.sh ./fmt.simple.sh ./config.nix "$TEST_HOME"
|
|
|
|
cd "$TEST_HOME"
|
|
|
|
nix fmt --help | grep "Format"
|
|
|
|
cat << EOF > flake.nix
|
|
{
|
|
outputs = _: {
|
|
formatter.$system =
|
|
with import ./config.nix;
|
|
mkDerivation {
|
|
name = "formatter";
|
|
buildCommand = ''
|
|
mkdir -p \$out/bin
|
|
echo "#! ${shell}" > \$out/bin/formatter
|
|
cat \${./fmt.simple.sh} >> \$out/bin/formatter
|
|
chmod +x \$out/bin/formatter
|
|
'';
|
|
};
|
|
};
|
|
}
|
|
EOF
|
|
# No arguments check
|
|
[[ "$(nix fmt)" = "Formatting(0):" ]]
|
|
# Argument forwarding check
|
|
nix fmt ./file ./folder | grep 'Formatting(2): ./file ./folder'
|
|
nix flake check
|
|
nix flake show | grep -P "package 'formatter'"
|