about summary refs log tree commit diff
path: root/pkgs/build-support/build-fhsenv-bubblewrap
diff options
context:
space:
mode:
authorPeder Bergebakken Sundt <pbsds@hotmail.com>2023-11-30 01:28:38 +0100
committerPeder Bergebakken Sundt <pbsds@hotmail.com>2024-04-24 15:26:52 +0200
commitbbb1f25bfb5b8b956caab23e49b705640ea1dc3c (patch)
tree6a03d3158fdea62f6401dde16a12e436c536d252 /pkgs/build-support/build-fhsenv-bubblewrap
parentb8100ca5e4d982e642420815331e35720632f353 (diff)
buildFHSEnvBubblewrap: do not infer `pname` from `name`
Diffstat (limited to 'pkgs/build-support/build-fhsenv-bubblewrap')
-rw-r--r--pkgs/build-support/build-fhsenv-bubblewrap/default.nix21
1 files changed, 9 insertions, 12 deletions
diff --git a/pkgs/build-support/build-fhsenv-bubblewrap/default.nix b/pkgs/build-support/build-fhsenv-bubblewrap/default.nix
index c30a4dfb7ea37..311212495f64d 100644
--- a/pkgs/build-support/build-fhsenv-bubblewrap/default.nix
+++ b/pkgs/build-support/build-fhsenv-bubblewrap/default.nix
@@ -9,10 +9,7 @@
 , bubblewrap
 }:
 
-{ name ? null
-, pname ? null
-, version ? null
-, runScript ? "bash"
+{ runScript ? "bash"
 , extraInstallCommands ? ""
 , meta ? {}
 , passthru ? {}
@@ -29,7 +26,7 @@
 , ...
 } @ args:
 
-assert (pname != null || version != null) -> (name == null && pname != null); # You must declare either a name or pname + version (preferred).
+assert (!args ? pname || !args ? version) -> (args ? name); # You must provide name if pname or version (preferred) is missing.
 
 let
   inherit (lib)
@@ -43,9 +40,10 @@ let
 
   inherit (lib.attrsets) removeAttrs;
 
-  pname = if args ? name && args.name != null then args.name else args.pname;
-  versionStr = optionalString (version != null) ("-" + version);
-  name = pname + versionStr;
+  name = args.name or "${args.pname}-${args.version}";
+  executableName = args.pname or args.name;
+  # we don't know which have been supplied, and want to avoid defaulting missing attrs to null. Passed into runCommandLocal
+  nameAttrs = lib.filterAttrs (key: value: builtins.elem key [ "name" "pname" "version" ]) args;
 
   buildFHSEnv = callPackage ./buildFHSEnv.nix { };
 
@@ -270,8 +268,7 @@ let
   '';
 
   bin = writeShellScript "${name}-bwrap" (bwrapCmd { initArgs = ''"$@"''; });
-in runCommandLocal name {
-  inherit pname version;
+in runCommandLocal name (nameAttrs // {
   inherit meta;
 
   passthru = passthru // {
@@ -285,9 +282,9 @@ in runCommandLocal name {
     '';
     inherit args fhsenv;
   };
-} ''
+}) ''
   mkdir -p $out/bin
-  ln -s ${bin} $out/bin/${pname}
+  ln -s ${bin} $out/bin/${executableName}
 
   ${extraInstallCommands}
 ''