From 3d79cf4cb3934e4ea6b19da5f7f49cadc72ff8f2 Mon Sep 17 00:00:00 2001 From: Noa Aarts Date: Fri, 22 Nov 2024 20:23:31 +0100 Subject: [PATCH] make extendable using merge --- common/home.nix | 118 +++++++++++++++++++++++++----------------------- 1 file changed, 61 insertions(+), 57 deletions(-) diff --git a/common/home.nix b/common/home.nix index 5446ee1..6d75efb 100644 --- a/common/home.nix +++ b/common/home.nix @@ -156,66 +156,70 @@ in systemd.user = { enable = enableGraphical; + startServices = "sd-switch"; - services = builtins.listToAttrs ( - builtins.map ( - { - name, - horizontal, - vertical, - ... - }: - let - display_config = - let - display-shader = pkgs.substituteAll { - src = ../modules/automapaper/display-with_vars.glsl; - background = inputs.nix-colors.lib.conversions.hexToGLSLVec "0a000a"; - foreground = inputs.nix-colors.lib.conversions.hexToGLSLVec "192291"; - }; - state-shader = ../modules/automapaper/state-game_of_life.glsl; - init-shader = ../modules/automapaper/init.glsl; - # General configurations - cycles = 2000; - tps = 30; - horizontal-dot-size = 10; - vertical-dot-size = 10; - in - (import ../modules/automapaper/config.nix { - inherit (pkgs) writeTextFile; - inherit - init-shader - state-shader - display-shader - tps - cycles - ; - display = name; - horizontal = builtins.div horizontal horizontal-dot-size; - vertical = builtins.div vertical vertical-dot-size; - }); + services = lib.mkMerge [ - in - lib.attrsets.nameValuePair "automapaper-${name}" ({ - Install = { - WantedBy = [ "niri.service" ]; - }; - Unit = { - Description = "Automapaper for display ${name}"; - PartOf = "graphical-session.target"; - After = "graphical-session.target"; - Requisite = "graphical-session.target"; - }; + (builtins.listToAttrs ( + builtins.map ( + { + name, + horizontal, + vertical, + ... + }: + let + display_config = + let + display-shader = pkgs.substituteAll { + src = ../modules/automapaper/display-with_vars.glsl; + background = inputs.nix-colors.lib.conversions.hexToGLSLVec "0a000a"; + foreground = inputs.nix-colors.lib.conversions.hexToGLSLVec "192291"; + }; + state-shader = ../modules/automapaper/state-game_of_life.glsl; + init-shader = ../modules/automapaper/init.glsl; + # General configurations + cycles = 2000; + tps = 30; + horizontal-dot-size = 10; + vertical-dot-size = 10; + in + (import ../modules/automapaper/config.nix { + inherit (pkgs) writeTextFile; + inherit + init-shader + state-shader + display-shader + tps + cycles + ; + display = name; + horizontal = builtins.div horizontal horizontal-dot-size; + vertical = builtins.div vertical vertical-dot-size; + }); - Service = { - ExecStart = "${ - inputs.automapaper.packages.${pkgs.system}.automapaper - }/bin/automapaper -C ${display_config}/config.toml"; - Restart = "on-failure"; - }; - }) - ) displays - ); + in + lib.attrsets.nameValuePair "automapaper-${name}" ({ + Install = { + WantedBy = [ "niri.service" ]; + }; + Unit = { + Description = "Automapaper for display ${name}"; + PartOf = "graphical-session.target"; + After = "graphical-session.target"; + Requisite = "graphical-session.target"; + }; + + Service = { + ExecStart = "${ + inputs.automapaper.packages.${pkgs.system}.automapaper + }/bin/automapaper -C ${display_config}/config.toml"; + Restart = "on-failure"; + }; + }) + ) displays + )) + ]; }; xdg = {