buildFHSEnvBubblewrap: do not infer pname from name

This commit is contained in:
Peder Bergebakken Sundt
2024-04-24 15:26:52 +02:00
parent b8100ca5e4
commit bbb1f25bfb
2 changed files with 14 additions and 13 deletions
@@ -6,7 +6,11 @@ It uses Linux' namespaces feature to create temporary lightweight environments w
Accepted arguments are:
- `name`
The name of the environment and the wrapper executable.
The name of the environment, and the wrapper executable if `pname` is unset.
- `pname`
The pname of the environment and the wrapper executable.
- `version`
The version of the environment.
- `targetPkgs`
Packages to be installed for the main host's architecture (i.e. x86_64 on x86_64 installations). Along with libraries binaries are also installed.
- `multiPkgs`
@@ -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}
''