Skip to content

Commit 23ee769

Browse files
committed
buildFHSUserEnv: add version arg
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.
1 parent de40816 commit 23ee769

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

pkgs/build-support/build-fhs-userenv-bubblewrap/default.nix

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
args @ {
44
name
5+
, version ? null
56
, runScript ? "bash"
67
, extraInstallCommands ? ""
78
, meta ? {}
@@ -24,6 +25,7 @@ let
2425
env = buildFHSEnv (removeAttrs args [
2526
"runScript" "extraInstallCommands" "meta" "passthru" "extraBwrapArgs" "dieWithParent"
2627
"unshareUser" "unshareCgroup" "unshareUts" "unshareNet" "unsharePid" "unshareIpc"
28+
"version"
2729
]);
2830

2931
etcBindFlags = let
@@ -192,7 +194,11 @@ let
192194

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

195-
in runCommandLocal name {
197+
versionStr = lib.optionalString (! isNull version) ("-" + version);
198+
199+
nameAndVersion = name + versionStr;
200+
201+
in runCommandLocal nameAndVersion {
196202
inherit meta;
197203

198204
passthru = passthru // {

pkgs/build-support/build-fhs-userenv/default.nix

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
{ callPackage, runCommandLocal, writeScript, stdenv, coreutils }:
1+
{ lib, callPackage, runCommandLocal, writeScript, stdenv, coreutils }:
22

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

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

77
let
8-
env = buildFHSEnv (removeAttrs args [ "runScript" "extraInstallCommands" "meta" "passthru" ]);
8+
env = buildFHSEnv (removeAttrs args [ "version" "runScript" "extraInstallCommands" "meta" "passthru" ]);
99

1010
chrootenv = callPackage ./chrootenv {};
1111

@@ -23,7 +23,11 @@ let
2323
exec ${run} "$@"
2424
'';
2525

26-
in runCommandLocal name {
26+
versionStr = lib.optionalString (! isNull version) ("-" + version);
27+
28+
nameAndVersion = name + versionStr;
29+
30+
in runCommandLocal nameAndVersion {
2731
inherit meta;
2832

2933
passthru = passthru // {

0 commit comments

Comments
 (0)