From 1040eef2d1864b7e90fdd4c49884918fc9f9b01a Mon Sep 17 00:00:00 2001 From: arunoruto Date: Sun, 13 Oct 2024 23:51:29 +0000 Subject: [PATCH] Make stylix more modular --- flake.lock | 21 ++++- flake.nix | 30 +++---- modules/home-manager/home.nix | 1 + modules/home-manager/module.nix | 4 + modules/home-manager/theming/default.nix | 15 +++- modules/home-manager/theming/stylix.nix | 99 +++++++++++++++--------- modules/nixos/system/default.nix | 8 ++ modules/nixos/system/theming.nix | 56 ++++++++++++++ modules/nixos/user.nix | 25 ------ 9 files changed, 181 insertions(+), 78 deletions(-) create mode 100644 modules/nixos/system/theming.nix diff --git a/flake.lock b/flake.lock index c62f404..6686b85 100644 --- a/flake.lock +++ b/flake.lock @@ -662,7 +662,8 @@ "poetry2nix": "poetry2nix", "secrets": "secrets", "sops-nix": "sops-nix", - "stylix": "stylix" + "stylix": "stylix", + "wallpapers": "wallpapers" } }, "rust-overlay": { @@ -860,6 +861,24 @@ "repo": "treefmt-nix", "type": "github" } + }, + "wallpapers": { + "flake": false, + "locked": { + "lastModified": 1720967019, + "narHash": "sha256-uPaPAggLFmureDXqKcvwr2uMb24QuxQzbwCqTHNSIrg=", + "ref": "main", + "rev": "8815698729ceff1f97fae5ab2bf930a9dd682198", + "shallow": true, + "type": "git", + "url": "https://github.com/arunoruto/wallpapers.git" + }, + "original": { + "ref": "main", + "shallow": true, + "type": "git", + "url": "https://github.com/arunoruto/wallpapers.git" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index dfc5f78..48a0108 100644 --- a/flake.nix +++ b/flake.nix @@ -68,6 +68,10 @@ url = "git+https://github.com/arunoruto/secrets.nix.git?ref=main&shallow=1"; flake = false; }; + wallpapers = { + url = "git+https://github.com/arunoruto/wallpapers.git?ref=main&shallow=1"; + flake = false; + }; }; outputs = { @@ -80,9 +84,9 @@ ... } @ inputs: let system = "x86_64-linux"; - # theme = "catppuccin-macchiato"; - # theme = "tokyo-night-dark"; - theme = "gruvbox-material-dark-hard"; + # scheme = "catppuccin-macchiato"; + # scheme = "tokyo-night-dark"; + scheme = "gruvbox-material-dark-hard"; # image = "anime/jjk/satoru-gojo-jujutsu-kaisen-5k-ac.jpg"; # image = "anime/gruvbox/skull2.png"; image = "anime/gruvbox/boonies.png"; @@ -120,7 +124,7 @@ }; stylix-config = { stylix.image = nixpkgs.lib.mkDefault ./modules/home-manager/theming/wallpaper.png; - # theme = "tokyo-night-dark"; + # scheme = "tokyo-night-dark"; # image = "anime/jjk/satoru-gojo-jujutsu-kaisen-5k-ac.jpg"; }; nixos-modules = [ @@ -151,7 +155,7 @@ inherit system; specialArgs = { inherit inputs; - inherit theme; + inherit scheme; inherit image; username = "mirza"; }; @@ -169,7 +173,7 @@ inherit system; specialArgs = { inherit inputs; - inherit theme; + inherit scheme; inherit image; username = "mirza"; }; @@ -187,7 +191,7 @@ inherit system; specialArgs = { inherit inputs; - inherit theme; + inherit scheme; inherit image; username = "mirza"; }; @@ -205,7 +209,7 @@ inherit system; specialArgs = { inherit inputs; - inherit theme; + inherit scheme; inherit image; username = "mar"; }; @@ -225,7 +229,7 @@ inherit system; specialArgs = { inherit inputs; - inherit theme; + inherit scheme; inherit image; username = "mirza"; }; @@ -243,7 +247,7 @@ inherit system; specialArgs = { inherit inputs; - inherit theme; + inherit scheme; inherit image; username = "mirza"; }; @@ -260,7 +264,7 @@ inherit system; specialArgs = { inherit inputs; - inherit theme; + inherit scheme; inherit image; username = "mirza"; }; @@ -290,7 +294,7 @@ # # to pass through arguments to home.nix # extraSpecialArgs = { # inherit inputs; - # inherit theme; + # inherit scheme; # inherit image; # user = "mirza"; # }; @@ -307,7 +311,7 @@ ]; extraSpecialArgs = { inherit inputs; - inherit theme; + inherit scheme; inherit image; user = "mar"; }; diff --git a/modules/home-manager/home.nix b/modules/home-manager/home.nix index bb27ebe..5d3e481 100644 --- a/modules/home-manager/home.nix +++ b/modules/home-manager/home.nix @@ -19,6 +19,7 @@ in { ]; pc.enable = lib.mkDefault osConfig.gui.enable; + theming.enable = lib.mkDefault osConfig.gui.enable; environment.enable = true; # Allow unfree software diff --git a/modules/home-manager/module.nix b/modules/home-manager/module.nix index 19ed8c1..7fae25a 100644 --- a/modules/home-manager/module.nix +++ b/modules/home-manager/module.nix @@ -8,4 +8,8 @@ layout = osConfig.services.xserver.xkb.layout; variant = osConfig.services.xserver.xkb.variant; }; + theming = { + image = osConfig.theming.image; + scheme = osConfig.theming.scheme; + }; } diff --git a/modules/home-manager/theming/default.nix b/modules/home-manager/theming/default.nix index dda2ef7..83c7fc4 100644 --- a/modules/home-manager/theming/default.nix +++ b/modules/home-manager/theming/default.nix @@ -1,8 +1,19 @@ -{lib, ...}: { +{ + lib, + config, + ... +}: { imports = [ ./icons.nix ./stylix.nix ]; - theming.icons.enable = lib.mkDefault true; + options.theming.enable = lib.mkEnableOption "Setup local theming"; + + config = lib.mkIf config.theming.enable { + theming = { + icons.enable = lib.mkDefault true; + # stylix.enable = lib.mkDefault true; + }; + }; } diff --git a/modules/home-manager/theming/stylix.nix b/modules/home-manager/theming/stylix.nix index a889e3b..f88ac65 100644 --- a/modules/home-manager/theming/stylix.nix +++ b/modules/home-manager/theming/stylix.nix @@ -4,50 +4,75 @@ config, pkgs, lib, - theme, - image, ... -}: let - wallpapers = pkgs.fetchFromGitHub { - owner = "arunoruto"; - repo = "wallpapers"; - rev = "8815698729ceff1f97fae5ab2bf930a9dd682198"; - hash = "sha256-uPaPAggLFmureDXqKcvwr2uMb24QuxQzbwCqTHNSIrg="; - }; -in { +}: +# let +# wallpapers = pkgs.fetchFromGitHub { +# owner = "arunoruto"; +# repo = "wallpapers"; +# rev = "8815698729ceff1f97fae5ab2bf930a9dd682198"; +# hash = "sha256-uPaPAggLFmureDXqKcvwr2uMb24QuxQzbwCqTHNSIrg="; +# }; +# in +{ # imports = [ # inputs.stylix.homeManagerModules.stylix # ]; + options.theming = { + # enable = lib.mkEnableOption "Setup icons for theming"; + + scheme = lib.mkOption { + type = lib.types.str; + default = "catppuccin-macchiato"; + example = "gruvbox-material-dark-hard"; + description = '' + Theme to be used with Stylix throughout your config + Visit https://tinted-theming.github.io/base16-gallery/ to see some schemes + ''; + }; - stylix = { - enable = true; - base16Scheme = lib.mkDefault "${pkgs.base16-schemes}/share/themes/${theme}.yaml"; - # image = "${wallpapers}/art/kanagawa/kanagawa-van-gogh.jpg"; - image = "${wallpapers}/${image}"; - targets = { - nixvim.enable = false; - vscode.enable = true; + image = lib.mkOption { + type = lib.types.str; + default = "linux/nixos.png"; + example = "linux/nixos.png"; + description = '' + Wallpaper to be used with Stylix throughout your config + Visit https://github.com/arunoruto/wallpapers for possible images + ''; }; }; - home.file = { - ".config/stylix/palette.scss".text = '' - $base00: ${config.lib.stylix.colors.withHashtag.base00}; - $base01: ${config.lib.stylix.colors.withHashtag.base01}; - $base02: ${config.lib.stylix.colors.withHashtag.base02}; - $base03: ${config.lib.stylix.colors.withHashtag.base03}; - $base04: ${config.lib.stylix.colors.withHashtag.base04}; - $base05: ${config.lib.stylix.colors.withHashtag.base05}; - $base06: ${config.lib.stylix.colors.withHashtag.base06}; - $base07: ${config.lib.stylix.colors.withHashtag.base07}; - $base08: ${config.lib.stylix.colors.withHashtag.base08}; - $base09: ${config.lib.stylix.colors.withHashtag.base09}; - $base0A: ${config.lib.stylix.colors.withHashtag.base0A}; - $base0B: ${config.lib.stylix.colors.withHashtag.base0B}; - $base0C: ${config.lib.stylix.colors.withHashtag.base0C}; - $base0D: ${config.lib.stylix.colors.withHashtag.base0D}; - $base0E: ${config.lib.stylix.colors.withHashtag.base0E}; - $base0F: ${config.lib.stylix.colors.withHashtag.base0F}; - ''; + # config = lib.mkIf config.theming.enable { + config = { + stylix = { + enable = true; + base16Scheme = lib.mkDefault "${pkgs.base16-schemes}/share/themes/${config.theming.scheme}.yaml"; + image = "${inputs.wallpapers}/${config.theming.image}"; + targets = { + nixvim.enable = false; + vscode.enable = true; + }; + }; + + home.file = { + ".config/stylix/palette.scss".text = '' + $base00: ${config.lib.stylix.colors.withHashtag.base00}; + $base01: ${config.lib.stylix.colors.withHashtag.base01}; + $base02: ${config.lib.stylix.colors.withHashtag.base02}; + $base03: ${config.lib.stylix.colors.withHashtag.base03}; + $base04: ${config.lib.stylix.colors.withHashtag.base04}; + $base05: ${config.lib.stylix.colors.withHashtag.base05}; + $base06: ${config.lib.stylix.colors.withHashtag.base06}; + $base07: ${config.lib.stylix.colors.withHashtag.base07}; + $base08: ${config.lib.stylix.colors.withHashtag.base08}; + $base09: ${config.lib.stylix.colors.withHashtag.base09}; + $base0A: ${config.lib.stylix.colors.withHashtag.base0A}; + $base0B: ${config.lib.stylix.colors.withHashtag.base0B}; + $base0C: ${config.lib.stylix.colors.withHashtag.base0C}; + $base0D: ${config.lib.stylix.colors.withHashtag.base0D}; + $base0E: ${config.lib.stylix.colors.withHashtag.base0E}; + $base0F: ${config.lib.stylix.colors.withHashtag.base0F}; + ''; + }; }; } diff --git a/modules/nixos/system/default.nix b/modules/nixos/system/default.nix index 79df726..c0d7f2a 100644 --- a/modules/nixos/system/default.nix +++ b/modules/nixos/system/default.nix @@ -1,6 +1,8 @@ { # pkgs, lib, + image, + scheme, ... }: { imports = [ @@ -10,10 +12,16 @@ ./secure-boot.nix ./security.nix # ./systemd.nix + ./theming.nix ]; nix-utils.enable = lib.mkDefault true; secureboot.enable = lib.mkDefault false; + theming = { + # enable = lib.mkDefault true; + inherit image; + inherit scheme; + }; # This value determines the NixOS release from which the default # settings for stateful data, like file locations and database versions diff --git a/modules/nixos/system/theming.nix b/modules/nixos/system/theming.nix new file mode 100644 index 0000000..76e98b5 --- /dev/null +++ b/modules/nixos/system/theming.nix @@ -0,0 +1,56 @@ +{ + inputs, + pkgs, + lib, + config, + ... +}: { + imports = [inputs.stylix.nixosModules.stylix]; + + options.theming = { + # enable = lib.mkEnableOption "Enable eye-candy"; + + scheme = lib.mkOption { + type = lib.types.str; + default = "catppuccin-macchiato"; + example = "gruvbox-material-dark-hard"; + description = '' + Theme to be used with Stylix throughout your config + Visit https://tinted-theming.github.io/base16-gallery/ to see some schemes + ''; + }; + + image = lib.mkOption { + type = lib.types.str; + default = "linux/nixos.png"; + example = "linux/nixos.png"; + description = '' + Wallpaper to be used with Stylix throughout your config + Visit https://github.com/arunoruto/wallpapers for possible images + ''; + }; + }; + + # config = lib.mkIf config.theming.enable { + config = { + stylix = { + enable = true; + base16Scheme = lib.mkDefault "${pkgs.base16-schemes}/share/themes/${config.theming.scheme}.yaml"; + image = + # pkgs.fetchFromGitHub { + # owner = "arunoruto"; + # repo = "wallpapers"; + # rev = "8815698729ceff1f97fae5ab2bf930a9dd682198"; + # hash = "sha256-uPaPAggLFmureDXqKcvwr2uMb24QuxQzbwCqTHNSIrg="; + # } + inputs.wallpapers + "/${config.theming.image}"; + cursor = { + name = "catppuccin-macchiato-dark-cursors"; + package = pkgs.catppuccin-cursors.macchiatoDark; + }; + targets = { + # lightdm.enable = true; + }; + }; + }; +} diff --git a/modules/nixos/user.nix b/modules/nixos/user.nix index 465ed27..0f1ce3c 100644 --- a/modules/nixos/user.nix +++ b/modules/nixos/user.nix @@ -36,29 +36,4 @@ programs.zsh.enable = true; environment.sessionVariables.FLAKE = "/home/${username}/.config/flake"; - - imports = [ - inputs.stylix.nixosModules.stylix - ]; - - stylix = { - enable = true; - base16Scheme = lib.mkDefault "${pkgs.base16-schemes}/share/themes/${theme}.yaml"; - image = - pkgs.fetchFromGitHub { - owner = "arunoruto"; - repo = "wallpapers"; - rev = "8815698729ceff1f97fae5ab2bf930a9dd682198"; - hash = "sha256-uPaPAggLFmureDXqKcvwr2uMb24QuxQzbwCqTHNSIrg="; - } - + "/${image}"; - # + "/art/kanagawa/kanagawa-van-gogh.jpg"; - cursor = { - name = "catppuccin-macchiato-dark-cursors"; - package = pkgs.catppuccin-cursors.macchiatoDark; - }; - targets = { - lightdm.enable = true; - }; - }; }