77 lines
2 KiB
Nix
77 lines
2 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
let
|
|
cfg = config.local.programs.communication.telegram;
|
|
|
|
hostRunPackage = pkgs.writeScript "cont-run" ''
|
|
sudo nixos-container run telegram -- su -l jan -c "$*"
|
|
'';
|
|
|
|
hostPackageScript = pkgs.writeScriptBin "${cfg.package.meta.mainProgram}" ''
|
|
${hostRunPackage} ${cfg.package.meta.mainProgram} $@
|
|
'';
|
|
|
|
hostTelegram = pkgs.runCommand "${cfg.package.meta.mainProgram}" { } ''
|
|
mkdir $out
|
|
cp -r ${hostPackageScript}/bin $out/bin
|
|
cp -r ${cfg.package}/share $out/share
|
|
'';
|
|
in
|
|
{
|
|
options.local.programs.communication.telegram = with lib; {
|
|
enable = mkEnableOption "tdesktop. telegram client";
|
|
package = mkPackageOption pkgs "tdesktop" { };
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
environment.systemPackages = [ hostTelegram ];
|
|
|
|
local.sound.systemWide = true;
|
|
|
|
containers.telegram = {
|
|
autoStart = true;
|
|
ephemeral = true;
|
|
|
|
bindMounts = lib.mkMerge [
|
|
{
|
|
"/tmp/.X11-unix" = { };
|
|
"/home/jan/downloads/telegram" = {
|
|
isReadOnly = false;
|
|
};
|
|
}
|
|
(lib.mkIf config.hardware.graphics.enable {
|
|
"/run/opengl-driver/lib" = { };
|
|
})
|
|
(lib.mkIf config.hardware.graphics.enable32Bit {
|
|
"/run/opengl-driver-32/lib" = { };
|
|
})
|
|
(lib.mkIf config.local.programs.browsers.librewolf.enable {
|
|
"/home/jan/downloads/browser" = { };
|
|
})
|
|
];
|
|
|
|
config = { pkgs, ... }: {
|
|
system.stateVersion = "23.11";
|
|
|
|
fonts = {
|
|
inherit (config.fonts) enableDefaultPackages packages;
|
|
fontconfig = { inherit (config.fonts.fontconfig) defaultFonts; };
|
|
};
|
|
|
|
users.users.jan = {
|
|
isNormalUser = true;
|
|
home = "/home/jan";
|
|
password = "hello";
|
|
extraGroups = [ "pulse-access" ];
|
|
packages = [ cfg.package ];
|
|
};
|
|
|
|
environment.sessionVariables = {
|
|
DISPLAY = ":0";
|
|
PULSE_SERVER = "tcp:127.0.0.1:4713";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|