diff options
| author | Stefan Weigl-Bosker <stefan@s00.xyz> | 2025-03-04 12:36:18 -0500 |
|---|---|---|
| committer | Stefan Weigl-Bosker <stefan@s00.xyz> | 2025-03-04 12:36:18 -0500 |
| commit | fdbeca13108fac5e5f07fb08d8b28d80ed973c1d (patch) | |
| tree | a656d95b58ee4502cb5fc5cc834a7f42d74a771d | |
| parent | cfd09f66cbd48d527f1b9ab02aec2420d3fd7ab8 (diff) | |
| download | home-fdbeca13108fac5e5f07fb08d8b28d80ed973c1d.tar.gz | |
service management wip
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | modules/default.nix | 1 | ||||
| -rw-r--r-- | modules/services/default.nix | 44 | ||||
| -rw-r--r-- | modules/sway/default.nix | 36 | ||||
| -rw-r--r-- | void/home.nix | 12 | ||||
| -rwxr-xr-x | void/services/mpd/run | 3 | ||||
| -rwxr-xr-x | void/services/pipewire/run | 3 |
7 files changed, 82 insertions, 19 deletions
@@ -22,5 +22,5 @@ nixos and home-manager configurations for various systems * os: Void Linux * hosts: Framework Laptop 13 (AMD), 51nb x2100 * kernel: [linux-zen](https://github.com/zen-kernel/zen-kernel/releases) - * prerequisites: pipewire, session manager, drivers + * prerequisites: pipewire, session manager, drivers, [turnstile](https://github.com/chimera-linux/turnstile) * `home-manager switch --impure --flake ~/home#void` (impure to pass env to [nixGL](https://github.com/nix-community/nixGL) diff --git a/modules/default.nix b/modules/default.nix index 3998fc1..f924c45 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -8,5 +8,6 @@ ./sway ./neovim ./qutebrowser + ./services ]; } diff --git a/modules/services/default.nix b/modules/services/default.nix new file mode 100644 index 0000000..7409c59 --- /dev/null +++ b/modules/services/default.nix @@ -0,0 +1,44 @@ +{ self, config, lib, pkgs, nixgl, ... }: +let + cfg = config.modules.services; + + inherit (lib) mkOption types listOf; + runFile = name: value: { + ${"service/" + name + "/run"} = { + text = value.run; + executable = true; + }; + }; +in +{ + options.modules.services = { + name = mkOption { + type = types.string; + }; + enable = mkOption { + type = types.bool; + default = false; + description = "Whether to enable the user service manager module."; + }; + services = mkOption { + description = "List of user services to run on login"; + type = types.attrsOf (types.submodule { + options = { + run = mkOption { + type = types.str; + description = "The 'run' script for the service"; + example = '' + #!/bin/sh + + exec chpst -e "$TURNSTILE_ENV_DIR" foo + ''; + }; + }; + }); + }; + }; + + config = lib.mkIf cfg.enable { + xdg.configFile = (lib.concatMapAttrs runFile cfg.services); + }; +} diff --git a/modules/sway/default.nix b/modules/sway/default.nix index 55ef601..5d81354 100644 --- a/modules/sway/default.nix +++ b/modules/sway/default.nix @@ -5,10 +5,25 @@ in { options.modules.sway = { enable = lib.mkEnableOption "sway"; - wrapWithNixGL = lib.mkEnableOption "NixGL wrapper"; + wrapWithNixGL = lib.mkEnableOption "NixGL wrapper."; terminal = lib.mkOption { type = lib.types.str; - description = "terminal command"; + description = "Terminal command."; + }; + startup = lib.mkOption { + type = lib.types.listOf (lib.types.submodule { + command = lib.mkOption { + type = lib.types.string; + description = "Command to be executed on startup."; + }; + always = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Whether to run command on each restart"; + }; + }); + default = [ ]; + description = "List of commands that sway will run on startup. This should be used only for sway specific applications"; }; }; @@ -19,14 +34,6 @@ in wayland.windowManager.sway = lib.mkIf cfg.enable { enable = true; package = if cfg.wrapWithNixGL then config.lib.nixGL.wrap pkgs.sway else pkgs.sway; -# package = c -# package = pkgs.sway; -# package = pkgs.writeShellScriptBin "sway" '' -# ${pkgs.nixgl.auto.nixGLDefault}/bin/nixGL ${pkgs.sway}/bin/sway -# ''; -# extraSessionCommands='' -# source ${pkgs.nixgl.auto.nixGLDefault}/bin/nixGL -# ''; config = rec { modifier = "Mod1"; @@ -236,14 +243,7 @@ in "--locked XF86MonBrightnessUp" = "exec lightctl -d up"; }; - startup = [ - { command = "foot -s"; } - { command = "wayneko --layer bottom --follow-pointer true --background-colour 0xcacaca --outline-colour 0x0f0f0f"; } -# { command = "pipewire"; always = true; } # TODO need to fix this instead of running a new session every time -# { command = "mpd"; } -# { command = "mpdscribble"; } -# { command = "avizo-service"; } # disable if on nixos or systemd - ]; + startup = cfg.startup; seat = { "*" = { diff --git a/void/home.nix b/void/home.nix index 78f05fc..50fdb4a 100644 --- a/void/home.nix +++ b/void/home.nix @@ -29,5 +29,17 @@ mako.enable = true; neovide.enable = true; + + services = { + enable = true; + services = { + "pipewire" = { + run = "${builtins.readFile ./services/pipewire/run}"; + }; + "mpd" = { + run = "${builtins.readFile ./services/mpd/run}"; + }; + }; + }; }; } diff --git a/void/services/mpd/run b/void/services/mpd/run new file mode 100755 index 0000000..d0c23db --- /dev/null +++ b/void/services/mpd/run @@ -0,0 +1,3 @@ +#!/bin/sh + +exec chpst -e "$TURNSTILE_ENV_DIR" mpd diff --git a/void/services/pipewire/run b/void/services/pipewire/run new file mode 100755 index 0000000..1de4c3b --- /dev/null +++ b/void/services/pipewire/run @@ -0,0 +1,3 @@ +#!/bin/sh + +exec chpst -e "$TURNSTILE_ENV_DIR" pipewire |