Update themes module

Setting themes should be in `modules.themes.themes` for namespacing and
the module itself is gaining options.
This commit is contained in:
foo-dogsquared 2021-12-25 20:32:52 +08:00
parent 9eac509b26
commit 6d33406492
3 changed files with 27 additions and 27 deletions

View File

@ -27,8 +27,11 @@
virtualization.enable = true; virtualization.enable = true;
}; };
editors.neovim.enable = true; editors.neovim.enable = true;
themes.a-happy-gnome.enable = true;
users.users.foo-dogsquared = {}; users.users.foo-dogsquared = {};
themes = {
disableLimit = true;
themes.a-happy-gnome.enable = true;
};
hardware-setup.backup-archive.enable = true; hardware-setup.backup-archive.enable = true;
}; };

View File

@ -4,7 +4,7 @@
# See https://github.com/NixOS/nixpkgs/issues/54150 for more details. # See https://github.com/NixOS/nixpkgs/issues/54150 for more details.
let let
name = "a-happy-gnome"; name = "a-happy-gnome";
cfg = config.modules.themes.a-happy-gnome; cfg = config.modules.themes.themes.a-happy-gnome;
dconf = pkgs.gnome3.dconf; dconf = pkgs.gnome3.dconf;
customDconfDb = pkgs.stdenv.mkDerivation { customDconfDb = pkgs.stdenv.mkDerivation {
name = "${name}-dconf-db"; name = "${name}-dconf-db";
@ -12,7 +12,7 @@ let
}; };
in in
{ {
options.modules.themes.a-happy-gnome.enable = lib.mkEnableOption "'A happy GNOME', foo-dogsquared's configuration of GNOME desktop environment"; options.modules.themes.themes.a-happy-gnome.enable = lib.mkEnableOption "'A happy GNOME', foo-dogsquared's configuration of GNOME desktop environment";
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.xserver.enable = true; services.xserver.enable = true;
@ -41,21 +41,6 @@ in
gnome-tour gnome-tour
]); ]);
programs.dconf = {
enable = true;
# This is an internal function which is subject to change.
# However, this seems to be in for some time but still, be wary.
# The function is found on `nixos/programs/dconf.nix` from nixpkgs.
profiles.customGnomeConfig = pkgs.writeTextFile {
name = "${name}-dconf-profile";
text = ''
user-db:user
file-db:${customDconfDb}
'';
};
};
# I'm pretty sure this is already done but just to make sure. # I'm pretty sure this is already done but just to make sure.
services.gnome.chrome-gnome-shell.enable = true; services.gnome.chrome-gnome-shell.enable = true;

View File

@ -3,14 +3,26 @@
# You can also show your desktop being modularized like this. # You can also show your desktop being modularized like this.
{ config, options, lib, pkgs, ... }: { config, options, lib, pkgs, ... }:
let let cfg = config.modules.themes;
cfg = config.modules.themes; in {
in options.modules.themes.disableLimit = lib.mkOption {
{ type = lib.types.bool;
default = false;
description = ''
Whether to unlock the limit for themes. Since themes may overlap with
packages and configurations, this should be enabled at your own risk.
'';
};
imports = lib.mapAttrsToList (n: v: import v)
(lib.filterAttrs (n: v: n != "default") (lib.filesToAttr ./.));
config = {
assertions = [{ assertions = [{
assertion = (lib.countAttrs (_: theme: theme.enable) cfg) < 2; assertion =
let enabledThemes = lib.countAttrs (_: theme: theme.enable) cfg.themes;
in cfg.disableLimit && (enabledThemes < 2);
message = "Can't have more than one theme enabled at any given time."; message = "Can't have more than one theme enabled at any given time.";
}]; }];
};
imports = lib.mapAttrsToList (n: v: import v) (lib.filterAttrs (n: v: n != "default") (lib.filesToAttr ./.));
} }