diff --git a/hosts/muos/configuration.nix b/hosts/muos/configuration.nix index cf53d8d..ecab64d 100644 --- a/hosts/muos/configuration.nix +++ b/hosts/muos/configuration.nix @@ -155,26 +155,19 @@ ) automapaper-configs; in { - # "autostart/spotify.desktop".source = config.lib.file.mkOutOfStoreSymlink ""; - "niri/config.kdl".source = pkgs.substituteAll { - src = ../../extra/niri.kdl; - env = { - kitty = "${pkgs.kitty}/bin/kitty"; - launcher = "${spkgs.fuzzel-launch}/bin/fuzzel-launch"; - powermenu = "${spkgs.fuzzel-power}/bin/fuzzel-power"; - swaylock = "${pkgs.swaylock}/bin/swaylock"; - automapaper = automapaper; - spotify = "spotify"; - keepass = "keepassxc"; - thunderbird = "thunderbird"; - appbar = "${pkgs.waybar}/bin/waybar"; - extra = - "spawn-at-startup \"" - + lib.strings.concatStringsSep "\nspawn-at-startup \"" [ - "${pkgs.dunst}/bin/dunst\"" - "${pkgs.xwayland-satellite}/bin/xwayland-satellite\"" - ]; - }; + "niri/config.kdl".source = import ../../packages/niri-config/default.nix { + pkgs = pkgs; + self-pkgs = spkgs; + inputs = inputs; + displays = [ + { + name = "eDP-1"; + horizontal-resolution = 2256; + horizontal-position = 0; + vertical-resolution = 1504; + framerate = "59.999"; + } + ]; }; }; }; diff --git a/packages/niri-config/default.nix b/packages/niri-config/default.nix new file mode 100644 index 0000000..f4055a1 --- /dev/null +++ b/packages/niri-config/default.nix @@ -0,0 +1,95 @@ +{ + pkgs, + self-pkgs, + inputs, + displays, +}: +let + terminal = "${pkgs.kitty}/bin/kitty"; + launcher = "${self-pkgs.fuzzel-launch}/bin/fuzzel-launch"; + power-menu = "${self-pkgs.fuzzel-power}/bin/fuzzel-power"; + lockscreen = "${pkgs.swaylock}/bin/swaylock"; + wallpapers = + let + automapaper-configs = builtins.map ( + { + name, + horizontal-resolution, + vertical-resolution, + }: + let + display-shader = pkgs.substituteAll { + src = ../../modules/automapaper/display-with_vars.glsl; + background = inputs.nix-colors.lib.conversions.hexToGLSLVec "101012"; + 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 + name + tps + cycles + ; + horizontal = builtins.div horizontal-resolution horizontal-dot-size; + vertical = builtins.div vertical-resolution vertical-dot-size; + }) + ) displays; + in + pkgs.lib.strings.concatMapStringsSep "\n" ( + file: + ''spawn-at-startup "${ + inputs.automapaper.packages.${pkgs.system}.automapaper + }/bin/automapaper" "-C" "${file}/config.toml"'' + ) automapaper-configs; + autostart-string = + "spawn-at-startup \"" + + pkgs.lib.strings.concatStringsSep "\nspawn-at-startup \"" [ + "${pkgs.dunst}/bin/dunst\"" + "${pkgs.xwayland-satellite}/bin/xwayland-satellite\"" + "spotify\"" + "keepassxc\"" + "thunderbird\"" + "${pkgs.waybar}/bin/waybar\"" + ]; + + displays-string = pkgs.lib.strings.concatMapStringsSep "\n" ( + { + name, + horizontal-resolution, + vertical-resolution, + framerate, + horizontal-position, + }: + '' + output "${name}" { + mode "${builtins.toString horizontal-resolution}x${builtins.toString vertical-resolution}@${framerate}" + scale 1 + transform "normal" + position x=${builtins.toString horizontal-position} y=0 + } + '' + ) displays; +in +pkgs.substituteAll { + src = ./template.kdl; + terminal = terminal; + launcher = launcher; + power_menu = power-menu; + lockscreen = lockscreen; + wallpapers = wallpapers; + + displays = displays-string; + autostart = autostart-string; +} diff --git a/extra/niri.kdl b/packages/niri-config/template.kdl similarity index 97% rename from extra/niri.kdl rename to packages/niri-config/template.kdl index 7383d92..c3f650c 100644 --- a/extra/niri.kdl +++ b/packages/niri-config/template.kdl @@ -23,12 +23,7 @@ input { focus-follows-mouse max-scroll-amount="40%" } -output "eDP-1" { - mode "2256x1504@59.999" - scale 1 - transform "normal" - position x=0 y=0 -} +@displays@ layout { // Set gaps around windows in logical pixels. @@ -120,11 +115,7 @@ layout { // which may be more convenient to use. // See the binds section below for more spawn examples. // spawn-at-startup "alacritty" "-e" "fish" -@automapaper@ -spawn-at-startup "@spotify@" -spawn-at-startup "@keepass@" -spawn-at-startup "@thunderbird@" -spawn-at-startup "@appbar@" +@wallpapers@ @extra@ @@ -226,10 +217,10 @@ binds { Mod+Shift+Slash { show-hotkey-overlay; } // Suggested binds for running programs: terminal, app launcher, screen locker. - Mod+Return { spawn "@kitty@"; } + Mod+Return { spawn "@terminal@"; } Mod+Space { spawn "@launcher@"; } - Mod+P { spawn "@powermenu@"; } - Super+Alt+L { spawn "@swaylock@"; } + Mod+P { spawn "@power_menu@"; } + Super+Alt+L { spawn "@lockscreen@"; } // You can also use a shell. Do this if you need pipes, multiple commands, etc. // Note: the entire command goes as a single argument in the end.