From 83ec5a063a5e9df73ec45a915d4369986579432e Mon Sep 17 00:00:00 2001 From: RTUnreal Date: Tue, 8 Apr 2025 22:22:24 +0200 Subject: [PATCH] vars: use writeShellApplication to shellcheck generators --- nixosModules/clanCore/vars/generator.nix | 57 +++++++++++++----------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/nixosModules/clanCore/vars/generator.nix b/nixosModules/clanCore/vars/generator.nix index aae8dc22f..677295f30 100644 --- a/nixosModules/clanCore/vars/generator.nix +++ b/nixosModules/clanCore/vars/generator.nix @@ -16,7 +16,7 @@ let ; promptToFile = name: '' - cat "$prompts/${name}" > "$out/${name}" + cat "$prompts"/${name} > "$out"/${name} ''; promptsToFilesScript = concatMapStrings promptToFile; @@ -25,35 +25,42 @@ let in { finalScript = mkOptionDefault ( - pkgs.writeScript "generator-${config.name}" '' - set -eu -o pipefail + lib.getExe ( + pkgs.writeShellApplication { + name = "generator-${config.name}"; + text = '' + in="''${in:?}" + out="''${out:?}" + ${if config.prompts == { } then "" else ''prompts="''${prompts:?}"''} - export PATH="${makeBinPath config.runtimeInputs}:${pkgs.coreutils}/bin" + export PATH="${makeBinPath config.runtimeInputs}:${pkgs.coreutils}/bin" - ${optionalString (pkgs.stdenv.hostPlatform.isLinux) '' - # prepare sandbox user on platforms where this is supported - mkdir -p /etc + ${optionalString (pkgs.stdenv.hostPlatform.isLinux) '' + # prepare sandbox user on platforms where this is supported + mkdir -p /etc - cat > /etc/group < /etc/group < /etc/passwd < /etc/passwd < /etc/hosts < /etc/hosts <