forked from pub-solar/os
Compare commits
9 commits
main
...
feature/wa
Author | SHA1 | Date | |
---|---|---|---|
Hendrik Sokolowski | 2d213d4dbd | ||
Hendrik Sokolowski | 9aafa7ff52 | ||
Hendrik Sokolowski | 67e90032c4 | ||
Benjamin Bädorf | 48a1267b4e | ||
Benjamin Bädorf | 3b3c6ec0e1 | ||
Benjamin Bädorf | 1ce4d74637 | ||
Benjamin Bädorf | a2d7196cd9 | ||
Benjamin Bädorf | ae7bee47df | ||
Benjamin Bädorf | 06ca86f9c9 |
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:
|
pkgs:
|
||||||
{
|
{
|
||||||
Unit = {
|
Unit = {
|
||||||
Description = "sway - SirCmpwn's Wayland window manager";
|
Description = "Headless sway - SirCmpwn's Wayland window manager";
|
||||||
Documentation = [ "man:sway(5)" ];
|
Documentation = [ "man:sway(5)" ];
|
||||||
BindsTo = [ "graphical-session.target" ];
|
BindsTo = [ "graphical-session.target" ];
|
||||||
Wants = [ "graphical-session-pre.target" ];
|
Wants = [ "graphical-session-pre.target" ];
|
||||||
After = [ "graphical-session-pre.target" ];
|
After = [ "graphical-session-pre.target" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
Service = {
|
Service = {
|
||||||
Type = "simple";
|
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";
|
Restart = "on-failure";
|
||||||
RestartSec = "1";
|
RestartSec = "1";
|
||||||
TimeoutStopSec = "10";
|
TimeoutStopSec = "10";
|
||||||
ExecStopPost = "${pkgs.systemd}/bin/systemctl --user unset-environment SWAYSOCK DISPLAY I3SOCK WAYLAND_DISPLAY";
|
ExecStopPost = "${pkgs.systemd}/bin/systemctl --user unset-environment SWAYSOCK DISPLAY I3SOCK WAYLAND_DISPLAY";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Install = {
|
||||||
|
WantedBy = [ "sway-session.target" ];
|
||||||
|
};
|
||||||
}
|
}
|
20
modules/headless-graphical/wayvnc.service.nix
Normal file
20
modules/headless-graphical/wayvnc.service.nix
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
pkgs:
|
||||||
|
{
|
||||||
|
Unit = {
|
||||||
|
Description = "A VNC server for wlroots based Wayland compositors ";
|
||||||
|
Documentation = "https://github.com/any1/wayvnc";
|
||||||
|
BindsTo = [ "sway-session.target" ];
|
||||||
|
After = [ "graphical-session-pre.target" "network-online.target" ];
|
||||||
|
Wants = [ "graphical-session-pre.target" "network-online.target" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
Service = {
|
||||||
|
Type = "simple";
|
||||||
|
Environment = "WAYLAND_DISPLAY=wayland-1";
|
||||||
|
ExecStart = "${pkgs.wayvnc}/bin/wayvnc --render-cursor --unix-socket /run/wayvnc.sock";
|
||||||
|
};
|
||||||
|
|
||||||
|
Install = {
|
||||||
|
WantedBy = [ "sway-session.target" ];
|
||||||
|
};
|
||||||
|
}
|
|
@ -47,3 +47,11 @@ mode "$mode_system" {
|
||||||
bindsym Return mode "default"
|
bindsym Return mode "default"
|
||||||
bindsym Escape mode "default"
|
bindsym Escape mode "default"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set $mode_vncclient In VNCClient mode. Press $mod+Num_Lock or $mod+Shift+Escape to return.
|
||||||
|
bindsym $mod+Num_Lock mode "$mode_vncclient"
|
||||||
|
bindsym $mod+Shift+Escape mode "$mode_vncclient"
|
||||||
|
mode "$mode_vncclient" {
|
||||||
|
bindsym $mod+Num_Lock mode "default"
|
||||||
|
bindsym $mod+Shift+Escape mode "default"
|
||||||
|
}
|
||||||
|
|
8
modules/sway/config/wayvnc/config.nix
Normal file
8
modules/sway/config/wayvnc/config.nix
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{ psCfg, pkgs }: "
|
||||||
|
address=0.0.0.0
|
||||||
|
enable_auth=true
|
||||||
|
username=${psCfg.user.name}
|
||||||
|
password=testtest
|
||||||
|
private_key_file=/run/agenix/vnc-key.pem
|
||||||
|
certificate_file=/run/agenix/vnc-cert.pem
|
||||||
|
"
|
|
@ -3,20 +3,27 @@ with lib;
|
||||||
let
|
let
|
||||||
psCfg = config.pub-solar;
|
psCfg = config.pub-solar;
|
||||||
cfg = config.pub-solar.sway;
|
cfg = config.pub-solar.sway;
|
||||||
|
headlessCfg = config.pub-solar.sway-headless;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.pub-solar.sway = {
|
options.pub-solar.sway = {
|
||||||
enable = mkEnableOption "Life in boxes";
|
enable = mkEnableOption "Life in boxes";
|
||||||
|
|
||||||
|
terminal = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "alacritty";
|
||||||
|
description = "Choose sway's default terminal";
|
||||||
|
};
|
||||||
|
|
||||||
|
v4l2loopback.enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = "WebCam streaming tool";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
options.pub-solar.sway.terminal = mkOption {
|
|
||||||
type = types.nullOr types.str;
|
options.pub-solar.sway-headless = {
|
||||||
default = "alacritty";
|
enable = mkEnableOption "Enable headless sway and vnc service";
|
||||||
description = "Choose sway's default terminal";
|
|
||||||
};
|
|
||||||
options.pub-solar.sway.v4l2loopback.enable = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = true;
|
|
||||||
description = "WebCam streaming tool";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
|
@ -26,13 +33,12 @@ in
|
||||||
boot.extraModprobeConfig = ''
|
boot.extraModprobeConfig = ''
|
||||||
options v4l2loopback exclusive_caps=1 devices=3
|
options v4l2loopback exclusive_caps=1 devices=3
|
||||||
'';
|
'';
|
||||||
})
|
|
||||||
|
|
||||||
({
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
linuxPackages.v4l2loopback
|
linuxPackages.v4l2loopback
|
||||||
];
|
];
|
||||||
|
})
|
||||||
|
|
||||||
|
({
|
||||||
programs.sway.enable = true;
|
programs.sway.enable = true;
|
||||||
|
|
||||||
xdg.portal = {
|
xdg.portal = {
|
||||||
|
@ -98,6 +104,7 @@ in
|
||||||
xdg.configFile."sway/config.d/custom-keybindings.conf".source = ./config/config.d/custom-keybindings.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/applications.conf".source = ./config/config.d/applications.conf;
|
||||||
xdg.configFile."sway/config.d/systemd.conf".source = ./config/config.d/systemd.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; };
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -41,6 +41,7 @@ in
|
||||||
type = types.nullOr types.str;
|
type = types.nullOr types.str;
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
|
autologin = mkEnableOption "Autologin the pub solar user on all TTYs";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let cfg = config.pub-solar.x-os;
|
let
|
||||||
|
psCfg = config.pub-solar;
|
||||||
|
cfg = psCfg.x-os;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.pub-solar.x-os = {
|
options.pub-solar.x-os = {
|
||||||
|
@ -34,21 +36,51 @@ in
|
||||||
|
|
||||||
# These entries get added to /etc/hosts
|
# These entries get added to /etc/hosts
|
||||||
networking.hosts = {
|
networking.hosts = {
|
||||||
"127.0.0.1" = [ "cups.local" ];
|
"127.0.0.1" = mkIf psCfg.printing.enable [ "cups.local" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
# Caddy reverse proxy for local services like cups
|
# ha reverse proxy for local services like cups
|
||||||
services.caddy = {
|
services.haproxy.enable = true;
|
||||||
enable = true;
|
services.haproxy.config = ''
|
||||||
config = ''
|
global
|
||||||
{
|
maxconn 4096
|
||||||
auto_https off
|
# user http
|
||||||
}
|
# group http
|
||||||
cups.local:80
|
daemon
|
||||||
bind 127.0.0.1
|
|
||||||
request_header Host localhost:631
|
defaults
|
||||||
reverse_proxy unix//run/cups/cups.sock
|
log global
|
||||||
'';
|
mode http
|
||||||
};
|
option httplog
|
||||||
|
option dontlognull
|
||||||
|
retries 3
|
||||||
|
option redispatch
|
||||||
|
maxconn 2000
|
||||||
|
timeout connect 5000
|
||||||
|
timeout client 50000
|
||||||
|
timeout server 50000
|
||||||
|
log 127.0.0.1 local0
|
||||||
|
log 127.0.0.1 local7 debug
|
||||||
|
option httpchk
|
||||||
|
|
||||||
|
frontend http
|
||||||
|
bind 0.0.0.0:80
|
||||||
|
|
||||||
|
acl is_cups hdr_end(host) -i cups.local
|
||||||
|
acl is_local dst 127.0.0.1
|
||||||
|
|
||||||
|
use_backend cups if is_cups is_local
|
||||||
|
|
||||||
|
frontend vnc
|
||||||
|
bind 0.0.0.0:5901
|
||||||
|
mode tcp
|
||||||
|
use_backend vnc
|
||||||
|
|
||||||
|
backend cups
|
||||||
|
server cups unix@/run/cups/cups.sock
|
||||||
|
|
||||||
|
backend vnc
|
||||||
|
server vnc unix@/run/wayvnc.sock
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue