Skip to content

Commit

Permalink
buildFHSUserEnv: add version arg
Browse files Browse the repository at this point in the history
This lets you set the version for the derivation produced from
`buildFHSUserEnvChroot` and `buildFHSUserEnvBubblewrap`.

This can help to make it more clear to end-users to see the versions of
the packages they are using.
  • Loading branch information
cdepillabout committed Mar 2, 2023
1 parent de40816 commit 23ee769
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
8 changes: 7 additions & 1 deletion pkgs/build-support/build-fhs-userenv-bubblewrap/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

args @ {
name
, version ? null
, runScript ? "bash"
, extraInstallCommands ? ""
, meta ? {}
Expand All @@ -24,6 +25,7 @@ let
env = buildFHSEnv (removeAttrs args [
"runScript" "extraInstallCommands" "meta" "passthru" "extraBwrapArgs" "dieWithParent"
"unshareUser" "unshareCgroup" "unshareUts" "unshareNet" "unsharePid" "unshareIpc"
"version"
]);

etcBindFlags = let
Expand Down Expand Up @@ -192,7 +194,11 @@ let

bin = writeShellScriptBin name (bwrapCmd { initArgs = ''"$@"''; });

in runCommandLocal name {
versionStr = lib.optionalString (! isNull version) ("-" + version);

nameAndVersion = name + versionStr;

in runCommandLocal nameAndVersion {
inherit meta;

passthru = passthru // {
Expand Down
12 changes: 8 additions & 4 deletions pkgs/build-support/build-fhs-userenv/default.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{ callPackage, runCommandLocal, writeScript, stdenv, coreutils }:
{ lib, callPackage, runCommandLocal, writeScript, stdenv, coreutils }:

let buildFHSEnv = callPackage ./env.nix { }; in

args@{ name, runScript ? "bash", extraInstallCommands ? "", meta ? {}, passthru ? {}, ... }:
args@{ name, version ? null, runScript ? "bash", extraInstallCommands ? "", meta ? {}, passthru ? {}, ... }:

let
env = buildFHSEnv (removeAttrs args [ "runScript" "extraInstallCommands" "meta" "passthru" ]);
env = buildFHSEnv (removeAttrs args [ "version" "runScript" "extraInstallCommands" "meta" "passthru" ]);

chrootenv = callPackage ./chrootenv {};

Expand All @@ -23,7 +23,11 @@ let
exec ${run} "$@"
'';

in runCommandLocal name {
versionStr = lib.optionalString (! isNull version) ("-" + version);

nameAndVersion = name + versionStr;

in runCommandLocal nameAndVersion {
inherit meta;

passthru = passthru // {
Expand Down

0 comments on commit 23ee769

Please sign in to comment.