discord: Fix sandbox and desktop item
This commit is contained in:
parent
66ddcf0270
commit
c093b10729
@ -38,13 +38,16 @@ in mkHost config {
|
||||
vfio-isolate # Custom Package
|
||||
steam
|
||||
discord-system-electron-wrapped # Custom package
|
||||
discord-wrapper # Custom package
|
||||
superpaper # Custom package
|
||||
mumble
|
||||
piper
|
||||
trackma
|
||||
];
|
||||
extraOptions = old: {
|
||||
programs.mpv.primaryScreen = "C27F398";
|
||||
programs = {
|
||||
mpv.primaryScreen = "C27F398";
|
||||
adb.enable = true;
|
||||
};
|
||||
|
||||
# TODO: Move to virtualisation/gaming.nix
|
||||
# Allow scream to connect to this host
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
lib, stdenv, pkgs
|
||||
, makeDesktopItem
|
||||
, extraStartupArgs ? ""
|
||||
}:
|
||||
|
||||
@ -8,7 +9,7 @@ pkgs.discord.overrideAttrs (old: let
|
||||
gtk3 = pkgs.gtk3;
|
||||
binaryName = "Discord";
|
||||
system-electron = "$out/opt/${binaryName}/system-electron.sh";
|
||||
in {
|
||||
in rec {
|
||||
nativeBuildInputs = with pkgs; old.nativeBuildInputs ++ [ electron asar ];
|
||||
buildPhase = ''
|
||||
${asar}/bin/asar e resources/app.asar resources/app
|
||||
@ -35,7 +36,6 @@ pkgs.discord.overrideAttrs (old: let
|
||||
# Without || true the install would fail on case-insensitive filesystems
|
||||
ln -s ${system-electron} $out/bin/${lib.strings.toLower binaryName} || true
|
||||
ln -s $out/opt/${binaryName}/discord.png $out/share/pixmaps/${old.pname}.png
|
||||
ln -s "${old.desktopItem}/share/applications" $out/share/
|
||||
'';
|
||||
desktopItem = null;
|
||||
desktopItem = null;
|
||||
})
|
||||
|
@ -1,11 +0,0 @@
|
||||
{ stdenv, lib, makeDesktopItem, discord }:
|
||||
|
||||
makeDesktopItem {
|
||||
name = "Discord";
|
||||
exec = "${discord}/bin/Discord";
|
||||
icon = "discord";
|
||||
comment = "All-in-one voice and text chat for gamers that's free, secure, and works on both your desktop and phone.";
|
||||
genericName = "Internet Messenger";
|
||||
desktopName = "Discord";
|
||||
categories = "Network;InstantMessaging;";
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
{ writeScript, runtimeShell, buildFHSUserEnvBubblewrap, discord }:
|
||||
|
||||
buildFHSUserEnvBubblewrap {
|
||||
name = "discord";
|
||||
runScript = ''
|
||||
#!${runtimeShell}
|
||||
exec ${discord}/bin/Discord $@
|
||||
'';
|
||||
|
||||
specifyHomeDirs = true;
|
||||
mountInHome = ".config/discord";
|
||||
additionalBlacklist = [ "/mnt" ];
|
||||
chdirTo = "/home/$USER";
|
||||
}
|
@ -10,10 +10,7 @@ let
|
||||
# NOTE: electron under Wayland has no window titlebars
|
||||
#extraStartupArgs = "--enable-features=UseOzonePlatform --ozone-platform=wayland";
|
||||
};
|
||||
discord-system-electron-wrapped = pkgs.callPackage ./applications/networking/instant-messengers/discord/wrapped.nix {
|
||||
buildFHSUserEnvBubblewrap = buildFHSUserEnvBubblewrap;
|
||||
discord = discord-system-electron;
|
||||
};
|
||||
wrapInSandbox = pkgs.callPackage ./sandbox.nix {};
|
||||
in {
|
||||
gamemode = pkgs.callPackage ./tools/games/gamemode { };
|
||||
key-mapper = pkgs.callPackage ./tools/games/key-mapper {};
|
||||
@ -39,12 +36,27 @@ in {
|
||||
superpaper = pkgs.callPackage ./applications/desktop/superpaper {
|
||||
system_hotkey = system_hotkey;
|
||||
};
|
||||
discord-system-electron = discord-system-electron;
|
||||
discord-system-electron-wrapped = discord-system-electron-wrapped;
|
||||
discord-wrapper = pkgs.callPackage ./applications/networking/instant-messengers/discord/desktop.nix {
|
||||
discord = discord-system-electron-wrapped;
|
||||
discord-system-electron-wrapped = wrapInSandbox "${discord-system-electron}/bin/discord" {
|
||||
name = "discord";
|
||||
mountInHome = [ ".config/discord" ];
|
||||
additionalBlacklist = [ "/mnt" ];
|
||||
chdirTo = "/home/$USER";
|
||||
|
||||
pkg = discord-system-electron;
|
||||
version = "1.0.1";
|
||||
copyIntoSandbox = [ "share/pixmaps" ];
|
||||
desktopFileArgs = {
|
||||
name = "Discord (wrapped)";
|
||||
#exec = "discord";
|
||||
icon = "discord";
|
||||
desktopName = "Discord (wrapped)";
|
||||
genericName = "Instant Messenger";
|
||||
categories = "Network;InstantMessaging;";
|
||||
};
|
||||
};
|
||||
|
||||
iptsd = pkgs.callPackage ./tools/daemons/iptsd {};
|
||||
surface-control = pkgs.callPackage ./tools/system/surface-control {};
|
||||
|
||||
trackma = pkgs.callPackage ./tools/video/trackma {};
|
||||
}
|
||||
|
@ -1,11 +1,15 @@
|
||||
{
|
||||
stdenv, lib
|
||||
, runCommandLocal, writeShellScriptBin
|
||||
, runCommandLocal, writeShellScriptBin, makeDesktopItem
|
||||
, bubblewrap, coreutils, glibc, pkgsi686Linux
|
||||
}:
|
||||
|
||||
runScript: {
|
||||
name
|
||||
, version ? "1.0.0"
|
||||
, desktopFileArgs ? {}
|
||||
, pkg ? null
|
||||
, copyIntoSandbox ? []
|
||||
, unshareUser ? true
|
||||
, unshareIpc ? true
|
||||
, unsharePid ? true
|
||||
@ -91,7 +95,7 @@ let
|
||||
extraEnvString = lib.foldl (acc: val: acc + val + "\n") "" (lib.mapAttrsToList (name: value: "--setenv ${name} \"${value}\"") extraEnv);
|
||||
mountHome = mountInHome == [];
|
||||
bwrapCmd = { initArgs ? "" }: ''
|
||||
blacklist=(/nix /dev /proc /etc ${lib.optionalString mountHome "/home"} ${builtins.toString additionalBlacklist})
|
||||
blacklist=(/nix /dev /proc /etc ${lib.optionalString (!mountHome) "/home"} ${builtins.toString additionalBlacklist})
|
||||
ro_mounts=()
|
||||
symlinks=()
|
||||
|
||||
@ -157,9 +161,12 @@ let
|
||||
exec "''${cmd[@]}"
|
||||
'';
|
||||
bin = writeShellScriptBin name (bwrapCmd { initArgs = ''"$@"''; });
|
||||
desktopItem = makeDesktopItem (desktopFileArgs // {
|
||||
exec = "${bin}/bin/${name}";
|
||||
});
|
||||
in stdenv.mkDerivation {
|
||||
pname = "${name}-sandboxed";
|
||||
version = "1.0.0";
|
||||
version = version;
|
||||
|
||||
unpackPhase = ":";
|
||||
dontBuild = true;
|
||||
@ -167,5 +174,7 @@ in stdenv.mkDerivation {
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
ln -s ${bin}/bin/${name} $out/bin/${name}
|
||||
'';
|
||||
mkdir -p $out/share/
|
||||
cp -r ${desktopItem}/share/applications $out/share
|
||||
'' + (lib.concatStrings (map (x: "cp -Lr ${pkg}/${x} $out/${x}\n") copyIntoSandbox));
|
||||
}
|
Loading…
Reference in New Issue
Block a user