nixos/swap: resolve shellcheck warnings

And enable `enableStrictShellChecks` to ensure it stays that way.
This commit is contained in:
Mynacol 2025-12-01 16:14:00 +00:00 committed by Mynacol
parent 7975df2bbb
commit 0fc9a4dc80

View file

@ -297,7 +297,7 @@ in
${lib.optionalString (sw.size != null) ''
currentSize=$(( $(stat -c "%s" "$DEVICE" 2>/dev/null || echo 0) / 1024 / 1024 ))
if [[ ! -b "$DEVICE" && "${toString sw.size}" != "$currentSize" ]]; then
if [[ $(stat -f -c %T "$(dirname "$DEVICE")") == "btrfs" ]]; then
if [[ "$(stat -f -c %T "$(dirname "$DEVICE")")" == "btrfs" ]]; then
# Use btrfs mkswapfile to speed up the creation of swapfile.
rm -f "$DEVICE"
btrfs filesystem mkswapfile --size "${toString sw.size}M" --uuid clear "$DEVICE"
@ -331,6 +331,7 @@ in
mkswap ${sw.realDevice}
''}
'';
enableStrictShellChecks = true;
unitConfig.RequiresMountsFor = [ "${dirOf sw.device}" ];
unitConfig.DefaultDependencies = false; # needed to prevent a cycle