Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildFHSEnv: allow specifying executableName explicitly #371770

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions doc/build-helpers/special/fhs-environments.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
13 changes: 10 additions & 3 deletions pkgs/build-support/build-fhsenv-bubblewrap/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +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 name,
MattSturgeon marked this conversation as resolved.
Show resolved Hide resolved
meta ? { },
passthru ? { },
extraPreBwrapCmds ? "",
Expand All @@ -30,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)
Expand All @@ -48,8 +57,6 @@ let
# explicit about which package set it's coming from.
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:
Expand Down