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.
This commit is contained in:
Dennis Gosnell 2023-03-02 10:07:06 +09:00
parent de408167ed
commit 23ee769358
No known key found for this signature in database
GPG key ID: 462E0C03D11422F4
2 changed files with 15 additions and 5 deletions

View file

@ -2,6 +2,7 @@
args @ {
name
, version ? null
, runScript ? "bash"
, extraInstallCommands ? ""
, meta ? {}
@ -24,6 +25,7 @@ let
env = buildFHSEnv (removeAttrs args [
"runScript" "extraInstallCommands" "meta" "passthru" "extraBwrapArgs" "dieWithParent"
"unshareUser" "unshareCgroup" "unshareUts" "unshareNet" "unsharePid" "unshareIpc"
"version"
]);
etcBindFlags = let
@ -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 // {

View file

@ -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 {};
@ -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 // {