-
Notifications
You must be signed in to change notification settings - Fork 1
/
bwrapperFHSEnv.nix
75 lines (66 loc) · 1.99 KB
/
bwrapperFHSEnv.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{ nixpkgs, pkgs, runCommandLocal, callPackage, lib, xdg-dbus-proxy, bubblewrap, coreutils }:
{ pkg-unwrapped ? null
, dbusLogging ? false
, forceAppId ? null
, renameDesktopFile ? true
, appendBwrapArgs ? [ ]
, additionalFolderPaths ? [ ]
, additionalFolderPathsReadWrite ? [ ]
, additionalSandboxPaths ? [ ]
, dbusTalks ? [ ]
, dbusOwns ? [ ]
, systemDbusTalks ? [ ]
, addPkgs ? [ ]
, overwriteExec ? false
, execArgs ? ""
, unshareIpc ? true
, unshareUser ? false
, unshareUts ? false
, unshareCgroup ? false
, unsharePid ? true
, unshareNet ? false
, dieWithParent ? true
, privateTmp ? true
, skipExtraInstallCmds ? true
}@bwrapperArgs:
{ name ? null
, pname ? null
, version ? null
, runScript ? "bash"
, extraInstallCommands ? ""
, meta ? { }
, passthru ? { }
, extraPreBwrapCmds ? ""
, extraBwrapArgs ? [ ]
, unshareUser ? false
, unshareIpc ? false
, unsharePid ? false
, unshareNet ? false
, unshareUts ? false
, unshareCgroup ? false
, privateTmp ? false
, dieWithParent ? true
, ...
} @ args:
let
mkFHSEnvArgs = callPackage ./mkFHSEnvArgs.nix { inherit nixpkgs; };
# TODO: is there a better way?
pkg = bwrapperArgs.pkg-unwrapped or (builtins.elemAt (args.targetPkgs pkgs) 0);
fhsEnvArgs = mkFHSEnvArgs (bwrapperArgs // {
inherit
runScript
pkg
# needed, because the default in this file differs from the default in mkFHSEnvArgs
skipExtraInstallCmds;
});
pname = if args ? name && args.name != null then args.name else args.pname;
versionStr = lib.optionalString (version != null) ("-" + version);
name = pname + versionStr;
in
(fhsEnvArgs.buildFHSEnv (args // (builtins.removeAttrs fhsEnvArgs [ "buildFHSEnv" ]) // {
inherit name;
targetPkgs = pkgs: ((fhsEnvArgs.targetPkgs pkgs) ++ (args.targetPkgs pkgs));
extraInstallCommands = (args.extraInstallCommands or "") + fhsEnvArgs.extraInstallCommands;
extraPreBwrapCmds = (args.extraPreBwrapCmds or "") + fhsEnvArgs.extraPreBwrapCmds;
extraBwrapArgs = (args.extraBwrapArgs or [ ]) ++ fhsEnvArgs.extraBwrapArgs;
}))