diff --git a/README.md b/README.md index 06d18aca..6cd0976b 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ TODO: add directory structure info and enforce it - if there is non nix code, it will be in a `config` folder - redo docs - every module should not do anything if imported + - all nix files that represent a module should be `default.nix` (a nix file + which is imported directly can be called anything alongside `default.nix`) ## AGS diff --git a/configurations/bbsteamie/default.nix b/configurations/bbsteamie/default.nix index 61eb2afb..9cfb83f4 100644 --- a/configurations/bbsteamie/default.nix +++ b/configurations/bbsteamie/default.nix @@ -47,6 +47,7 @@ }; roles.server = { + enable = true; user = mainUser; sshd.enable = true; }; diff --git a/configurations/binto/default.nix b/configurations/binto/default.nix index a7f90ae0..7e2651f8 100644 --- a/configurations/binto/default.nix +++ b/configurations/binto/default.nix @@ -55,6 +55,7 @@ }; roles.desktop = { + enable = true; user = mainUser; ags.enable = true; @@ -65,6 +66,7 @@ }; roles.server = { + enable = true; user = mainUser; tailscale.enable = true; sshd.enable = true; diff --git a/configurations/cluster/default.nix b/configurations/cluster/default.nix index ba3e52c4..0f96f0da 100644 --- a/configurations/cluster/default.nix +++ b/configurations/cluster/default.nix @@ -58,6 +58,7 @@ in { }; roles.server = { + enable = true; user = mainUser; tailscale.enable = true; sshd.enable = true; diff --git a/configurations/homie/default.nix b/configurations/homie/default.nix index bb028706..58fa48ba 100644 --- a/configurations/homie/default.nix +++ b/configurations/homie/default.nix @@ -48,6 +48,7 @@ }; roles.server = { + enable = true; user = mainUser; tailscale.enable = true; sshd.enable = true; diff --git a/configurations/homie/modules/music/default.nix b/configurations/homie/modules/music/default.nix index 8941a487..8f376227 100644 --- a/configurations/homie/modules/music/default.nix +++ b/configurations/homie/modules/music/default.nix @@ -52,21 +52,21 @@ "ueboom.service" ]; - # Allow pulseaudio to be managed by MPD - hardware.pulseaudio = { - enable = true; + services = { + # Allow pulseaudio to be managed by MPD + pulseaudio = { + enable = true; - zeroconf = { - discovery.enable = true; - publish.enable = true; + zeroconf = { + discovery.enable = true; + publish.enable = true; + }; + + extraConfig = '' + load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 + ''; }; - extraConfig = '' - load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 - ''; - }; - - services = { upower.enable = true; mpd = { diff --git a/configurations/live-image/default.nix b/configurations/live-image/default.nix index e4ab4308..dea23623 100644 --- a/configurations/live-image/default.nix +++ b/configurations/live-image/default.nix @@ -23,6 +23,7 @@ }; roles.server = { + enable = true; user = mainUser; sshd.enable = true; }; diff --git a/configurations/nos/default.nix b/configurations/nos/default.nix index 836271a5..db5227ca 100644 --- a/configurations/nos/default.nix +++ b/configurations/nos/default.nix @@ -49,6 +49,7 @@ }; roles.server = { + enable = true; user = mainUser; tailscale.enable = true; sshd.enable = true; diff --git a/configurations/servivi/default.nix b/configurations/servivi/default.nix index 469d3aff..d6d4bb6a 100644 --- a/configurations/servivi/default.nix +++ b/configurations/servivi/default.nix @@ -62,6 +62,7 @@ }; roles.server = { + enable = true; user = mainUser; tailscale.enable = true; sshd.enable = true; diff --git a/configurations/wim/default.nix b/configurations/wim/default.nix index e6d8a88c..2f093f2a 100644 --- a/configurations/wim/default.nix +++ b/configurations/wim/default.nix @@ -65,6 +65,7 @@ }; roles.desktop = { + enable = true; user = mainUser; ags.enable = true; @@ -76,6 +77,7 @@ }; roles.server = { + enable = true; user = mainUser; tailscale.enable = true; }; diff --git a/modules/ags/hyprland.nix b/modules/ags/hyprland.nix index af2852d9..42036677 100644 --- a/modules/ags/hyprland.nix +++ b/modules/ags/hyprland.nix @@ -1,195 +1,205 @@ -self: {...}: let +self: { + lib, + osConfig, + ... +}: let inherit (self.lib.hypr) mkAnimation mkBezier mkBind mkLayerRule; + + inherit (lib) mkIf; + + cfgDesktop = osConfig.roles.desktop; in { - config.wayland.windowManager.hyprland = { - settings = { - general = { - gaps_in = 5; - gaps_out = 5; - border_size = 0; - }; - - decoration = { - rounding = 12; - - blur = { - enabled = true; - size = 3; - passes = 1; + config = mkIf cfgDesktop.ags.enable { + wayland.windowManager.hyprland = { + settings = { + general = { + gaps_in = 5; + gaps_out = 5; + border_size = 0; }; - shadow.enabled = false; - }; + decoration = { + rounding = 12; - animations = { - enabled = true; + blur = { + enabled = true; + size = 3; + passes = 1; + }; - bezier = map mkBezier [ + shadow.enabled = false; + }; + + animations = { + enabled = true; + + bezier = map mkBezier [ + { + name = "easeInQuart"; + p0 = [0.895 0.030]; + p1 = [0.685 0.220]; + } + { + name = "easeOutQuart"; + p0 = [0.165 0.840]; + p1 = [0.440 1.000]; + } + { + name = "easeInOutQuart"; + p0 = [0.770 0.000]; + p1 = [0.175 1.000]; + } + + # fade out + { + name = "easeInExpo"; + p0 = [0.950 0.050]; + p1 = [0.795 0.035]; + } + ]; + + animation = map mkAnimation [ + { + name = "workspaces"; + duration = 6; + bezier = "easeOutQuart"; + style = "slide"; + } + + { + name = "windows"; + duration = 4; + bezier = "easeOutQuart"; + style = "slide"; + } + { + name = "fadeIn"; + enable = false; + } + { + name = "fadeOut"; + duration = 4; + bezier = "easeInExpo"; + } + + { + name = "fadeLayersIn"; + enable = false; + } + { + name = "fadeLayersOut"; + duration = 4; + bezier = "easeInExpo"; + } + { + name = "layers"; + duration = 4; + bezier = "easeInOutQuart"; + style = "fade"; + } + ]; + }; + + layerrule = map mkLayerRule [ { - name = "easeInQuart"; - p0 = [0.895 0.030]; - p1 = [0.685 0.220]; + rule = "animation popin"; + namespace = "^(hyprpaper.*)"; } { - name = "easeOutQuart"; - p0 = [0.165 0.840]; - p1 = [0.440 1.000]; + rule = "animation fade"; + namespace = "^(bg-layer.*)"; } { - name = "easeInOutQuart"; - p0 = [0.770 0.000]; - p1 = [0.175 1.000]; + rule = "noanim"; + namespace = "^(noanim-.*)"; } - # fade out { - name = "easeInExpo"; - p0 = [0.950 0.050]; - p1 = [0.795 0.035]; + rule = "blur"; + namespace = "^(blur-bg.*)"; + } + { + rule = "ignorealpha 0.19"; + namespace = "^(blur-bg.*)"; } ]; - animation = map mkAnimation [ + exec-once = [ + "ags" + "sleep 3; ags request 'open win-applauncher'" + ]; + + bind = map mkBind [ { - name = "workspaces"; - duration = 6; - bezier = "easeOutQuart"; - style = "slide"; + modifier = "$mainMod SHIFT"; + key = "E"; + command = "ags toggle win-powermenu"; + } + { + modifier = "$mainMod"; + key = "D"; + command = "ags toggle win-applauncher"; + } + { + modifier = "$mainMod"; + key = "V"; + command = "ags toggle win-clipboard"; + } + { + key = "Print"; + command = "ags toggle win-screenshot"; } { - name = "windows"; - duration = 4; - bezier = "easeOutQuart"; - style = "slide"; + key = "XF86AudioMute"; + command = "pactl set-sink-mute @DEFAULT_SINK@ toggle"; } { - name = "fadeIn"; - enable = false; + key = "XF86AudioMicMute"; + command = "pactl set-source-mute @DEFAULT_SOURCE@ toggle"; } { - name = "fadeOut"; - duration = 4; - bezier = "easeInExpo"; + modifier = "$mainMod"; + key = "Print"; + command = "bash -c \"grim -g \\\"$(slurp)\\\" - | satty -f -\""; + } + ]; + + binde = map mkBind [ + { + key = "XF86MonBrightnessUp"; + command = "ags request 'Brightness.screen +0.05'"; + } + { + key = "XF86MonBrightnessDown"; + command = "ags request 'Brightness.screen -0.05'"; } { - name = "fadeLayersIn"; - enable = false; + key = "XF86AudioRaiseVolume"; + command = "wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+ & ags request 'popup speaker' &"; } { - name = "fadeLayersOut"; - duration = 4; - bezier = "easeInExpo"; + key = "XF86AudioLowerVolume"; + command = "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- & ags request 'popup speaker' &"; } + ]; + + bindn = map mkBind [ { - name = "layers"; - duration = 4; - bezier = "easeInOutQuart"; - style = "fade"; + key = "Escape"; + command = "ags request closeAll"; + } + ]; + + bindr = map mkBind [ + { + modifier = "CAPS"; + key = "Caps_Lock"; + command = "ags request fetchCapsState"; } ]; }; - - layerrule = map mkLayerRule [ - { - rule = "animation popin"; - namespace = "^(hyprpaper.*)"; - } - { - rule = "animation fade"; - namespace = "^(bg-layer.*)"; - } - { - rule = "noanim"; - namespace = "^(noanim-.*)"; - } - - { - rule = "blur"; - namespace = "^(blur-bg.*)"; - } - { - rule = "ignorealpha 0.19"; - namespace = "^(blur-bg.*)"; - } - ]; - - exec-once = [ - "ags" - "sleep 3; ags request 'open win-applauncher'" - ]; - - bind = map mkBind [ - { - modifier = "$mainMod SHIFT"; - key = "E"; - command = "ags toggle win-powermenu"; - } - { - modifier = "$mainMod"; - key = "D"; - command = "ags toggle win-applauncher"; - } - { - modifier = "$mainMod"; - key = "V"; - command = "ags toggle win-clipboard"; - } - { - key = "Print"; - command = "ags toggle win-screenshot"; - } - - { - key = "XF86AudioMute"; - command = "pactl set-sink-mute @DEFAULT_SINK@ toggle"; - } - { - key = "XF86AudioMicMute"; - command = "pactl set-source-mute @DEFAULT_SOURCE@ toggle"; - } - { - modifier = "$mainMod"; - key = "Print"; - command = "bash -c \"grim -g \\\"$(slurp)\\\" - | satty -f -\""; - } - ]; - - binde = map mkBind [ - { - key = "XF86MonBrightnessUp"; - command = "ags request 'Brightness.screen +0.05'"; - } - { - key = "XF86MonBrightnessDown"; - command = "ags request 'Brightness.screen -0.05'"; - } - - { - key = "XF86AudioRaiseVolume"; - command = "wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+ & ags request 'popup speaker' &"; - } - { - key = "XF86AudioLowerVolume"; - command = "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- & ags request 'popup speaker' &"; - } - ]; - - bindn = map mkBind [ - { - key = "Escape"; - command = "ags request closeAll"; - } - ]; - - bindr = map mkBind [ - { - modifier = "CAPS"; - key = "Caps_Lock"; - command = "ags request fetchCapsState"; - } - ]; }; }; diff --git a/modules/ags/packages.nix b/modules/ags/packages.nix index 39dfd8d2..8383eecb 100644 --- a/modules/ags/packages.nix +++ b/modules/ags/packages.nix @@ -9,7 +9,7 @@ self: { gtkSessionLock = gtk-session-lock.packages.${pkgs.system}.default; - inherit (lib) attrValues boolToString filter getExe optionalAttrs optionals; + inherit (lib) attrValues boolToString filter getExe mkIf optionalAttrs optionals; inherit (osConfig.networking) hostName; @@ -29,7 +29,7 @@ self: { ''; }; in { - config = { + config = mkIf cfgDesktop.ags.enable { # Make these accessible outside these files programs.ags = { package = ags.packages.${pkgs.system}.ags.override { diff --git a/modules/base/locale/default.nix b/modules/base/locale/default.nix index ebac9743..c0500401 100644 --- a/modules/base/locale/default.nix +++ b/modules/base/locale/default.nix @@ -7,8 +7,8 @@ inherit (lib) mkIf; cfg = config.roles.base; -in - mkIf cfg.enable { +in { + config = mkIf cfg.enable { fonts = { fontconfig = { enable = true; @@ -45,4 +45,8 @@ in # Select internationalisation properties. i18n.defaultLocale = "en_CA.UTF-8"; console.useXkbConfig = true; - } + }; + + # For accurate stack trace + _file = ./default.nix; +} diff --git a/modules/base/locate/default.nix b/modules/base/locate/default.nix index 17cf6035..f8b1211e 100644 --- a/modules/base/locate/default.nix +++ b/modules/base/locate/default.nix @@ -23,8 +23,8 @@ ${updatedb} -o ${database} --prunefs "${pruneFS}" \ --prunepaths "${prunePaths}" --prunenames "${pruneNames}" ''; -in - mkIf (baseCfg.enable) { +in { + config = mkIf baseCfg.enable { users.users.${baseCfg.user}.extraGroups = [ locateGroup ]; @@ -79,4 +79,8 @@ in ".svn" ]; }; - } + }; + + # For accurate stack trace + _file = ./default.nix; +} diff --git a/modules/base/packages/default.nix b/modules/base/packages/default.nix index 86bf478d..c9ec318c 100644 --- a/modules/base/packages/default.nix +++ b/modules/base/packages/default.nix @@ -8,7 +8,7 @@ self: { cfg = config.roles.base; in { - config = mkIf (cfg.enable) { + config = mkIf cfg.enable { nixpkgs.overlays = (map (i: self.inputs.${i}.overlays.default) [ "discord-overlay" diff --git a/modules/base/substituters/default.nix b/modules/base/substituters/default.nix index 6ac2cf2d..13a234e9 100644 --- a/modules/base/substituters/default.nix +++ b/modules/base/substituters/default.nix @@ -14,8 +14,8 @@ then unique (a ++ b) else b)) {} list; -in - mkIf cfg.enable { +in { + config = mkIf cfg.enable { environment.systemPackages = [ (pkgs.writeShellApplication { name = "rebuild-no-cache"; @@ -50,4 +50,8 @@ in (mkSubstituterConf 10 "https://cache-apt.nelim.org" "cache-apt.nelim.org:NLAsWxa2Qbm4b+hHimjCpZfm48a4oN4O/GPZY9qpjNw=") ]); }; - } + }; + + # For accurate stack trace + _file = ./default.nix; +} diff --git a/modules/borgbackup/default.nix b/modules/borgbackup/default.nix index bde098e4..4242ad41 100644 --- a/modules/borgbackup/default.nix +++ b/modules/borgbackup/default.nix @@ -1,32 +1,42 @@ -{...}: { +{ + config, + lib, + ... +}: let + inherit (lib) mkIf; + + cfg = config.services.borgbackup; +in { imports = [./module.nix]; - config.services.borgbackup = { - existingRepos = [ - { - name = "docker"; - host = "nos"; - authorizedKeys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPijoxuSwH9IrS4poewzHHwe64UoX4QY7Qix5VhEdqKR root@servivi" - ]; - } + config = mkIf (cfg.configs != {}) { + services.borgbackup = { + existingRepos = [ + { + name = "docker"; + host = "nos"; + authorizedKeys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPijoxuSwH9IrS4poewzHHwe64UoX4QY7Qix5VhEdqKR root@servivi" + ]; + } - { - name = "mc"; - host = "servivi"; - authorizedKeys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPijoxuSwH9IrS4poewzHHwe64UoX4QY7Qix5VhEdqKR root@servivi" - ]; - } + { + name = "mc"; + host = "servivi"; + authorizedKeys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPijoxuSwH9IrS4poewzHHwe64UoX4QY7Qix5VhEdqKR root@servivi" + ]; + } - { - name = "seven-days"; - host = "nos"; - authorizedKeys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPijoxuSwH9IrS4poewzHHwe64UoX4QY7Qix5VhEdqKR root@servivi" - ]; - } - ]; + { + name = "seven-days"; + host = "nos"; + authorizedKeys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPijoxuSwH9IrS4poewzHHwe64UoX4QY7Qix5VhEdqKR root@servivi" + ]; + } + ]; + }; }; # For accurate stack trace diff --git a/modules/caddy-plus/default.nix b/modules/caddy-plus/default.nix index a0d57daf..3a4262eb 100644 --- a/modules/caddy-plus/default.nix +++ b/modules/caddy-plus/default.nix @@ -92,7 +92,7 @@ self: { }/Caddyfile"; in { options.services.caddy.virtualHosts = mkOption { - type = types.attrsOf (types.submodule (import ./vhost-options.nix {inherit cfg;})); + type = types.attrsOf (types.submodule (import ./vhost-options.nix cfg)); }; config = mkIf cfg.enable { diff --git a/modules/caddy-plus/sub-dir-options.nix b/modules/caddy-plus/sub-dir-options.nix index fb97d337..bda937e6 100644 --- a/modules/caddy-plus/sub-dir-options.nix +++ b/modules/caddy-plus/sub-dir-options.nix @@ -1,4 +1,4 @@ -{cfg}: { +cfg: { lib, name, ... diff --git a/modules/caddy-plus/sub-domain-options.nix b/modules/caddy-plus/sub-domain-options.nix index 321bd249..3e6e3f18 100644 --- a/modules/caddy-plus/sub-domain-options.nix +++ b/modules/caddy-plus/sub-domain-options.nix @@ -1,4 +1,4 @@ -{cfg}: { +cfg: { lib, name, ... @@ -22,7 +22,7 @@ in { }; subDirectories = mkOption { - type = types.attrsOf (types.submodule (import ./sub-dir-options.nix {inherit cfg;})); + type = types.attrsOf (types.submodule (import ./sub-dir-options.nix cfg)); default = {}; example = literalExpression '' { diff --git a/modules/caddy-plus/vhost-options.nix b/modules/caddy-plus/vhost-options.nix index 8a3e0baf..452df7ab 100644 --- a/modules/caddy-plus/vhost-options.nix +++ b/modules/caddy-plus/vhost-options.nix @@ -1,4 +1,4 @@ -{cfg}: {lib, ...}: let +cfg: {lib, ...}: let inherit (lib) literalExpression mkOption types; in { options = { @@ -12,7 +12,7 @@ in { }; subDomains = mkOption { - type = types.attrsOf (types.submodule (import ./sub-domain-options.nix {inherit cfg;})); + type = types.attrsOf (types.submodule (import ./sub-domain-options.nix cfg)); default = {}; example = literalExpression '' { @@ -30,7 +30,7 @@ in { }; subDirectories = mkOption { - type = types.attrsOf (types.submodule (import ./sub-dir-options.nix {inherit cfg;})); + type = types.attrsOf (types.submodule (import ./sub-dir-options.nix cfg)); default = {}; example = literalExpression '' { diff --git a/modules/desktop/default.nix b/modules/desktop/default.nix index baf0f949..2e7a5e8b 100644 --- a/modules/desktop/default.nix +++ b/modules/desktop/default.nix @@ -3,10 +3,10 @@ self: { lib, ... }: let - inherit (lib) elemAt mkOption types; - inherit (self.inputs) home-manager; + inherit (lib) elemAt mkIf mkOption types; + cfg = config.roles.desktop; flakeDir = config.environment.variables.FLAKE; in { @@ -18,17 +18,24 @@ in { home-manager.nixosModules.home-manager ]; - config.assertions = [ - { - assertion = lib.hasPrefix "/home/${cfg.user}/" flakeDir; - message = '' - Your $FLAKE environment variable needs to point to a directory in - the main users' home to use the desktop module. - ''; - } - ]; + config = mkIf cfg.enable { + assertions = [ + { + assertion = lib.hasPrefix "/home/${cfg.user}/" flakeDir; + message = '' + Your $FLAKE environment variable needs to point to a directory in + the main users' home to use the desktop module. + ''; + } + ]; + }; options.roles.desktop = { + enable = mkOption { + type = types.bool; + default = false; + }; + user = mkOption { type = types.str; description = '' diff --git a/modules/desktop/environment/default.nix b/modules/desktop/environment/default.nix index e6a23edb..ad81e899 100644 --- a/modules/desktop/environment/default.nix +++ b/modules/desktop/environment/default.nix @@ -6,6 +6,19 @@ self: { }: let inherit (self.inputs) hyprland; inherit (self.lib.hypr) mkBind; + + inherit (lib) concatStringsSep mkIf optionals; + + cfg = config.roles.desktop; + + hyprCfg = + config + .home-manager + .users + .${cfg.user} + .wayland + .windowManager + .hyprland; in { imports = [ (import ../../ags self) @@ -18,20 +31,7 @@ in { (import ./modules/security.nix self) ]; - config = let - inherit (lib) concatStringsSep optionals; - - cfg = config.roles.desktop; - - hyprCfg = - config - .home-manager - .users - .${cfg.user} - .wayland - .windowManager - .hyprland; - in { + config = mkIf cfg.enable { services = { dbus.enable = true; gvfs.enable = true; diff --git a/modules/desktop/environment/home/dev.nix b/modules/desktop/environment/home/dev.nix index 5f651f2a..82d2a2d8 100644 --- a/modules/desktop/environment/home/dev.nix +++ b/modules/desktop/environment/home/dev.nix @@ -1,5 +1,14 @@ -{pkgs, ...}: { - config = { +{ + lib, + osConfig, + pkgs, + ... +}: let + inherit (lib) mkIf; + + cfg = osConfig.roles.desktop; +in { + config = mkIf cfg.enable { programs.bash.shellAliases = { # https://wiki.hyprland.org/Contributing-and-Debugging/#lsp-and-formatting "mkCMakeFiles" = "${pkgs.cmake}/bin/cmake -S . -B build/ -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON"; diff --git a/modules/desktop/environment/home/foot.nix b/modules/desktop/environment/home/foot.nix index cdc67068..e78656d6 100644 --- a/modules/desktop/environment/home/foot.nix +++ b/modules/desktop/environment/home/foot.nix @@ -2,10 +2,12 @@ lib, osConfig, ... -}: { - config = let - cfg = osConfig.roles.desktop; - in { +}: let + inherit (lib) mkIf; + + cfg = osConfig.roles.desktop; +in { + config = mkIf cfg.enable { programs = { # https://codeberg.org/dnkl/foot/wiki#spawning-new-terminal-instances-in-the-current-working-directory bash.bashrcExtra = diff --git a/modules/desktop/environment/home/hyprexpo.nix b/modules/desktop/environment/home/hyprexpo.nix index 65dfb5ca..85c14938 100644 --- a/modules/desktop/environment/home/hyprexpo.nix +++ b/modules/desktop/environment/home/hyprexpo.nix @@ -1,7 +1,16 @@ -self: {pkgs, ...}: let +self: { + lib, + osConfig, + pkgs, + ... +}: let inherit (self.lib.hypr) mkBind; + + inherit (lib) mkIf; + + cfg = osConfig.roles.desktop; in { - config = { + config = mkIf cfg.enable { wayland.windowManager.hyprland = { plugins = [self.inputs.hyprland-plugins.packages.${pkgs.system}.hyprexpo]; diff --git a/modules/desktop/environment/home/hyprgrass.nix b/modules/desktop/environment/home/hyprgrass.nix index 8ce5958b..e9d4b3dc 100644 --- a/modules/desktop/environment/home/hyprgrass.nix +++ b/modules/desktop/environment/home/hyprgrass.nix @@ -4,12 +4,13 @@ self: { pkgs, ... }: let - inherit (lib) map mkIf; inherit (self.lib.hypr) mkBind; + inherit (lib) map mkIf; + cfg = osConfig.roles.desktop; in { - config = mkIf cfg.isTouchscreen { + config = mkIf (cfg.enable && cfg.isTouchscreen) { wayland.windowManager.hyprland = { plugins = [self.inputs.hyprgrass.packages.${pkgs.system}.default]; diff --git a/modules/desktop/environment/home/inputs.nix b/modules/desktop/environment/home/inputs.nix index ae2a21c2..e2a1e733 100644 --- a/modules/desktop/environment/home/inputs.nix +++ b/modules/desktop/environment/home/inputs.nix @@ -2,25 +2,27 @@ self: { osConfig, lib, ... -}: { - config = let - inherit (lib) map; - inherit (self.lib.hypr) mkBind; +}: let + inherit (self.lib.hypr) mkBind; - inherit (osConfig.services.xserver) xkb; - inherit (osConfig.roles.desktop) mainMonitor; + inherit (lib) mkIf; - miceNames = [ - "logitech-g502-x" - "logitech-g502-hero-gaming-mouse" - ]; + cfg = osConfig.roles.desktop; - mkConf = name: { - inherit name; - sensitivity = 0; - accel_profile = "flat"; - }; - in { + inherit (osConfig.services.xserver) xkb; + + miceNames = [ + "logitech-g502-x" + "logitech-g502-hero-gaming-mouse" + ]; + + mkConf = name: { + inherit name; + sensitivity = 0; + accel_profile = "flat"; + }; +in { + config = mkIf cfg.enable { wayland.windowManager.hyprland = { settings = { device = map mkConf miceNames; @@ -31,8 +33,8 @@ self: { }; exec-once = - if mainMonitor != null - then ["hyprctl dispatch focusmonitor ${mainMonitor}"] + if cfg.mainMonitor != null + then ["hyprctl dispatch focusmonitor ${cfg.mainMonitor}"] else []; input = { diff --git a/modules/desktop/environment/home/mpv.nix b/modules/desktop/environment/home/mpv.nix index 8475c4c6..cfaf85b9 100644 --- a/modules/desktop/environment/home/mpv.nix +++ b/modules/desktop/environment/home/mpv.nix @@ -1,7 +1,16 @@ -self: {pkgs, ...}: { - config = let - inherit (self.scopedPackages.${pkgs.system}) mpvScripts; - in { +self: { + lib, + osConfig, + pkgs, + ... +}: let + inherit (self.scopedPackages.${pkgs.system}) mpvScripts; + + inherit (lib) mkIf; + + cfg = osConfig.roles.desktop; +in { + config = mkIf cfg.enable { # For kdialog-open-files home.packages = [ pkgs.kdialog diff --git a/modules/desktop/environment/home/obs.nix b/modules/desktop/environment/home/obs.nix index 91bab314..95c35c70 100644 --- a/modules/desktop/environment/home/obs.nix +++ b/modules/desktop/environment/home/obs.nix @@ -1,9 +1,18 @@ -self: {pkgs, ...}: let +self: { + lib, + osConfig, + pkgs, + ... +}: let inherit (self.inputs) nixpkgs-wayland; + + waypkgs = nixpkgs-wayland.packages.${pkgs.system}; + + inherit (lib) mkIf; + + cfg = osConfig.roles.desktop; in { - config = let - waypkgs = nixpkgs-wayland.packages.${pkgs.system}; - in { + config = mkIf cfg.enable { programs = { obs-studio = { enable = true; diff --git a/modules/desktop/environment/modules/audio.nix b/modules/desktop/environment/modules/audio.nix index 53e8f51f..aee166eb 100644 --- a/modules/desktop/environment/modules/audio.nix +++ b/modules/desktop/environment/modules/audio.nix @@ -1,9 +1,17 @@ -self: {...}: let +self: { + config, + lib, + ... +}: let inherit (self.inputs) nix-gaming; + + inherit (lib) mkIf; + + cfg = config.roles.desktop; in { imports = [nix-gaming.nixosModules.pipewireLowLatency]; - config = { + config = mkIf cfg.enable { services = { pulseaudio.enable = false; diff --git a/modules/desktop/environment/modules/dconf.nix b/modules/desktop/environment/modules/dconf.nix index 0ee853f2..4b233c29 100644 --- a/modules/desktop/environment/modules/dconf.nix +++ b/modules/desktop/environment/modules/dconf.nix @@ -1,7 +1,13 @@ -{config, ...}: { - config = let - cfg = config.roles.desktop; - in { +{ + config, + lib, + ... +}: let + inherit (lib) mkIf; + + cfg = config.roles.desktop; +in { + config = mkIf cfg.enable { programs.dconf.enable = true; home-manager.users.${cfg.user} = { diff --git a/modules/desktop/environment/modules/dolphin.nix b/modules/desktop/environment/modules/dolphin.nix index b337bb0c..6de51fda 100644 --- a/modules/desktop/environment/modules/dolphin.nix +++ b/modules/desktop/environment/modules/dolphin.nix @@ -1,11 +1,14 @@ { config, + lib, pkgs, ... -}: { - config = let - cfg = config.roles.desktop; - in { +}: let + inherit (lib) mkIf; + + cfg = config.roles.desktop; +in { + config = mkIf cfg.enable { environment.systemPackages = [ pkgs.plasma5Packages.kio-admin ]; diff --git a/modules/desktop/environment/modules/packages.nix b/modules/desktop/environment/modules/packages.nix index 63a9ba32..b01c61e1 100644 --- a/modules/desktop/environment/modules/packages.nix +++ b/modules/desktop/environment/modules/packages.nix @@ -6,21 +6,22 @@ self: { }: let inherit (self.lib.hypr) mkBind; inherit (self.inputs) jellyfin-flake; + + inherit (lib) getExe mkIf optionals; + inherit (pkgs.writers) writeTOML; + + cfg = config.roles.desktop; + + flakeDir = config.environment.variables.FLAKE; + isNvidia = config.nvidia.enable; + + restartTailscale = pkgs.writeShellScriptBin "restartTailscale" '' + sudo ${pkgs.systemd}/bin/systemctl restart tailscaled.service + ''; in { imports = [./dolphin.nix]; - config = let - inherit (lib) getExe map optionals; - inherit (pkgs.writers) writeTOML; - - flakeDir = config.environment.variables.FLAKE; - cfg = config.roles.desktop; - isNvidia = config.nvidia.enable; - - restartTailscale = pkgs.writeShellScriptBin "restartTailscale" '' - sudo ${pkgs.systemd}/bin/systemctl restart tailscaled.service - ''; - in { + config = mkIf cfg.enable { programs.kdeconnect.enable = true; security.sudo.extraRules = [ diff --git a/modules/desktop/environment/modules/printer.nix b/modules/desktop/environment/modules/printer.nix index 1f6df265..c030f2fe 100644 --- a/modules/desktop/environment/modules/printer.nix +++ b/modules/desktop/environment/modules/printer.nix @@ -1,5 +1,14 @@ -{pkgs, ...}: { - config = { +{ + config, + lib, + pkgs, + ... +}: let + inherit (lib) mkIf; + + cfg = config.roles.desktop; +in { + config = mkIf cfg.enable { services = { # Enable CUPS to print documents. printing = { diff --git a/modules/desktop/environment/modules/ratbag-mice.nix b/modules/desktop/environment/modules/ratbag-mice.nix index 1c340514..61dbcf0a 100644 --- a/modules/desktop/environment/modules/ratbag-mice.nix +++ b/modules/desktop/environment/modules/ratbag-mice.nix @@ -1,7 +1,15 @@ -self: {pkgs, ...}: let +self: { + config, + lib, + pkgs, + ... +}: let inherit (self.packages.${pkgs.system}) libratbag piper; + inherit (lib) mkIf; + + cfg = config.roles.desktop; in { - config = { + config = mkIf cfg.enable { services.ratbagd = { enable = true; diff --git a/modules/desktop/environment/modules/security.nix b/modules/desktop/environment/modules/security.nix index b7f4302a..37e5315d 100644 --- a/modules/desktop/environment/modules/security.nix +++ b/modules/desktop/environment/modules/security.nix @@ -3,44 +3,45 @@ self: { lib, pkgs, ... -}: { - config = let - inherit (self.lib.hypr) mkBind; - inherit (lib) getExe map mkIf; +}: let + inherit (self.lib.hypr) mkBind; - cfg = config.roles.desktop; + inherit (lib) getExe map mkIf; - hmCfg = config.home-manager.users.${cfg.user}; - hyprPkg = hmCfg.wayland.windowManager.hyprland.finalPackage; + cfg = config.roles.desktop; - # See modules/ags/packages.nix - lockPkg = hmCfg.programs.ags.lockPkg; + hmCfg = config.home-manager.users.${cfg.user}; + hyprPkg = hmCfg.wayland.windowManager.hyprland.finalPackage; - runInDesktop = pkgs.writeShellApplication { - name = "runInDesktop"; - runtimeInputs = [ - pkgs.sudo - hyprPkg - ]; + # See modules/ags/packages.nix + lockPkg = hmCfg.programs.ags.lockPkg; - text = '' - params=( "$@" ) - user="$(id -u ${cfg.user})" - readarray -t SIGS <<< "$(ls "/run/user/$user/hypr/")" + runInDesktop = pkgs.writeShellApplication { + name = "runInDesktop"; + runtimeInputs = [ + pkgs.sudo + hyprPkg + ]; - run() { - export HYPRLAND_INSTANCE_SIGNATURE="$1" - sudo -Eu ${cfg.user} hyprctl dispatch exec "''${params[@]}" - } + text = '' + params=( "$@" ) + user="$(id -u ${cfg.user})" + readarray -t SIGS <<< "$(ls "/run/user/$user/hypr/")" - i=0 + run() { + export HYPRLAND_INSTANCE_SIGNATURE="$1" + sudo -Eu ${cfg.user} hyprctl dispatch exec "''${params[@]}" + } - while ! run "''${SIGS[$i]}"; do - ((i+=1)) - done - ''; - }; - in { + i=0 + + while ! run "''${SIGS[$i]}"; do + ((i+=1)) + done + ''; + }; +in { + config = mkIf cfg.enable { services.acpid = mkIf cfg.isLaptop { enable = true; diff --git a/modules/desktop/manager/ags.nix b/modules/desktop/manager/ags/default.nix similarity index 50% rename from modules/desktop/manager/ags.nix rename to modules/desktop/manager/ags/default.nix index a65537f2..362821ec 100644 --- a/modules/desktop/manager/ags.nix +++ b/modules/desktop/manager/ags/default.nix @@ -1,29 +1,32 @@ self: { config, + lib, pkgs, ... -}: { - config = let - cfg = config.roles.desktop; - agsCfg = hmCfg.programs.ags; - hmCfg = config.home-manager.users.${cfg.user}; +}: let + inherit (lib) mkIf; - hyprland = hmCfg.wayland.windowManager.hyprland.finalPackage; + cfg = config.roles.desktop; + agsCfg = hmCfg.programs.ags; + hmCfg = config.home-manager.users.${cfg.user}; - agsConfig = let - homeFiles = config.home-manager.users.${cfg.user}.home.file; + hyprland = hmCfg.wayland.windowManager.hyprland.finalPackage; - nodeModules = homeFiles."${agsCfg.configDir}/node_modules".source; - varsTs = homeFiles."${agsCfg.configDir}/widgets/lockscreen/vars.ts".source; - in - pkgs.runCommandLocal "agsConfig" {} '' - cp -ar ${../../ags/config}/* ./. - chmod +w -R ./. - cp -ar ${varsTs} ./widgets/lockscreen/vars.ts - cp -ar ${nodeModules} ./node_modules - ${agsCfg.package}/bin/ags bundle ./app.ts $out - ''; - in { + agsConfig = let + homeFiles = config.home-manager.users.${cfg.user}.home.file; + + nodeModules = homeFiles."${agsCfg.configDir}/node_modules".source; + varsTs = homeFiles."${agsCfg.configDir}/widgets/lockscreen/vars.ts".source; + in + pkgs.runCommandLocal "agsConfig" {} '' + cp -ar ${self}/modules/ags/config/* ./. + chmod +w -R ./. + cp -ar ${varsTs} ./widgets/lockscreen/vars.ts + cp -ar ${nodeModules} ./node_modules + ${agsCfg.package}/bin/ags bundle ./app.ts $out + ''; +in { + config = mkIf cfg.enable { assertions = [ { assertion = cfg.ags.enable; diff --git a/modules/desktop/manager/default.nix b/modules/desktop/manager/default.nix index 7947588e..f1df1850 100644 --- a/modules/desktop/manager/default.nix +++ b/modules/desktop/manager/default.nix @@ -3,58 +3,57 @@ self: { lib, pkgs, ... -}: { +}: let + inherit (lib) mkIf; + + cfg = config.roles.desktop; + + hyprland = + config + .home-manager + .users + .${cfg.user} + .wayland + .windowManager + .hyprland + .finalPackage; + + # Hide TTY on launch + cmd = toString (pkgs.writeShellScript "hyprland-wrapper" '' + trap 'systemctl --user stop hyprland-session.target; sleep 1' EXIT + exec Hyprland >/dev/null + ''); +in { imports = [ - (import ./ags.nix self) - (import ./hyprland.nix self) + (import ./ags self) + (import ./hyprland self) ]; - config = let - inherit (lib) mkIf; + config = mkIf (cfg.enable && cfg.displayManager.enable) { + services = { + displayManager.sessionPackages = [hyprland]; - cfg = config.roles.desktop; + greetd = { + enable = true; + settings = { + default_session = { + command = cmd; + user = "greeter"; + }; - hyprland = - config - .home-manager - .users - .${cfg.user} - .wayland - .windowManager - .hyprland - .finalPackage; - - # Hide TTY on launch - cmd = toString (pkgs.writeShellScript "hyprland-wrapper" '' - trap 'systemctl --user stop hyprland-session.target; sleep 1' EXIT - exec Hyprland >/dev/null - ''); - in - mkIf cfg.displayManager.enable { - services = { - displayManager.sessionPackages = [hyprland]; - - greetd = { - enable = true; - settings = { - default_session = { - command = cmd; - user = "greeter"; - }; - - initial_session = { - command = cmd; - user = cfg.user; - }; + initial_session = { + command = cmd; + user = cfg.user; }; }; }; - - # unlock GPG keyring on login - services.gnome.gnome-keyring.enable = true; - security.pam.services.greetd.enableGnomeKeyring = true; }; + # unlock GPG keyring on login + services.gnome.gnome-keyring.enable = true; + security.pam.services.greetd.enableGnomeKeyring = true; + }; + # For accurate stack trace _file = ./default.nix; } diff --git a/modules/desktop/manager/hyprland.nix b/modules/desktop/manager/hyprland/default.nix similarity index 74% rename from modules/desktop/manager/hyprland.nix rename to modules/desktop/manager/hyprland/default.nix index 87aec19f..63da5bda 100644 --- a/modules/desktop/manager/hyprland.nix +++ b/modules/desktop/manager/hyprland/default.nix @@ -3,28 +3,28 @@ self: { lib, pkgs, ... -}: { - config = let - inherit (lib) optionals; - inherit (self.lib.hypr) mkAnimation; +}: let + inherit (self.lib.hypr) mkAnimation; - inherit (import ./setupMonitors.nix {inherit config pkgs;}) setupMonitors; + inherit (lib) mkIf optionals; - cfg = config.roles.desktop; + inherit (import ./setupMonitors.nix {inherit config pkgs;}) setupMonitors; - # Nix stuff - cfgHypr = - config - .home-manager - .users - .${cfg.user} - .wayland - .windowManager - .hyprland; - in { + cfg = config.roles.desktop; + + cfgHypr = + config + .home-manager + .users + .${cfg.user} + .wayland + .windowManager + .hyprland; +in { + config = mkIf cfg.enable { home-manager.users.greeter = { imports = [ - (import ../theme self) + (import ../../theme self) ]; wayland.windowManager.hyprland = { @@ -73,5 +73,5 @@ self: { }; # For accurate stack trace - _file = ./hyprland.nix; + _file = ./default.nix; } diff --git a/modules/desktop/manager/setupMonitors.nix b/modules/desktop/manager/hyprland/setupMonitors.nix similarity index 100% rename from modules/desktop/manager/setupMonitors.nix rename to modules/desktop/manager/hyprland/setupMonitors.nix diff --git a/modules/desktop/theme/cursors.nix b/modules/desktop/theme/cursors/default.nix similarity index 63% rename from modules/desktop/theme/cursors.nix rename to modules/desktop/theme/cursors/default.nix index 1c323631..3b6a445c 100644 --- a/modules/desktop/theme/cursors.nix +++ b/modules/desktop/theme/cursors/default.nix @@ -1,12 +1,21 @@ -self: {pkgs, ...}: { - config = let - inherit (self.scopedPackages.${pkgs.system}) dracula; +self: { + lib, + osConfig, + pkgs, + ... +}: let + inherit (self.scopedPackages.${pkgs.system}) dracula; - cursorTheme = dracula.hyprcursor; - cursorThemeName = "Dracula-cursors"; - hyprcursorThemeName = "Dracula-hyprcursor"; - cursorSize = 24; - in { + inherit (lib) mkIf; + + cfg = osConfig.roles.desktop; + + cursorTheme = dracula.hyprcursor; + cursorThemeName = "Dracula-cursors"; + hyprcursorThemeName = "Dracula-hyprcursor"; + cursorSize = 24; +in { + config = mkIf cfg.enable { home.pointerCursor = { name = cursorThemeName; package = dracula.gtk; @@ -35,5 +44,5 @@ self: {pkgs, ...}: { }; # For accurate stack trace - _file = ./cursors.nix; + _file = ./default.nix; } diff --git a/modules/desktop/theme/default.nix b/modules/desktop/theme/default.nix index 125f75b8..59f52b72 100644 --- a/modules/desktop/theme/default.nix +++ b/modules/desktop/theme/default.nix @@ -1,26 +1,36 @@ -self: {...}: { +self: { + lib, + osConfig, + ... +}: let + inherit (lib) mkIf; + + cfg = osConfig.roles.desktop; +in { imports = [ ./gtk - ./xresources.nix + ./xresources - (import ./cursors.nix self) - (import ./qt.nix self) - (import ./hyprpaper.nix self) + (import ./cursors self) + (import ./hyprpaper self) + (import ./qt self) ]; - config.wayland.windowManager.hyprland = { - settings = { - windowrule = [ - "size 1231 950,title:^(Open Folder)$" - "float,title:^(Open Folder)$" + config = mkIf cfg.enable { + wayland.windowManager.hyprland = { + settings = { + windowrule = [ + "size 1231 950,title:^(Open Folder)$" + "float,title:^(Open Folder)$" - "size 1231 950,title:^(Open File)$" - "float,title:^(Open File)$" - ]; + "size 1231 950,title:^(Open File)$" + "float,title:^(Open File)$" + ]; - layerrule = [ - "noanim, selection" - ]; + layerrule = [ + "noanim, selection" + ]; + }; }; }; diff --git a/modules/desktop/theme/gtk/default.nix b/modules/desktop/theme/gtk/default.nix index da0b489d..4aad7759 100644 --- a/modules/desktop/theme/gtk/default.nix +++ b/modules/desktop/theme/gtk/default.nix @@ -3,12 +3,14 @@ lib, osConfig, ... -}: { - config = let - inherit (import ./gradience.nix {inherit pkgs lib;}) gradience; +}: let + inherit (lib) mkIf; - cfg = osConfig.roles.desktop; - in { + inherit (import ./gradience.nix {inherit pkgs lib;}) gradience; + + cfg = osConfig.roles.desktop; +in { + config = mkIf cfg.enable { home.packages = [ pkgs.gnomeExtensions.user-themes ]; diff --git a/modules/desktop/theme/hyprpaper.nix b/modules/desktop/theme/hyprpaper/default.nix similarity index 57% rename from modules/desktop/theme/hyprpaper.nix rename to modules/desktop/theme/hyprpaper/default.nix index e96ce437..53eecc00 100644 --- a/modules/desktop/theme/hyprpaper.nix +++ b/modules/desktop/theme/hyprpaper/default.nix @@ -1,12 +1,17 @@ self: { lib, + osConfig, pkgs, ... -}: { - config = let - hyprpaper = self.inputs.hyprpaper.packages.${pkgs.system}.default; - wallpaper = toString self.scopedPackages.${pkgs.system}.dracula.wallpaper; - in { +}: let + inherit (lib) mkIf; + + cfg = osConfig.roles.desktop; + + hyprpaper = self.inputs.hyprpaper.packages.${pkgs.system}.default; + wallpaper = toString self.scopedPackages.${pkgs.system}.dracula.wallpaper; +in { + config = mkIf cfg.enable { home.packages = [hyprpaper]; xdg.configFile."hypr/hyprpaper.conf" = { @@ -26,5 +31,5 @@ self: { }; # For accurate stack trace - _file = ./hyprpaper.nix; + _file = ./default.nix; } diff --git a/modules/desktop/theme/qt.nix b/modules/desktop/theme/qt/default.nix similarity index 86% rename from modules/desktop/theme/qt.nix rename to modules/desktop/theme/qt/default.nix index c5eb6094..44cb6390 100644 --- a/modules/desktop/theme/qt.nix +++ b/modules/desktop/theme/qt/default.nix @@ -3,12 +3,14 @@ self: { osConfig, pkgs, ... -}: { - config = let - inherit (self.scopedPackages.${pkgs.system}) dracula; +}: let + inherit (self.scopedPackages.${pkgs.system}) dracula; - cfg = osConfig.roles.desktop; - in { + inherit (lib) mkIf; + + cfg = osConfig.roles.desktop; +in { + config = mkIf cfg.enable { home.packages = [ pkgs.libsForQt5.qtstyleplugin-kvantum pkgs.kdePackages.qtstyleplugin-kvantum @@ -44,5 +46,5 @@ self: { }; # For accurate stack trace - _file = ./qt.nix; + _file = ./default.nix; } diff --git a/modules/desktop/theme/xresources.nix b/modules/desktop/theme/xresources.nix deleted file mode 100644 index 16bff955..00000000 --- a/modules/desktop/theme/xresources.nix +++ /dev/null @@ -1,23 +0,0 @@ -{...}: { - xresources.extraConfig = '' - ! Dracula Xresources palette - *.foreground: #F8F8F2 - *.background: #282A36 - *.color0: #000000 - *.color8: #4D4D4D - *.color1: #FF5555 - *.color9: #FF6E67 - *.color2: #50FA7B - *.color10: #5AF78E - *.color3: #F1FA8C - *.color11: #F4F99D - *.color4: #BD93F9 - *.color12: #CAA9FA - *.color5: #FF79C6 - *.color13: #FF92D0 - *.color6: #8BE9FD - *.color14: #9AEDFE - *.color7: #BFBFBF - *.color15: #E6E6E6 - ''; -} diff --git a/modules/desktop/theme/xresources/default.nix b/modules/desktop/theme/xresources/default.nix new file mode 100644 index 00000000..7776d962 --- /dev/null +++ b/modules/desktop/theme/xresources/default.nix @@ -0,0 +1,36 @@ +{ + lib, + osConfig, + ... +}: let + inherit (lib) mkIf; + + cfg = osConfig.roles.desktop; +in { + config = mkIf cfg.enable { + xresources.extraConfig = '' + ! Dracula Xresources palette + *.foreground: #F8F8F2 + *.background: #282A36 + *.color0: #000000 + *.color8: #4D4D4D + *.color1: #FF5555 + *.color9: #FF6E67 + *.color2: #50FA7B + *.color10: #5AF78E + *.color3: #F1FA8C + *.color11: #F4F99D + *.color4: #BD93F9 + *.color12: #CAA9FA + *.color5: #FF79C6 + *.color13: #FF92D0 + *.color6: #8BE9FD + *.color14: #9AEDFE + *.color7: #BFBFBF + *.color15: #E6E6E6 + ''; + }; + + # For accurate stack trace + _file = ./default.nix; +} diff --git a/modules/docker/default.nix b/modules/docker/default.nix index e774630d..9da499d8 100644 --- a/modules/docker/default.nix +++ b/modules/docker/default.nix @@ -33,7 +33,7 @@ in { }; }; - config = mkIf (cfg.enable) { + config = mkIf cfg.enable { virtualisation = { docker = { enable = true; diff --git a/modules/esphome-plus/default.nix b/modules/esphome-plus/default.nix index bc893adb..774d34c8 100644 --- a/modules/esphome-plus/default.nix +++ b/modules/esphome-plus/default.nix @@ -51,7 +51,7 @@ in { }; }; - config = mkIf (cfg.enable) { + config = mkIf cfg.enable { # FIXME: https://github.com/NixOS/nixpkgs/issues/339557 systemd.services.esphome = { environment.PLATFORMIO_CORE_DIR = mkForce "${stateDir}/.platformio"; diff --git a/modules/plymouth/default.nix b/modules/plymouth/default.nix index e5e1758d..7a3f9e52 100644 --- a/modules/plymouth/default.nix +++ b/modules/plymouth/default.nix @@ -7,26 +7,28 @@ cfg = config.boot.plymouth; in { - config.boot = mkIf cfg.enable { - initrd = { - verbose = false; - systemd.enable = true; + config = mkIf cfg.enable { + boot = { + initrd = { + verbose = false; + systemd.enable = true; + }; + + consoleLogLevel = 0; + + kernelParams = [ + "quiet" + "splash" + "boot.shell_on_fail" + "i915.fastboot=1" + "loglevel=3" + "rd.systemd.show_status=false" + "rd.udev.log_level=3" + "udev.log_priority=3" + ]; + + loader.timeout = 0; }; - - consoleLogLevel = 0; - - kernelParams = [ - "quiet" - "splash" - "boot.shell_on_fail" - "i915.fastboot=1" - "loglevel=3" - "rd.systemd.show_status=false" - "rd.udev.log_level=3" - "udev.log_priority=3" - ]; - - loader.timeout = 0; }; # For accurate stack trace diff --git a/modules/server/default.nix b/modules/server/default.nix index 29a0597b..3d7446a2 100644 --- a/modules/server/default.nix +++ b/modules/server/default.nix @@ -2,11 +2,16 @@ inherit (lib) mkOption types; in { imports = [ - ./sshd.nix - ./tailscale.nix + ./sshd + ./tailscale ]; options.roles.server = { + enable = mkOption { + type = types.bool; + default = false; + }; + user = mkOption { type = types.str; description = '' diff --git a/modules/server/sshd.nix b/modules/server/sshd/default.nix similarity index 91% rename from modules/server/sshd.nix rename to modules/server/sshd/default.nix index e84b40b7..efdc8041 100644 --- a/modules/server/sshd.nix +++ b/modules/server/sshd/default.nix @@ -7,7 +7,7 @@ cfg = config.roles.server; in { - config = mkIf cfg.sshd.enable { + config = mkIf (cfg.enable && cfg.sshd.enable) { services = { openssh = { enable = true; @@ -29,5 +29,5 @@ in { }; # For accurate stack trace - _file = ./sshd.nix; + _file = ./default.nix; } diff --git a/modules/server/tailscale.nix b/modules/server/tailscale/default.nix similarity index 94% rename from modules/server/tailscale.nix rename to modules/server/tailscale/default.nix index de2773f8..e084d3d0 100644 --- a/modules/server/tailscale.nix +++ b/modules/server/tailscale/default.nix @@ -8,7 +8,7 @@ cfg = config.roles.server; in { - config = mkIf cfg.tailscale.enable { + config = mkIf (cfg.enable && cfg.tailscale.enable) { services = { tailscale = { enable = true; @@ -48,5 +48,5 @@ in { }; # For accurate stack trace - _file = ./tailscale.nix; + _file = ./default.nix; } diff --git a/modules/tmux/default.nix b/modules/tmux/default.nix index 8a624120..fbb0ab67 100644 --- a/modules/tmux/default.nix +++ b/modules/tmux/default.nix @@ -4,14 +4,14 @@ pkgs, ... }: let - inherit (lib) attrValues elemAt hasAttr mkIf mkOption types; + inherit (lib) attrValues hasAttr head mkIf mkOption types; cfg = config.programs.tmux; # Support NixOnDroid firstUser = if hasAttr "users" config.home-manager - then elemAt (attrValues config.home-manager.users) 0 + then head (attrValues config.home-manager.users) else config.home-manager.config; in { options.programs.tmux = { diff --git a/modules/wyoming-plus/default.nix b/modules/wyoming-plus/default.nix index 8a9abbd3..5f62dc01 100644 --- a/modules/wyoming-plus/default.nix +++ b/modules/wyoming-plus/default.nix @@ -9,6 +9,8 @@ inherit (lib.strings) concatMapStringsSep concatStringsSep; cfg = config.services.wyoming; + + forkedPkg = pkgs.callPackage ./pkgs {}; in { options.services.wyoming.openwakeword.vadThreshold = mkOption { type = types.float; @@ -16,9 +18,7 @@ in { apply = toString; }; - config = let - forkedPkg = pkgs.callPackage ./pkgs {}; - in { + config = { systemd.services = mkIf (cfg.openwakeword.enable) { wyoming-openwakeword.serviceConfig = { MemoryDenyWriteExecute = mkForce (cfg.openwakeword.package != forkedPkg);