Compare commits

..

2 commits

Author SHA1 Message Date
32971e91bf
treewide: theme module refactor
I decided to refactor how the theme module works. The idea is, that I
wanted originally a module that I could give a base16 scheme name to,
and use that globally in my config. However, scheme only took the base16
scheme name without any checks, which was pretty bad. I ended up
creating a new option, schemeName, that scheme is computed from. It then
makes the whole configuration cleaner, and avoids long inputs
interpolations with the scheme name.
2024-11-21 15:51:01 +01:00
6d643f903c
treewide: import custom lib as lib', simplify mkSystem
I decided to import my custom lib as lib' as it makes it easier to read
and differentiate from lib. I also removed unnecessary imports from my
mkSystem function (that I actually put directly inside
hosts/default.nix, as that made more sense), since system is not needed
anymore (already set in hardware-configuration.nix), and the only
required argument is inputs, that will be then parsed automatically by
nixosSystem.
2024-11-21 14:54:22 +01:00
10 changed files with 35 additions and 54 deletions

View file

@ -24,10 +24,7 @@
}; };
}); });
formatter = eachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper); formatter = eachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper);
nixosConfigurations = let nixosConfigurations = import ./hosts {inherit inputs;};
lib' = import ./lib {inherit inputs lib';};
in
import ./hosts {inherit inputs lib';};
packages = eachSystem (pkgs: import ./pkgs {inherit inputs pkgs;}); packages = eachSystem (pkgs: import ./pkgs {inherit inputs pkgs;});
deploy.nodes = import ./nodes {inherit inputs;}; deploy.nodes = import ./nodes {inherit inputs;};
checks = builtins.mapAttrs (_: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib; checks = builtins.mapAttrs (_: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;

View file

@ -15,7 +15,7 @@
font = "monospace:size=14"; font = "monospace:size=14";
}; };
colors = let colors = let
inherit (inputs.basix.schemeData.base16.${osConfig.theme.scheme}) palette; inherit (osConfig.theme.scheme) palette;
in { in {
background = "${palette.base00}ff"; background = "${palette.base00}ff";
text = "${palette.base05}ff"; text = "${palette.base05}ff";

View file

@ -1,12 +1,11 @@
{ {
inputs,
pkgs, pkgs,
config, config,
osConfig, osConfig,
lib, lib,
... ...
}: let }: let
isDark = inputs.basix.schemeData.base16.${osConfig.theme.scheme}.variant == "dark"; isDark = osConfig.theme.scheme.variant == "dark";
in { in {
home.pointerCursor = { home.pointerCursor = {
inherit (osConfig.theme.cursorTheme) name package size; inherit (osConfig.theme.cursorTheme) name package size;

View file

@ -1,13 +1,11 @@
{ {
inputs,
lib, lib,
pkgs, pkgs,
config, config,
osConfig, osConfig,
... ...
}: let }: let
inherit (inputs.basix.schemeData.base16.${osConfig.theme.scheme}) palette; inherit (osConfig.theme.scheme) palette;
inherit (lib) getExe mkIf;
in { in {
imports = [./binds.nix]; imports = [./binds.nix];

View file

@ -1,10 +1,9 @@
{ {
inputs,
pkgs, pkgs,
osConfig, osConfig,
... ...
}: let }: let
inherit (inputs.basix.schemeData.base16.${osConfig.theme.scheme}) palette; inherit (osConfig.theme.scheme) palette;
in { in {
# requires `security.pam.services.swaylock = { };` at the system level or else # requires `security.pam.services.swaylock = { };` at the system level or else
# unlock will not work. # unlock will not work.

View file

@ -1,10 +1,9 @@
{ {
inputs,
lib, lib,
osConfig, osConfig,
... ...
}: let }: let
inherit (inputs.basix.schemeData.base16.${osConfig.theme.scheme}) palette; inherit (osConfig.theme.scheme) palette;
inherit (builtins) concatStringsSep; inherit (builtins) concatStringsSep;
inherit (lib) mapAttrsToList; inherit (lib) mapAttrsToList;

View file

@ -1,5 +1,4 @@
{ {
inputs,
osConfig, osConfig,
config, config,
lib, lib,
@ -17,7 +16,7 @@
inherit (lib) mapAttrs; inherit (lib) mapAttrs;
inherit (lib.strings) removePrefix; inherit (lib.strings) removePrefix;
# because someone thought this was a great idea: https://github.com/tinted-theming/schemes/commit/61058a8d2e2bd4482b53d57a68feb56cdb991f0b # because someone thought this was a great idea: https://github.com/tinted-theming/schemes/commit/61058a8d2e2bd4482b53d57a68feb56cdb991f0b
palette = mapAttrs (_: color: removePrefix "#" color) inputs.basix.schemeData.base16.${osConfig.theme.scheme}.palette; palette = mapAttrs (_: color: removePrefix "#" color) osConfig.theme.scheme.palette;
in { in {
background = palette.base00; background = palette.base00;
foreground = palette.base05; foreground = palette.base05;

View file

@ -1,12 +1,12 @@
{ {inputs, ...}: let
inputs, lib' = import ../lib;
lib', mkSystem = args:
... inputs.nixpkgs.lib.nixosSystem {
}: let specialArgs = {inherit inputs lib';};
inherit (lib') mkSystem; modules = args.modules or [];
};
in { in {
vamos = mkSystem { vamos = mkSystem {
system = "x86_64-linux";
modules = [ modules = [
./vamos ./vamos
../modules ../modules
@ -15,7 +15,6 @@ in {
}; };
solaire = mkSystem { solaire = mkSystem {
system = "x86_64-linux";
modules = [ modules = [
./solaire ./solaire
../modules ../modules
@ -23,7 +22,6 @@ in {
}; };
anastacia = mkSystem { anastacia = mkSystem {
system = "x86_64-linux";
modules = [ modules = [
./anastacia ./anastacia
]; ];

View file

@ -1,9 +1,4 @@
{ {lib, ...}: let
inputs,
lib',
...
}: let
inherit (inputs.nixpkgs) lib;
# convert rrggbb hex to rgba(r, g, b, a) # convert rrggbb hex to rgba(r, g, b, a)
rgba = c: let rgba = c: let
r = toString (hexToDec (builtins.substring 0 2 c)); r = toString (hexToDec (builtins.substring 0 2 c));
@ -89,23 +84,6 @@
# Create a KDE konsole color scheme from base16 colors # Create a KDE konsole color scheme from base16 colors
mkKonsoleColorScheme = pkgs: scheme: mkKonsoleColorScheme = pkgs: scheme:
pkgs.writeText "${scheme.name}.colorscheme" (schemeToKonsole scheme); pkgs.writeText "${scheme.name}.colorscheme" (schemeToKonsole scheme);
# https://github.com/diniamo/niqs/blob/caf396bb470619fa06936a379eec6e283c3c3d95/lib/default.nix#L13-L35C7
mkSystem = {system, ...} @ args:
lib.nixosSystem {
system = null;
specialArgs = {inherit inputs;};
modules =
[
{
_module.args = {
inherit system lib';
};
nixpkgs = {inherit system;};
}
]
++ args.modules or [];
};
in { in {
inherit mkKonsoleColorScheme rgba mkSystem; inherit mkKonsoleColorScheme rgba;
} }

View file

@ -1,22 +1,33 @@
{ {
inputs,
config,
lib, lib,
pkgs, pkgs,
... ...
}: let }: let
inherit (lib) mkEnableOption mkOption; inherit (lib) mkEnableOption mkOption mkIf attrNames;
inherit (lib.types) string path package; inherit (lib.types) path package enum;
cfg = config.theme;
in { in {
imports = [./gtk.nix]; imports = [./gtk.nix];
options.theme = { options.theme = {
enable = mkEnableOption "theme"; enable = mkEnableOption "theme";
scheme = mkOption { schemeName = mkOption {
description = '' description = ''
Name of the tinted-scheming color scheme to use. Name of the tinted-scheming color scheme to use.
''; '';
type = string; type = enum (attrNames inputs.basix.schemeData.base16);
example = lib.literalExpression "catppuccin-macchiato"; example = "catppuccin-macchiato";
default = "catppuccin-macchiato"; default = "catppuccin-macchiato";
}; };
scheme = mkOption {
description = ''
Resolved scheme from the tinted-scheming library.
'';
type = lib.types.attrs;
};
wallpaper = mkOption { wallpaper = mkOption {
description = '' description = ''
Location of the wallpaper that will be used throughout the system. Location of the wallpaper that will be used throughout the system.
@ -51,4 +62,7 @@ in {
}; };
}; };
}; };
config.theme = mkIf cfg.enable {
scheme = inputs.basix.schemeData.base16.${config.theme.schemeName};
};
} }