···
wrappedBins = pkgs.runCommand "firejail-wrapped-binaries"
{ preferLocalBuild = true;
allowSubstitutes = false;
+
# take precedence over non-firejailed versions
+
mkdir -p $out/share/applications
${lib.concatStringsSep "\n" (lib.mapAttrsToList (command: value:
opts = if builtins.isAttrs value
+
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}
+
${lib.optionalString (opts.desktop != null) ''
+
substitute ${opts.desktop} $out/share/applications/$(basename ${opts.desktop}) \
+
--replace ${opts.executable} $out/bin/${command}
'') cfg.wrappedBinaries)}
···
description = lib.mdDoc "Executable to run sandboxed";
example = literalExpression ''"''${lib.getBin pkgs.firefox}/bin/firefox"'';
+
type = types.nullOr types.path;
+
description = lib.mkDoc ".desktop file to modify. Only necessary if it uses the absolute path to the executable.";
+
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.