Skip to content

Commit

Permalink
Merge pull request #785 from nix-community/smaller-fixes
Browse files Browse the repository at this point in the history
Fix shellcheck for mounoptions with commas + escape filesystem args
  • Loading branch information
Mic92 authored Sep 20, 2024
2 parents 624fd86 + 9adb48e commit 0fe7799
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
8 changes: 7 additions & 1 deletion example/f2fs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
type = "filesystem";
format = "f2fs";
mountpoint = "/";
extraArgs = [
"-O"
"extra_attr,inode_checksum,sb_checksum,compression"
];
mountOptions = [
"compress_algorithm=zstd:6,compress_chksum,atgc,gc_merge,lazytime,nodiscard"
];
};
};
};
Expand All @@ -31,4 +38,3 @@
};
};
}

2 changes: 2 additions & 0 deletions example/zfs-with-vdevs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@
cache = [ "cache" ];
};
};
# Workaround: cannot import 'zroot': I/O error in disko tests
options.cachefile = "none";

rootFsOptions = {
compression = "zstd";
Expand Down
4 changes: 3 additions & 1 deletion lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ let
interpreter = if noDeps then "/usr/bin/env bash" else "${pkgs.bash}/bin/bash";
check = lib.optionalString (checked && !pkgs.hostPlatform.isRiscV64 && !pkgs.hostPlatform.isx86_32) (pkgs.writeScript "check" ''
set -efu
${pkgs.shellcheck}/bin/shellcheck -e SC2034 "$1"
# SC2054: our toShellVars function doesn't quote list elements with commas
# SC2034: We don't use all variables exported by hooks.
${pkgs.shellcheck}/bin/shellcheck -e SC2034,SC2054 "$1"
'');
};

Expand Down
4 changes: 2 additions & 2 deletions lib/types/filesystem.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
default = ''
if ! (blkid '${config.device}' | grep -q 'TYPE='); then
mkfs.${config.format} \
${toString config.extraArgs} \
${lib.escapeShellArgs config.extraArgs} \
${config.device}
fi
'';
Expand All @@ -58,7 +58,7 @@
if ! findmnt ${config.device} "${rootMountPoint}${config.mountpoint}" >/dev/null 2>&1; then
mount ${config.device} "${rootMountPoint}${config.mountpoint}" \
-t "${config.format}" \
${lib.concatMapStringsSep " " (opt: "-o ${opt}") config.mountOptions} \
${lib.concatMapStringsSep " " (opt: "-o ${lib.escapeShellArg opt}") config.mountOptions} \
-o X-mount.mkdir
fi
'';
Expand Down

0 comments on commit 0fe7799

Please sign in to comment.