From bc7fd7238a6596dfd0eb1d194f8ca73217d25e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 20 Sep 2024 14:47:45 +0200 Subject: [PATCH 1/4] filesystem: escape shell args --- lib/types/filesystem.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/types/filesystem.nix b/lib/types/filesystem.nix index 8f9e80d..5327e7a 100644 --- a/lib/types/filesystem.nix +++ b/lib/types/filesystem.nix @@ -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 ''; @@ -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 ''; From da8bfaf1d5b8b4ca1d1a46aea116ebabf35d8d2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 20 Sep 2024 14:55:36 +0200 Subject: [PATCH 2/4] shellcheck: also disable SC2054 --- lib/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/default.nix b/lib/default.nix index ccf169a..0506983 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -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" ''); }; From 93c1dde4190ecde415de3a47ba42163306b06998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 20 Sep 2024 15:02:25 +0200 Subject: [PATCH 3/4] tests/f2fs: add compression This is a regression test for shellcheck, where we had to disable SC2054 --- example/f2fs.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/example/f2fs.nix b/example/f2fs.nix index f5a1e8f..838b1a1 100644 --- a/example/f2fs.nix +++ b/example/f2fs.nix @@ -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" + ]; }; }; }; @@ -31,4 +38,3 @@ }; }; } - From 9adb48e682a42a52b83f9093b55020913a0f911f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 20 Sep 2024 15:16:46 +0200 Subject: [PATCH 4/4] add workaround for flakey zfs tests --- example/zfs-with-vdevs.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/example/zfs-with-vdevs.nix b/example/zfs-with-vdevs.nix index a61680a..96750fd 100644 --- a/example/zfs-with-vdevs.nix +++ b/example/zfs-with-vdevs.nix @@ -93,6 +93,8 @@ cache = [ "cache" ]; }; }; + # Workaround: cannot import 'zroot': I/O error in disko tests + options.cachefile = "none"; rootFsOptions = { compression = "zstd";