From e4469b7af2461e1068e82f710d4f0a092eb0e4a2 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Tue, 7 Jan 2025 12:10:58 +0000 Subject: [PATCH 1/2] buildFHSEnv: allow specifying `executableName` explicitly --- doc/build-helpers/special/fhs-environments.section.md | 6 ++++-- pkgs/build-support/build-fhsenv-bubblewrap/default.nix | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/build-helpers/special/fhs-environments.section.md b/doc/build-helpers/special/fhs-environments.section.md index b87bb97278576..815f6cac1126b 100644 --- a/doc/build-helpers/special/fhs-environments.section.md +++ b/doc/build-helpers/special/fhs-environments.section.md @@ -6,11 +6,13 @@ It uses Linux' namespaces feature to create temporary lightweight environments w Accepted arguments are: - `name` - The name of the environment, and the wrapper executable if `pname` is unset. + The name of the environment. - `pname` - The pname of the environment and the wrapper executable. + The pname of the environment. - `version` The version of the environment. +- `executableName` + The name of the wrapper executable. Defaults to `pname` if set, or `name` otherwise. - `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` diff --git a/pkgs/build-support/build-fhsenv-bubblewrap/default.nix b/pkgs/build-support/build-fhsenv-bubblewrap/default.nix index 12881e4a0bac5..172713020e1fb 100644 --- a/pkgs/build-support/build-fhsenv-bubblewrap/default.nix +++ b/pkgs/build-support/build-fhsenv-bubblewrap/default.nix @@ -15,6 +15,7 @@ runScript ? "bash", nativeBuildInputs ? [ ], extraInstallCommands ? "", + executableName ? args.pname or args.name, meta ? { }, passthru ? { }, extraPreBwrapCmds ? "", @@ -49,7 +50,6 @@ let inherit (pkgsHostTarget) pkgsi686Linux; 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: From 2a2c0bf46f890b985a750d52b58784819d8d6713 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Tue, 7 Jan 2025 12:20:06 +0000 Subject: [PATCH 2/2] buildFHSEnv: simplify `pname`/`name` logic --- .../build-fhsenv-bubblewrap/default.nix | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/build-fhsenv-bubblewrap/default.nix b/pkgs/build-support/build-fhsenv-bubblewrap/default.nix index 172713020e1fb..c204628d16684 100644 --- a/pkgs/build-support/build-fhsenv-bubblewrap/default.nix +++ b/pkgs/build-support/build-fhsenv-bubblewrap/default.nix @@ -12,10 +12,13 @@ }: { + pname ? throw "You must provide either `name` or `pname`", + version ? throw "You must provide either `name` or `version`", + name ? "${pname}-${version}", runScript ? "bash", nativeBuildInputs ? [ ], extraInstallCommands ? "", - executableName ? args.pname or args.name, + executableName ? args.pname or name, meta ? { }, passthru ? { }, extraPreBwrapCmds ? "", @@ -31,7 +34,12 @@ ... }@args: -assert (!args ? pname || !args ? version) -> (args ? name); # You must provide name if pname or version (preferred) is missing. +# NOTE: +# `pname` and `version` will throw if they were not provided. +# Use `name` instead of directly evaluating `pname` or `version`. +# +# If you need `pname` or `version` sepcifically, use `args` instead: +# e.g. `args.pname or ...`. let inherit (lib) @@ -49,7 +57,6 @@ let # explicit about which package set it's coming from. inherit (pkgsHostTarget) pkgsi686Linux; - name = args.name or "${args.pname}-${args.version}"; # 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: