aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArpit Chakladar <arpitchakladar@gmail.com>2026-09-18 06:17:21 +0530
committerArpit Chakladar <arpitchakladar@gmail.com>2026-09-18 06:17:21 +0530
commit53eac37422f77750adbc801f71b85ab04cf2b7f9 (patch)
treec8ea93c066eee28389aeb14e15f6c37a3e38b276
parent453c4a6002e51265f5bcaef3bf53a1362f4c7b6a (diff)
downloadhome-manager-config-53eac37422f77750adbc801f71b85ab04cf2b7f9.tar.gz
home-manager-config-53eac37422f77750adbc801f71b85ab04cf2b7f9.zip
chore(colors/base16): refactoring
-rw-r--r--modules/colors/base16/default.nix57
-rw-r--r--modules/colors/base16/onedark-dark.nix77
-rw-r--r--modules/colors/default.nix7
-rw-r--r--modules/default.nix2
-rw-r--r--modules/system/nix-update/default.nix4
5 files changed, 84 insertions, 63 deletions
diff --git a/modules/colors/base16/default.nix b/modules/colors/base16/default.nix
new file mode 100644
index 0000000..1262b53
--- /dev/null
+++ b/modules/colors/base16/default.nix
@@ -0,0 +1,57 @@
+# Provide options/configurations for other modules to use base16 colorschemes
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
+let
+ schemeFiles = {
+ "onedark-dark" = ./onedark-dark.nix;
+ };
+
+ schemeFile =
+ schemeFiles.${config.colors.base16} or (throw "Unknown color scheme: ${config.colors.base16}");
+
+ colors = import schemeFile { };
+
+ withHashtag = lib.mapAttrs (_: v: "#${v}") colors;
+ colorNames = builtins.attrNames colors;
+
+ processTemplate =
+ template:
+ let
+ content = if builtins.typeOf template == "path" then builtins.readFile template else template;
+ replaced = builtins.replaceStrings (map (name: "@@${name}@@") colorNames) (map (
+ name: colors.${name}
+ ) colorNames) content;
+ in
+ replaced;
+in
+{
+ options = {
+ colors.base16 = lib.mkOption {
+ type = lib.types.str;
+ default = "onedark-dark";
+ description = "Base16 color scheme to use";
+ };
+
+ scheme = lib.mkOption {
+ type = lib.types.unspecified;
+ description = "Color scheme providing withHashtag and template function";
+ };
+ };
+
+ config = {
+ scheme = {
+ inherit withHashtag;
+ __functor =
+ self:
+ {
+ template,
+ extension ? "",
+ }:
+ pkgs.writeText "themed${extension}" (processTemplate template);
+ };
+ };
+}
diff --git a/modules/colors/base16/onedark-dark.nix b/modules/colors/base16/onedark-dark.nix
index 44c8fce..f0ff329 100644
--- a/modules/colors/base16/onedark-dark.nix
+++ b/modules/colors/base16/onedark-dark.nix
@@ -1,63 +1,20 @@
# OneDark Dark color scheme
-# Replaces base16.nix with direct string replacement
+{ }:
{
- config,
- lib,
- pkgs,
- ...
-}:
-let
- colors = {
- base00 = "000000";
- base01 = "1c1f24";
- base02 = "2c313a";
- base03 = "434852";
- base04 = "565c64";
- base05 = "abb2bf";
- base06 = "b6bdca";
- base07 = "c8ccd4";
- base08 = "ef596f";
- base09 = "d19a66";
- base0A = "e5c07b";
- base0B = "89ca78";
- base0C = "2bbac5";
- base0D = "61afef";
- base0E = "d55fde";
- base0F = "be5046";
- };
-
- withHashtag = lib.mapAttrs (_: v: "#${v}") colors;
-
- colorNames = builtins.attrNames colors;
-
- processTemplate =
- template:
- let
- content = if builtins.typeOf template == "path" then builtins.readFile template else template;
- replaced = builtins.replaceStrings (map (name: "@@${name}@@") colorNames) (map (
- name: colors.${name}
- ) colorNames) content;
- in
- replaced;
-in
-{
- options.colors.onedark-dark = {
- enable = lib.mkEnableOption "Enables the OneDark Dark color scheme.";
- };
-
- options.scheme = lib.mkOption {
- type = lib.types.unspecified;
- description = "Color scheme providing withHashtag and template function";
- };
-
- config.scheme = lib.mkIf config.colors.onedark-dark.enable {
- inherit withHashtag;
- __functor =
- self:
- {
- template,
- extension ? "",
- }:
- pkgs.writeText "themed${extension}" (processTemplate template);
- };
+ base00 = "000000";
+ base01 = "1c1f24";
+ base02 = "2c313a";
+ base03 = "434852";
+ base04 = "565c64";
+ base05 = "abb2bf";
+ base06 = "b6bdca";
+ base07 = "c8ccd4";
+ base08 = "ef596f";
+ base09 = "d19a66";
+ base0A = "e5c07b";
+ base0B = "89ca78";
+ base0C = "2bbac5";
+ base0D = "61afef";
+ base0E = "d55fde";
+ base0F = "be5046";
}
diff --git a/modules/colors/default.nix b/modules/colors/default.nix
new file mode 100644
index 0000000..1bf48b5
--- /dev/null
+++ b/modules/colors/default.nix
@@ -0,0 +1,7 @@
+# Configuration wide colorscheme configurations
+{ ... }:
+{
+ imports = [
+ ./base16
+ ];
+}
diff --git a/modules/default.nix b/modules/default.nix
index eb05dbf..7db3d92 100644
--- a/modules/default.nix
+++ b/modules/default.nix
@@ -2,7 +2,7 @@
{ ... }:
{
imports = [
- ./colors/base16/onedark-dark.nix
+ ./colors
./communication
./desktop
./development
diff --git a/modules/system/nix-update/default.nix b/modules/system/nix-update/default.nix
index b597245..9f93a4e 100644
--- a/modules/system/nix-update/default.nix
+++ b/modules/system/nix-update/default.nix
@@ -27,7 +27,7 @@ let
installShellCompletion --zsh --name _nix-update ${pkgs.writeText "nix-update.zsh" (builtins.readFile ./nix-update.zsh)}
'';
- nixUpdateScriptPkg = pkgs.symlinkJoin {
+ nixUpdate = pkgs.symlinkJoin {
name = "nix-update";
paths = [
nixUpdateScript
@@ -43,7 +43,7 @@ in
package = lib.mkOption {
type = lib.types.package;
readOnly = true;
- default = nixUpdateScriptPkg;
+ default = nixUpdate;
description = "The nix-update script package.";
};
};