self: { config, lib, pkgs, ... }: let cfg = config.programs.nova-shell; stylixAvailable = config ? lib && config.lib ? stylix; stylixTheme = lib.mkIf stylixAvailable ( 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; } ); in { options.programs.nova-shell = { enable = lib.mkEnableOption "nova-shell Quickshell bar"; package = lib.mkOption { type = lib.types.package; default = self.packages.${pkgs.stdenv.hostPlatform.system}.default; description = "nova-shell package to use."; }; theme = lib.mkOption { type = lib.types.attrsOf lib.types.anything; default = { }; description = '' Theme overrides written to `$XDG_CONFIG_HOME/nova-shell/theme.json`. Keys: colors (base00-base0F), fontFamily, fontSize, barOpacity, barHeight. Automatically populated from stylix when it is available. ''; }; systemd = { enable = lib.mkOption { type = lib.types.bool; default = true; description = "Run nova-shell as a systemd user service."; }; target = lib.mkOption { type = lib.types.str; default = "graphical-session.target"; description = "Systemd target to bind the service to."; }; }; }; config = lib.mkIf cfg.enable { programs.nova-shell.theme = lib.mkIf stylixAvailable (lib.mkDefault stylixTheme); home.packages = [ cfg.package ]; xdg.configFile."nova-shell/theme.json".source = (pkgs.formats.json { }).generate "nova-shell-theme.json" cfg.theme; systemd.user.services.nova-shell = lib.mkIf cfg.systemd.enable { Unit = { Description = "nova-shell Quickshell bar"; PartOf = [ cfg.systemd.target ]; After = [ cfg.systemd.target ]; }; Service = { ExecStart = lib.getExe cfg.package; Restart = "on-failure"; Slice = "session.slice"; }; Install.WantedBy = [ cfg.systemd.target ]; }; }; }