WIP: VNC Module #62
73
modules/headless-graphical/default.nix
Normal file
73
modules/headless-graphical/default.nix
Normal file
|
@ -0,0 +1,73 @@
|
|||
{ lib, config, pkgs, ... }:
|
||||
with lib;
|
||||
let
|
||||
psCfg = config.pub-solar;
|
||||
cfg = config.pub-solar.headless-graphical;
|
||||
in
|
||||
{
|
||||
options.pub-solar.headless-graphical = {
|
||||
enable = mkEnableOption "Enable headless sway and VNC";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
programs.sway.enable = true;
|
||||
|
||||
xdg.portal = {
|
||||
enable = true;
|
||||
extraPortals = with pkgs; [ xdg-desktop-portal-gtk xdg-desktop-portal-wlr ];
|
||||
gtkUsePortal = true;
|
||||
};
|
||||
|
||||
services.pipewire.enable = true;
|
||||
|
||||
home-manager = with pkgs; pkgs.lib.setAttrByPath [ "users" psCfg.user.name ] {
|
||||
home.packages = with pkgs; [
|
||||
sway
|
||||
grim
|
||||
kanshi
|
||||
mako
|
||||
slurp
|
||||
swayidle
|
||||
swaylock
|
||||
swaybg
|
||||
xwayland
|
||||
|
||||
libappindicator-gtk3
|
||||
|
||||
wl-clipboard
|
||||
wf-recorder
|
||||
brightnessctl
|
||||
gammastep
|
||||
geoclue2
|
||||
xsettingsd
|
||||
ydotool
|
||||
|
||||
swaylock-bg
|
||||
sway-launcher
|
||||
import-gtk-settings
|
||||
s
|
||||
wcwd
|
||||
];
|
||||
|
||||
programs.waybar.enable = true;
|
||||
|
||||
systemd.user.services.mako = import ./mako.service.nix pkgs;
|
||||
systemd.user.services.swayidle = import ./swayidle.service.nix pkgs;
|
||||
systemd.user.services.xsettingsd = import ./xsettingsd.service.nix pkgs;
|
||||
systemd.user.services.waybar = import ./waybar.service.nix pkgs;
|
||||
systemd.user.targets.sway-session = import ./sway-session.target.nix pkgs;
|
||||
|
||||
systemd.user.services.sway-headless = mkIf cfg.vnc.enable (import ./wayvnc.service.nix pkgs);
|
||||
systemd.user.services.wayvnc = mkIf cfg.vnc.enable (import ./wayvnc.service.nix pkgs);
|
||||
|
||||
xdg.configFile."sway/config".source = ./config/config;
|
||||
xdg.configFile."sway/config.d/colorscheme.conf".source = ./config/config.d/colorscheme.conf;
|
||||
xdg.configFile."sway/config.d/theme.conf".source = ./config/config.d/theme.conf;
|
||||
xdg.configFile."sway/config.d/gaps.conf".source = ./config/config.d/gaps.conf;
|
||||
xdg.configFile."sway/config.d/custom-keybindings.conf".source = ./config/config.d/custom-keybindings.conf;
|
||||
xdg.configFile."sway/config.d/applications.conf".source = ./config/config.d/applications.conf;
|
||||
xdg.configFile."sway/config.d/systemd.conf".source = ./config/config.d/systemd.conf;
|
||||
xdg.configFile."wayvnc/config".text = import ./config/wayvnc/config.nix { inherit psCfg; inherit pkgs; };
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,18 +1,30 @@
|
|||
pkgs:
|
||||
{
|
||||
Unit = {
|
||||
Description = "sway - SirCmpwn's Wayland window manager";
|
||||
Description = "Headless sway - SirCmpwn's Wayland window manager";
|
||||
Documentation = [ "man:sway(5)" ];
|
||||
BindsTo = [ "graphical-session.target" ];
|
||||
Wants = [ "graphical-session-pre.target" ];
|
||||
After = [ "graphical-session-pre.target" ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
Type = "simple";
|
||||
ExecStart = "${pkgs.sway}/bin/sway";
|
||||
|
||||
ExecStart = "${pkgs.sway}/bin/sway --headless";
|
||||
Environment = [
|
||||
"WLR_BACKENDS=headless"
|
||||
"WLR_RENDERER=pixman"
|
||||
"WLR_LIBINPUT_NO_DEVICES=1"
|
||||
];
|
||||
|
||||
Restart = "on-failure";
|
||||
RestartSec = "1";
|
||||
TimeoutStopSec = "10";
|
||||
ExecStopPost = "${pkgs.systemd}/bin/systemctl --user unset-environment SWAYSOCK DISPLAY I3SOCK WAYLAND_DISPLAY";
|
||||
};
|
||||
|
||||
Install = {
|
||||
WantedBy = [ "sway-session.target" ];
|
||||
};
|
||||
}
|
|
@ -11,6 +11,7 @@ pkgs:
|
|||
Service = {
|
||||
Type = "simple";
|
||||
ExecStart = "${pkgs.wayvnc}/bin/wayvnc --render-cursor";
|
||||
Environment = "WAYLAND_DISPLAY=wayland-1";
|
||||
};
|
||||
|
||||
Install = {
|
|
@ -3,11 +3,11 @@ with lib;
|
|||
let
|
||||
psCfg = config.pub-solar;
|
||||
cfg = config.pub-solar.sway;
|
||||
headlessCfg = config.pub-solar.sway-headless;
|
||||
in
|
||||
{
|
||||
options.pub-solar.sway = {
|
||||
enable = mkEnableOption "Life in boxes";
|
||||
vnc.enable = mkEnableOption "Enable vnc service";
|
||||
|
||||
v4l2loopback.enable = mkOption {
|
||||
type = types.bool;
|
||||
|
@ -16,6 +16,10 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
options.pub-solar.sway-headless = {
|
||||
headless.enable = mkEnableOption "Enable headless sway and vnc service";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf (cfg.v4l2loopback.enable) {
|
||||
boot.extraModulePackages = with config.boot.kernelPackages; [ v4l2loopback ];
|
||||
|
@ -23,13 +27,12 @@ in
|
|||
boot.extraModprobeConfig = ''
|
||||
options v4l2loopback exclusive_caps=1 devices=3
|
||||
'';
|
||||
})
|
||||
|
||||
({
|
||||
environment.systemPackages = with pkgs; [
|
||||
linuxPackages.v4l2loopback
|
||||
];
|
||||
})
|
||||
|
||||
({
|
||||
programs.sway.enable = true;
|
||||
|
||||
xdg.portal = {
|
||||
|
@ -78,6 +81,7 @@ in
|
|||
systemd.user.services.waybar = import ./waybar.service.nix pkgs;
|
||||
systemd.user.targets.sway-session = import ./sway-session.target.nix pkgs;
|
||||
|
||||
systemd.user.services.sway-headless = mkIf cfg.vnc.enable (import ./wayvnc.service.nix pkgs);
|
||||
systemd.user.services.wayvnc = mkIf cfg.vnc.enable (import ./wayvnc.service.nix pkgs);
|
||||
|
||||
xdg.configFile."sway/config".source = ./config/config;
|
||||
|
|
|
@ -36,6 +36,7 @@ in
|
|||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
};
|
||||
autologin = mkEnableOption "Autologin the pub solar user on all TTYs";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue