module.nix: use sway as graphical backend

This commit is contained in:
Oystein Kristoffer Tveit 2024-10-19 23:26:16 +02:00
parent c1438f2480
commit a52f2a2e49
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
1 changed files with 59 additions and 19 deletions

View File

@ -10,6 +10,10 @@ in
mpvPackage = lib.mkPackageOption pkgs "mpv" { }; mpvPackage = lib.mkPackageOption pkgs "mpv" { };
enableSway = lib.mkEnableOption "sway as the main window manager";
enablePipewire = lib.mkEnableOption "pipewire" // { default = true; };
# TODO: create some better descriptions # TODO: create some better descriptions
settings = { settings = {
host = lib.mkOption { host = lib.mkOption {
@ -75,24 +79,60 @@ in
}; };
}; };
config = { config = lib.mkMerge [
services.cage.enable = true; (lib.mkIf cfg.enable {
services.cage.program =let users = {
flags = lib.cli.toGNUCommandLineShell { } cfg.settings; users.greg = {
in pkgs.writeShellScript "greg-kiosk" '' isNormalUser = true;
cd $(mktemp -d) group = "greg";
uid = 2000;
${lib.getExe cfg.package} ${flags} description = "loud gym bro";
''; };
services.cage.user = "greg"; groups.greg.gid = 2000;
users.users."greg".isNormalUser = true;
system.activationScripts = {
base-dirs = {
text = ''
mkdir -p /nix/var/nix/profiles/per-user/greg
'';
deps = [];
}; };
};
}; systemd.user.services.greg-ng = {
description = "greg-ng, an mpv based media player";
wantedBy = [ "graphical-session.target" ];
partOf = [ "graphical-session.target" ];
serviceConfig = {
Type = "simple";
ExecStart = "${lib.getExe cfg.package} ${lib.cli.toGNUCommandLineShell { } cfg.settings}";
Restart = "always";
RestartSec = 3;
};
};
})
(lib.mkIf (cfg.enable && cfg.enablePipewire) {
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
})
(lib.mkIf (cfg.enable && cfg.enableSway) {
programs.sway = {
enable = true;
wrapperFeatures.gtk = true;
};
xdg.portal = {
enable = true;
wlr.enable = true;
extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
};
services.greetd = {
enable = true;
settings = rec {
initial_session = {
command = "${pkgs.sway}/bin/sway";
user = "greg";
};
default_session = initial_session;
};
};
})
];
} }