Skip to content

Commit

Permalink
Make stylix more modular
Browse files Browse the repository at this point in the history
  • Loading branch information
arunoruto committed Oct 13, 2024
1 parent b87050c commit 1040eef
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 78 deletions.
21 changes: 20 additions & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 17 additions & 13 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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";
Expand Down Expand Up @@ -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 = [
Expand Down Expand Up @@ -151,7 +155,7 @@
inherit system;
specialArgs = {
inherit inputs;
inherit theme;
inherit scheme;
inherit image;
username = "mirza";
};
Expand All @@ -169,7 +173,7 @@
inherit system;
specialArgs = {
inherit inputs;
inherit theme;
inherit scheme;
inherit image;
username = "mirza";
};
Expand All @@ -187,7 +191,7 @@
inherit system;
specialArgs = {
inherit inputs;
inherit theme;
inherit scheme;
inherit image;
username = "mirza";
};
Expand All @@ -205,7 +209,7 @@
inherit system;
specialArgs = {
inherit inputs;
inherit theme;
inherit scheme;
inherit image;
username = "mar";
};
Expand All @@ -225,7 +229,7 @@
inherit system;
specialArgs = {
inherit inputs;
inherit theme;
inherit scheme;
inherit image;
username = "mirza";
};
Expand All @@ -243,7 +247,7 @@
inherit system;
specialArgs = {
inherit inputs;
inherit theme;
inherit scheme;
inherit image;
username = "mirza";
};
Expand All @@ -260,7 +264,7 @@
inherit system;
specialArgs = {
inherit inputs;
inherit theme;
inherit scheme;
inherit image;
username = "mirza";
};
Expand Down Expand Up @@ -290,7 +294,7 @@
# # to pass through arguments to home.nix
# extraSpecialArgs = {
# inherit inputs;
# inherit theme;
# inherit scheme;
# inherit image;
# user = "mirza";
# };
Expand All @@ -307,7 +311,7 @@
];
extraSpecialArgs = {
inherit inputs;
inherit theme;
inherit scheme;
inherit image;
user = "mar";
};
Expand Down
1 change: 1 addition & 0 deletions modules/home-manager/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions modules/home-manager/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}
15 changes: 13 additions & 2 deletions modules/home-manager/theming/default.nix
Original file line number Diff line number Diff line change
@@ -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;
};
};
}
99 changes: 62 additions & 37 deletions modules/home-manager/theming/stylix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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};
'';
};
};
}
8 changes: 8 additions & 0 deletions modules/nixos/system/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
# pkgs,
lib,
image,
scheme,
...
}: {
imports = [
Expand All @@ -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
Expand Down
56 changes: 56 additions & 0 deletions modules/nixos/system/theming.nix
Original file line number Diff line number Diff line change
@@ -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;
};
};
};
}
Loading

0 comments on commit 1040eef

Please sign in to comment.