From 1503f6b250b707f05727a5c865a6a4e1ed7e545e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Tue, 27 Jun 2023 13:24:13 +0200 Subject: [PATCH] nix: use Darwin stat command explicitly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise if in Nix context we can accidentally use GNU stat which results in a different output due to different command line flags: ``` [nix-shell:~/status-mobile]$ stat -Lf "%Sg" "/nix/store" stat: cannot read file system information for '%Sg': No such file or directory File: "/nix/store" ID: 10000110000001a Namelen: ? Type: apfs Block size: 4096 Fundamental block size: 4096 Blocks: Total: 242837545 Free: 199242283 Available: 199242283 Inodes: Total: 7971454780 Free: 7969691320 ``` And it should be just owner group name or ID. Which in turn results in: ``` Unknown Nix installtion type! ``` Signed-off-by: Jakub SokoĊ‚owski --- nix/scripts/lib.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nix/scripts/lib.sh b/nix/scripts/lib.sh index e4c0e64e10..74a550f3fc 100755 --- a/nix/scripts/lib.sh +++ b/nix/scripts/lib.sh @@ -8,7 +8,8 @@ file_group() { if [[ "${UNAME}" == "Linux" ]]; then stat -Lc "%G" "${1}" 2>/dev/null elif [[ "${UNAME}" == "Darwin" ]]; then - stat -Lf "%Sg" "${1}" 2>/dev/null + # Avoid using Nix GNU stat when in Nix shell. + /usr/bin/stat -Lf "%Sg" "${1}" 2>/dev/null fi }