clan-core/nixosModules/waypipe.nix

79 lines
2.1 KiB
Nix
Raw Normal View History

2024-03-17 18:48:49 +00:00
{
pkgs,
lib,
config,
...
2024-02-10 11:30:25 +00:00
}:
{
options.clan.services.waypipe = {
enable = lib.mkEnableOption "waypipe";
user = lib.mkOption {
type = lib.types.str;
default = "user";
description = "User the program is run under";
};
2024-02-13 15:02:23 +00:00
flags = lib.mkOption {
2024-02-10 11:30:25 +00:00
type = lib.types.listOf lib.types.str;
default = [
"--vsock"
"-s"
"3049"
"server"
];
2024-02-13 15:02:23 +00:00
description = "Flags that will be passed to waypipe";
2024-02-10 11:30:25 +00:00
};
2024-02-13 15:02:23 +00:00
command = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ (lib.getExe pkgs.foot) ];
description = "Commands that waypipe should run";
2024-02-10 11:30:25 +00:00
};
};
config = lib.mkIf config.clan.services.waypipe.enable {
# Waypipe needs pipewire
services.pipewire = {
enable = lib.mkDefault true;
alsa.enable = lib.mkDefault true;
alsa.support32Bit = lib.mkDefault true;
pulse.enable = lib.mkDefault true;
};
2024-02-10 12:22:16 +00:00
# General default settings
fonts.enableDefaultPackages = lib.mkDefault true;
hardware.opengl.enable = lib.mkDefault true;
2024-02-13 15:02:23 +00:00
# Assume it is run inside a clan context
2024-02-10 12:22:16 +00:00
clan.virtualisation.waypipe = lib.mkDefault true;
2024-02-10 11:30:25 +00:00
# User account
services.getty.autologinUser = lib.mkDefault config.clan.services.waypipe.user;
security.sudo.wheelNeedsPassword = false;
2024-02-15 18:33:01 +00:00
users.users.user = lib.mkIf (config.clan.services.waypipe.user == "user") {
2024-02-10 11:30:25 +00:00
isNormalUser = true;
2024-02-15 18:33:01 +00:00
uid = 1000;
2024-02-10 11:30:25 +00:00
password = "";
2024-03-17 18:48:49 +00:00
extraGroups = [
"wheel"
"video"
];
2024-02-10 11:30:25 +00:00
shell = "/run/current-system/sw/bin/bash";
};
2024-02-13 15:42:29 +00:00
systemd.user.services.waypipe = {
2024-02-10 11:30:25 +00:00
serviceConfig.PassEnvironment = "DISPLAY";
2024-02-15 08:58:56 +00:00
serviceConfig.Environment = ''
XDG_SESSION_TYPE=wayland \
NIXOS_OZONE_WL=1 \
GDK_BACKEND=wayland \
2024-02-15 08:58:56 +00:00
QT_QPA_PLATFORM=wayland \
CLUTTER_BACKEND = "wayland" \
2024-02-15 08:58:56 +00:00
SDL_VIDEODRIVER=wayland
'';
2024-02-10 11:30:25 +00:00
script = ''
2024-03-25 14:21:16 +00:00
${lib.getExe pkgs.waypipe} \
2024-02-13 15:02:23 +00:00
${lib.escapeShellArgs config.clan.services.waypipe.flags} \
${lib.escapeShellArgs config.clan.services.waypipe.command}
2024-02-10 11:30:25 +00:00
'';
wantedBy = [ "default.target" ];
};
};
}