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
|
vfio-isolate # Custom Package
|
||||||
steam
|
steam
|
||||||
discord-system-electron-wrapped # Custom package
|
discord-system-electron-wrapped # Custom package
|
||||||
discord-wrapper # Custom package
|
|
||||||
superpaper # Custom package
|
superpaper # Custom package
|
||||||
mumble
|
mumble
|
||||||
piper
|
piper
|
||||||
|
trackma
|
||||||
];
|
];
|
||||||
extraOptions = old: {
|
extraOptions = old: {
|
||||||
programs.mpv.primaryScreen = "C27F398";
|
programs = {
|
||||||
|
mpv.primaryScreen = "C27F398";
|
||||||
|
adb.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
# TODO: Move to virtualisation/gaming.nix
|
# TODO: Move to virtualisation/gaming.nix
|
||||||
# Allow scream to connect to this host
|
# Allow scream to connect to this host
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
lib, stdenv, pkgs
|
lib, stdenv, pkgs
|
||||||
|
, makeDesktopItem
|
||||||
, extraStartupArgs ? ""
|
, extraStartupArgs ? ""
|
||||||
}:
|
}:
|
||||||
|
|
||||||
@ -8,7 +9,7 @@ pkgs.discord.overrideAttrs (old: let
|
|||||||
gtk3 = pkgs.gtk3;
|
gtk3 = pkgs.gtk3;
|
||||||
binaryName = "Discord";
|
binaryName = "Discord";
|
||||||
system-electron = "$out/opt/${binaryName}/system-electron.sh";
|
system-electron = "$out/opt/${binaryName}/system-electron.sh";
|
||||||
in {
|
in rec {
|
||||||
nativeBuildInputs = with pkgs; old.nativeBuildInputs ++ [ electron asar ];
|
nativeBuildInputs = with pkgs; old.nativeBuildInputs ++ [ electron asar ];
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
${asar}/bin/asar e resources/app.asar resources/app
|
${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
|
# Without || true the install would fail on case-insensitive filesystems
|
||||||
ln -s ${system-electron} $out/bin/${lib.strings.toLower binaryName} || true
|
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 $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
|
# NOTE: electron under Wayland has no window titlebars
|
||||||
#extraStartupArgs = "--enable-features=UseOzonePlatform --ozone-platform=wayland";
|
#extraStartupArgs = "--enable-features=UseOzonePlatform --ozone-platform=wayland";
|
||||||
};
|
};
|
||||||
discord-system-electron-wrapped = pkgs.callPackage ./applications/networking/instant-messengers/discord/wrapped.nix {
|
wrapInSandbox = pkgs.callPackage ./sandbox.nix {};
|
||||||
buildFHSUserEnvBubblewrap = buildFHSUserEnvBubblewrap;
|
|
||||||
discord = discord-system-electron;
|
|
||||||
};
|
|
||||||
in {
|
in {
|
||||||
gamemode = pkgs.callPackage ./tools/games/gamemode { };
|
gamemode = pkgs.callPackage ./tools/games/gamemode { };
|
||||||
key-mapper = pkgs.callPackage ./tools/games/key-mapper {};
|
key-mapper = pkgs.callPackage ./tools/games/key-mapper {};
|
||||||
@ -39,12 +36,27 @@ in {
|
|||||||
superpaper = pkgs.callPackage ./applications/desktop/superpaper {
|
superpaper = pkgs.callPackage ./applications/desktop/superpaper {
|
||||||
system_hotkey = system_hotkey;
|
system_hotkey = system_hotkey;
|
||||||
};
|
};
|
||||||
discord-system-electron = discord-system-electron;
|
discord-system-electron-wrapped = wrapInSandbox "${discord-system-electron}/bin/discord" {
|
||||||
discord-system-electron-wrapped = discord-system-electron-wrapped;
|
name = "discord";
|
||||||
discord-wrapper = pkgs.callPackage ./applications/networking/instant-messengers/discord/desktop.nix {
|
mountInHome = [ ".config/discord" ];
|
||||||
discord = discord-system-electron-wrapped;
|
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 {};
|
iptsd = pkgs.callPackage ./tools/daemons/iptsd {};
|
||||||
surface-control = pkgs.callPackage ./tools/system/surface-control {};
|
surface-control = pkgs.callPackage ./tools/system/surface-control {};
|
||||||
|
|
||||||
|
trackma = pkgs.callPackage ./tools/video/trackma {};
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
{
|
{
|
||||||
stdenv, lib
|
stdenv, lib
|
||||||
, runCommandLocal, writeShellScriptBin
|
, runCommandLocal, writeShellScriptBin, makeDesktopItem
|
||||||
, bubblewrap, coreutils, glibc, pkgsi686Linux
|
, bubblewrap, coreutils, glibc, pkgsi686Linux
|
||||||
}:
|
}:
|
||||||
|
|
||||||
runScript: {
|
runScript: {
|
||||||
name
|
name
|
||||||
|
, version ? "1.0.0"
|
||||||
|
, desktopFileArgs ? {}
|
||||||
|
, pkg ? null
|
||||||
|
, copyIntoSandbox ? []
|
||||||
, unshareUser ? true
|
, unshareUser ? true
|
||||||
, unshareIpc ? true
|
, unshareIpc ? true
|
||||||
, unsharePid ? true
|
, unsharePid ? true
|
||||||
@ -91,7 +95,7 @@ let
|
|||||||
extraEnvString = lib.foldl (acc: val: acc + val + "\n") "" (lib.mapAttrsToList (name: value: "--setenv ${name} \"${value}\"") extraEnv);
|
extraEnvString = lib.foldl (acc: val: acc + val + "\n") "" (lib.mapAttrsToList (name: value: "--setenv ${name} \"${value}\"") extraEnv);
|
||||||
mountHome = mountInHome == [];
|
mountHome = mountInHome == [];
|
||||||
bwrapCmd = { initArgs ? "" }: ''
|
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=()
|
ro_mounts=()
|
||||||
symlinks=()
|
symlinks=()
|
||||||
|
|
||||||
@ -157,9 +161,12 @@ let
|
|||||||
exec "''${cmd[@]}"
|
exec "''${cmd[@]}"
|
||||||
'';
|
'';
|
||||||
bin = writeShellScriptBin name (bwrapCmd { initArgs = ''"$@"''; });
|
bin = writeShellScriptBin name (bwrapCmd { initArgs = ''"$@"''; });
|
||||||
|
desktopItem = makeDesktopItem (desktopFileArgs // {
|
||||||
|
exec = "${bin}/bin/${name}";
|
||||||
|
});
|
||||||
in stdenv.mkDerivation {
|
in stdenv.mkDerivation {
|
||||||
pname = "${name}-sandboxed";
|
pname = "${name}-sandboxed";
|
||||||
version = "1.0.0";
|
version = version;
|
||||||
|
|
||||||
unpackPhase = ":";
|
unpackPhase = ":";
|
||||||
dontBuild = true;
|
dontBuild = true;
|
||||||
@ -167,5 +174,7 @@ in stdenv.mkDerivation {
|
|||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
ln -s ${bin}/bin/${name} $out/bin/${name}
|
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