···
wrappedBins = pkgs.runCommand "firejail-wrapped-binaries"
{ preferLocalBuild = true;
allowSubstitutes = false;
11
+
# take precedence over non-firejailed versions
16
+
mkdir -p $out/share/applications
${lib.concatStringsSep "\n" (lib.mapAttrsToList (command: value:
opts = if builtins.isAttrs value
18
-
else { executable = value; profile = null; extraArgs = []; };
21
+
else { executable = value; desktop = null; profile = null; extraArgs = []; };
args = lib.escapeShellArgs (
++ (optional (opts.profile != null) "--profile=${toString opts.profile}")
cat <<_EOF >$out/bin/${command}
···
exec /run/wrappers/bin/firejail ${args} -- ${toString opts.executable} "\$@"
chmod 0755 $out/bin/${command}
34
+
${lib.optionalString (opts.desktop != null) ''
35
+
substitute ${opts.desktop} $out/share/applications/$(basename ${opts.desktop}) \
36
+
--replace ${opts.executable} $out/bin/${command}
'') cfg.wrappedBinaries)}
···
description = lib.mdDoc "Executable to run sandboxed";
example = literalExpression ''"''${lib.getBin pkgs.firefox}/bin/firefox"'';
53
+
desktop = mkOption {
54
+
type = types.nullOr types.path;
56
+
description = lib.mkDoc ".desktop file to modify. Only necessary if it uses the absolute path to the executable.";
57
+
example = literalExpression ''"''${pkgs.firefox}/share/applications/firefox.desktop"'';
type = types.nullOr types.path;
···
description = lib.mdDoc ''
Wrap the binaries in firejail and place them in the global path.
75
-
You will get file collisions if you put the actual application binary in
76
-
the global environment (such as by adding the application package to
77
-
`environment.systemPackages`), and applications started via
78
-
.desktop files are not wrapped if they specify the absolute path to the