dotfiles

My PC Dotfiles & Website

modules/gui/theme.nix (3599B)


  1## System Theming ##
  2{
  3  config,
  4  inputs,
  5  ...
  6}: let
  7  inherit (config.flake) files;
  8  cli = {lib, ...}: {
  9    stylix = {
 10      enable = lib.mkDefault true;
 11      image = lib.mkDefault files.wallpapers.Beauty;
 12      polarity = lib.mkDefault "dark";
 13      base16Scheme = files.colors.campbell;
 14    };
 15  };
 16in {
 17  flake.modules = {
 18    nixos.theme-cli = {
 19      imports = [inputs.stylix.nixosModules.stylix cli];
 20      stylix = {
 21        autoEnable = false;
 22        homeManagerIntegration.autoImport = false;
 23      };
 24    };
 25
 26    homeManager.theme-cli = {
 27      config,
 28      lib,
 29      options,
 30      ...
 31    }: {
 32      imports = [inputs.stylix.homeModules.stylix cli];
 33      stylix = {
 34        autoEnable = true;
 35        targets =
 36          lib.mapAttrs (name: _: {
 37            enable = lib.mkDefault (config.programs.${name}.enable or false);
 38          })
 39          options.stylix.targets;
 40      };
 41    };
 42
 43    nixos.theme = {
 44      config,
 45      lib,
 46      pkgs,
 47      ...
 48    }: let
 49      cfg = config.gui;
 50      stl = config.stylix;
 51      inherit (cfg) enable;
 52    in {
 53      imports = [inputs.stylix.nixosModules.stylix];
 54
 55      options.gui = {
 56        enable = lib.mkEnableOption "Graphical Desktop Session";
 57        fancy = lib.mkEnableOption "Enable Fancy GUI Effects";
 58        display = lib.mkOption {
 59          description = "Main GUI Display";
 60          type = lib.types.str;
 61          default = "eDP-1";
 62          example = "HDMI-A-1";
 63        };
 64        wallpaper = lib.mkOption {
 65          type = lib.types.enum (lib.attrNames files.wallpapers);
 66          default = "Beauty";
 67          apply = image: files.wallpapers."${image}";
 68        };
 69      };
 70
 71      config = {
 72        stylix = {
 73          inherit enable;
 74          autoEnable = true;
 75          homeManagerIntegration = {
 76            autoImport = true;
 77            followSystem = true;
 78          };
 79
 80          image = cfg.wallpaper;
 81          polarity = "dark";
 82
 83          icons = {
 84            enable = true;
 85            package = lib.mkDefault pkgs.papirus-icon-theme;
 86            light = "Papirus-Dark";
 87            dark = "Papirus-Dark";
 88          };
 89
 90          cursor = {
 91            name = "Bibata-Original-Classic";
 92            package = pkgs.bibata-cursors;
 93            size = 28;
 94          };
 95
 96          opacity = {
 97            popups = 0.9;
 98            terminal = 0.9;
 99          };
100
101          targets = {
102            console.enable = true;
103            plymouth.enable = false;
104            chromium.enable = false;
105          };
106        };
107
108        home-manager.sharedModules = lib.optionals (!enable) [
109          config.stylix.homeManagerIntegration.module
110        ];
111
112        environment.systemPackages = lib.optionals enable [
113          stl.icons.package
114          stl.cursor.package
115        ];
116
117        programs.gnupg.agent.pinentryPackage = pkgs.pinentry-gtk2;
118      };
119    };
120
121    homeManager.theme = {
122      config,
123      lib,
124      ...
125    }: {
126      options.gui._unmanaged = lib.mkOption {
127        description = "Stylix targets handled manually";
128        type = lib.types.listOf lib.types.str;
129        default = [];
130      };
131
132      config.stylix = {
133        enable = lib.mkDefault true;
134        targets = lib.mkMerge [
135          {
136            gnome.enable = lib.mkDefault false;
137            firefox.enable = lib.mkDefault false;
138            vscode.enable = lib.mkDefault false;
139            obsidian.enable = lib.mkDefault false;
140            nixcord.enable = lib.mkDefault false;
141          }
142          (lib.genAttrs (lib.unique config.gui._unmanaged) (_: {enable = false;}))
143        ];
144      };
145    };
146  };
147}