From ac032dee39978753d6bcbd51b266c0b24e1bb9d4 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Sat, 10 Feb 2024 12:30:25 +0100 Subject: [PATCH] clanModules: add waypipe service --- clanModules/flake-module.nix | 1 + clanModules/waypipe.nix | 62 ++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 clanModules/waypipe.nix diff --git a/clanModules/flake-module.nix b/clanModules/flake-module.nix index ead765135..d618a39a2 100644 --- a/clanModules/flake-module.nix +++ b/clanModules/flake-module.nix @@ -14,5 +14,6 @@ xfce = ./xfce.nix; zt-tcp-relay = ./zt-tcp-relay.nix; localsend = ./localsend.nix; + waypipe = ./waypipe.nix; }; } diff --git a/clanModules/waypipe.nix b/clanModules/waypipe.nix new file mode 100644 index 000000000..8dde8eecb --- /dev/null +++ b/clanModules/waypipe.nix @@ -0,0 +1,62 @@ +{ pkgs +, lib +, config +, ... +}: +{ + options.clan.services.waypipe = { + enable = lib.mkEnableOption "waypipe"; + user = lib.mkOption { + type = lib.types.str; + default = "user"; + description = "User the program is run under"; + }; + command = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ + "--vsock" + "-s" + "3049" + "server" + ]; + description = "Waypipe command that will be run"; + }; + program = lib.mkOption { + type = lib.types.str; + default = lib.getExe pkgs.foot; + description = "Program that should be started"; + }; + }; + 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; + jack.enable = lib.mkDefault true; + }; + fonts.enableDefaultPackages = true; + + # User account + services.getty.autologinUser = lib.mkDefault config.clan.services.waypipe.user; + security.sudo.wheelNeedsPassword = false; + + users.users.${config.clan.services.waypipe.user} = { + isNormalUser = true; + password = ""; + extraGroups = [ "wheel" ]; + shell = "/run/current-system/sw/bin/bash"; + }; + + systemd.user.services.waypipe-passthrough = { + serviceConfig.PassEnvironment = "DISPLAY"; + script = '' + ${lib.getExe config.clanCore.clanPkgs.waypipe} \ + ${lib.concatStringsSep " " config.clan.services.waypipe.command} \ + ${config.clan.services.waypipe.program} + ''; + wantedBy = [ "default.target" ]; + }; + }; +}