diff --git a/README.md b/README.md index e455866..2145d79 100644 --- a/README.md +++ b/README.md @@ -43,10 +43,18 @@ inputs = { ``` ```nix -# home.nix +# home.nix (standalone home-manager) imports = [ inputs.nova-shell.homeModules.default ]; ``` +Or, if you use home-manager as a NixOS module, import the NixOS module instead - +it auto-injects the hm module (and the stylix module, if stylix is present): + +```nix +# configuration.nix +imports = [ inputs.nova-shell.nixosModules.default ]; +``` + ### Without Nix You poor thing. Here's what the Nix packaging does for you, manually: @@ -75,11 +83,17 @@ programs.nova-shell.enable = true; ``` This installs the bar, the Symbols Nerd Font, and a systemd user service that -starts with `graphical-session.target`. If you use -[stylix](https://github.com/danth/stylix), colors and fonts are populated -automatically — one fewer thing for the AI to have gotten wrong. If you do not -use stylix, you get Catppuccin Mocha, because my keeper has -taste and it is purple. +starts with `graphical-session.target`. If you do not configure a theme, +you get Catppuccin Mocha, because my keeper has taste and it is purple. + +If you use [stylix](https://github.com/danth/stylix), import the stylix module +to have colors and fonts populated automatically: + +```nix +imports = [ nova-shell.homeModules.stylix ]; +``` + +You can disable it with `stylix.targets.nova-shell.enable = false`. ### Disabling modules @@ -142,8 +156,7 @@ nix build .#docs ### Theme -Theme keys are merged on top of whatever stylix provides. You only need to -specify what you want to override. Values are written to +Theme keys are written to `~/.config/nova-shell/theme.json`. Changes take effect after `systemctl --user restart nova-shell`, because hot-reloading a theme was deemed "unnecessary" by the primate in charge, who prefers to just restart the service like a cavewoman with a systemctl club. @@ -158,7 +171,7 @@ programs.nova-shell.theme = { fontSize = 13; fontFamily = "JetBrains Mono"; - # override individual palette entries if stylix's choices personally offend you + # override individual palette entries (or stylix defaults, if you imported the stylix module) colors.base00 = "#1a1a2e"; colors.base05 = "#e0e0f0"; }; diff --git a/flake.nix b/flake.nix index 39e1fb9..955fbaf 100644 --- a/flake.nix +++ b/flake.nix @@ -202,7 +202,10 @@ } ); + nixosModules.default = import ./nix/nixos-module.nix self; + homeModules.default = import ./nix/hm-module.nix self; + homeModules.stylix = import ./nix/stylix.nix self; homeManagerModules.default = self.homeModules.default; }; } diff --git a/nix/hm-module.nix b/nix/hm-module.nix index 4a87bd0..ae72e18 100644 --- a/nix/hm-module.nix +++ b/nix/hm-module.nix @@ -7,40 +7,6 @@ self: }: let cfg = config.programs.nova-shell; - - stylixAvailable = config ? lib && config.lib ? stylix; - - stylixTheme = - let - c = config.lib.stylix.colors.withHashtag; - f = config.stylix.fonts; - in - { - colors = { - inherit (c) - base00 - base01 - base02 - base03 - base04 - base05 - base06 - base07 - base08 - base09 - base0A - base0B - base0C - base0D - base0E - base0F - ; - }; - fontFamily = f.sansSerif.name; - fontSize = f.sizes.desktop; - barOpacity = 1.0 - config.stylix.opacity.desktop; - iconFontFamily = "Symbols Nerd Font"; - }; in { options.programs.nova-shell = { @@ -295,7 +261,7 @@ in Keys: colors (base00-base0F), fontFamily, iconFontFamily, fontSize, barOpacity, barHeight, barPadding, groupSpacing, groupPadding, moduleSpacing, radius, screenRadius, reducedMotion. - Automatically populated from stylix when it is available. + Populated from stylix when homeModules.stylix is imported. ''; }; @@ -327,11 +293,8 @@ in cfg.modules; xdg.configFile."nova-shell/theme.json".source = - let - stylixDefaults = if stylixAvailable then stylixTheme else { }; - finalTheme = lib.recursiveUpdate stylixDefaults cfg.theme; - in - (pkgs.formats.json { }).generate "nova-shell-theme.json" finalTheme; + (pkgs.formats.json { }).generate "nova-shell-theme.json" + cfg.theme; # Niri layer rules for backdrop placement (requires niri-flake hm module) programs.niri.settings.layer-rules = lib.mkIf (config ? programs && config.programs ? niri) [ diff --git a/nix/nixos-module.nix b/nix/nixos-module.nix new file mode 100644 index 0000000..d687470 --- /dev/null +++ b/nix/nixos-module.nix @@ -0,0 +1,22 @@ +self: +{ + config, + options, + lib, + ... +}: +let + cfg = config.programs.nova-shell; +in +{ + options.programs.nova-shell.enable = lib.mkEnableOption "nova-shell Quickshell bar"; + + config = lib.mkIf cfg.enable ( + lib.optionalAttrs (options ? home-manager) { + home-manager.sharedModules = [ + self.homeModules.default + ] + ++ lib.optionals (options ? stylix) [ self.homeModules.stylix ]; + } + ); +} diff --git a/nix/stylix.nix b/nix/stylix.nix new file mode 100644 index 0000000..643c4f1 --- /dev/null +++ b/nix/stylix.nix @@ -0,0 +1,40 @@ +_: +{ + lib, + config, + ... +}: +let + inherit (lib) mkDefault mkIf; + c = config.lib.stylix.colors.withHashtag; + f = config.stylix.fonts; +in +{ + options.stylix.targets.nova-shell.enable = config.lib.stylix.mkEnableTarget "nova-shell" true; + + config = mkIf (config.stylix.enable && config.stylix.targets.nova-shell.enable) { + programs.nova-shell.theme = { + colors = { + base00 = mkDefault c.base00; + base01 = mkDefault c.base01; + base02 = mkDefault c.base02; + base03 = mkDefault c.base03; + base04 = mkDefault c.base04; + base05 = mkDefault c.base05; + base06 = mkDefault c.base06; + base07 = mkDefault c.base07; + base08 = mkDefault c.base08; + base09 = mkDefault c.base09; + base0A = mkDefault c.base0A; + base0B = mkDefault c.base0B; + base0C = mkDefault c.base0C; + base0D = mkDefault c.base0D; + base0E = mkDefault c.base0E; + base0F = mkDefault c.base0F; + }; + fontFamily = mkDefault f.sansSerif.name; + fontSize = mkDefault f.sizes.desktop; + barOpacity = mkDefault (1.0 - config.stylix.opacity.desktop); + }; + }; +}