From 7b3acc2bf1b5e468b0d75e738ad30f93afcad106 Mon Sep 17 00:00:00 2001 From: kokobd Date: Fri, 30 Aug 2024 16:02:22 -0500 Subject: [PATCH 1/3] dynamically check for path existence --- default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/default.nix b/default.nix index 0ff1be2..7f910af 100644 --- a/default.nix +++ b/default.nix @@ -39,10 +39,10 @@ pkgs.runCommand "bundle-${name}" export bin_dir='${bin_dir}' export exe_dir='${exe_dir}' export lib_dir='${lib_dir}' - ${if builtins.pathExists "${path}/bin" then '' + if [ -d "${path}/bin" ]; then find '${path}/bin' -type f -executable -print0 | xargs -0 --max-args 1 ${cfg.script} "$out" - '' else '' + else ${cfg.script} "$out" ${pkgs.lib.escapeShellArg path} - ''} + fi find $out -empty -type d -delete '' From 24690e8f4e9ee46e80e1184397da12b2e817ecb6 Mon Sep 17 00:00:00 2001 From: kokobd Date: Mon, 2 Sep 2024 16:14:12 -0500 Subject: [PATCH 2/3] don't force 'path' when the name of the output drv is forced --- default.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/default.nix b/default.nix index 7f910af..eb76389 100644 --- a/default.nix +++ b/default.nix @@ -27,10 +27,8 @@ let else throw "Unsupported platform: only darwin and linux are supported"; - name = if pkgs.lib.isDerivation path then path.name else builtins.baseNameOf path; - overrideEnv = name: value: if value == null then "" else "export ${name}='${value}'"; in -pkgs.runCommand "bundle-${name}" +pkgs.runCommand "bundle" { nativeBuildInputs = cfg.deps ++ [ pkgs.nukeReferences ]; } From 83a1e4169c3bc242ed450c4ca733156a76388637 Mon Sep 17 00:00:00 2001 From: kokobd Date: Tue, 3 Sep 2024 15:51:59 -0500 Subject: [PATCH 3/3] use [[ instead of [ --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index eb76389..281268a 100644 --- a/default.nix +++ b/default.nix @@ -37,7 +37,7 @@ pkgs.runCommand "bundle" export bin_dir='${bin_dir}' export exe_dir='${exe_dir}' export lib_dir='${lib_dir}' - if [ -d "${path}/bin" ]; then + if [[ -d "${path}/bin" ]]; then find '${path}/bin' -type f -executable -print0 | xargs -0 --max-args 1 ${cfg.script} "$out" else ${cfg.script} "$out" ${pkgs.lib.escapeShellArg path}