-
-
Save mexisme/05f862660b04dd24387f862d96305918 to your computer and use it in GitHub Desktop.
chrome-remote-desktop on nixos/nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ config, lib, pkgs, ...}: | |
with lib; | |
let | |
cfg = config.services.crd; | |
in { | |
options = { | |
services.crd = { | |
enable = mkEnableOption '' | |
chrome remote desktop, a service which allows for remote control of your desktop from anywhere. | |
''; | |
user = mkOption { | |
type = types.submodule; | |
description = '' | |
A user which the service will run as. | |
''; | |
example = "users.users.alice"; | |
}; | |
screenSize = mkOption { | |
type = types.string; | |
description = '' | |
Size of the screen (for all clients) | |
''; | |
default = "1366x768"; | |
example = "1920x1080"; | |
}; | |
session = mkOption { | |
type = types.string; | |
description = '' | |
The X session that chrome remote desktop will control | |
''; | |
example = "gnome-session"; | |
}; | |
}; | |
}; | |
config = mkIf cfg.enable { | |
systemd.services.chrome-remote-desktop = { | |
description = "Chrome remote desktop service"; | |
path = with pkgs; [ sudo chrome-remote-desktop ]; | |
script = '' | |
sudo -u ${cfg.user.name} ${pkgs.chrome-remote-desktop}/opt/google/chrome-remote-desktop --start --size=${cfg.screenSize} | |
''; | |
}; | |
security.wrappers.crd-user-session.source = "${pkgs.chrome-remote-desktop}/opt/google/chrome-remote-desktop/user-session"; | |
system.activationScripts.crd-setup = { | |
text = '' | |
if [[ -z $(cat ${cfg.user.home}/.chrome-remote-desktop-session) ]]; then | |
# Create the file | |
echo "export $(dbus-launch)" > ${cfg.user.home}/.chrome-remote-desktop-session | |
echo "exec ${cfg.session}" >> ${cfg.user.home}/.chrome-remote-desktop-session | |
fi | |
''; | |
}; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ stdenv, lib, fetchurl, fetchgit, dpkg, python2, glibc, glib, pam, nss, nspr, expat, gnome3, xorg, fontconfig, dbus_daemon, alsaLib }: | |
stdenv.mkDerivation rec { | |
name = "chrome-remote-desktop"; | |
src = fetchurl { | |
sha256 = "d18baa7033d80cf458ffec808dacce11d737bf31e81f25884221867c8c6a3001"; | |
url = "https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb"; | |
}; | |
unpackPhase = '' | |
${dpkg}/bin/dpkg -x $src $out | |
''; | |
installPhase = '' | |
''; | |
patchPhase = '' | |
sed \ | |
-e '/^.*sudo_command =/ s/"gksudo .*"/"pkexec"/' \ | |
-e '/^.*command =/ s/s -- sh -c/s sh -c/' \ | |
-i $out/opt/google/chrome-remote-desktop/chrome-remote-desktop | |
substituteInPlace $out/opt/google/chrome-remote-desktop/chrome-remote-desktop --replace /usr/bin/python2 ${python2.withPackages (ps: with ps;[ psutil ])}/bin/python2 | |
''; | |
preFixup = let | |
libPath = lib.makeLibraryPath [glib pam nss nspr expat gnome3.gtk gnome3.gconf xorg.libXext xorg.libX11 xorg.libXcomposite xorg.libXrender xorg.libXrandr xorg.libXcursor xorg.libXdamage xorg.libXfixes xorg.libXi xorg.libXtst fontconfig xorg.libXScrnSaver dbus_daemon.lib alsaLib]; | |
in '' | |
for i in $out/opt/google/$name/{chrome-remote-desktop-host,start-host,native-messaging-host,remote-assistance-host,user-session}; do | |
patchelf --set-rpath "${libPath}" $i | |
patchelf --set-interpreter ${glibc}/lib/ld-linux-x86-64.so.2 $i | |
done | |
''; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment