diff --git a/Droidnix/README.org b/Droidnix/README.org index 3810f8de4..b0b302152 100644 --- a/Droidnix/README.org +++ b/Droidnix/README.org @@ -1348,24 +1348,38 @@ in ** =generated/modules/terminals/zsh.nix= This sets up the zsh in the terminal #+BEGIN_SRC nix :tangle generated/modules/terminals/zsh.nix :noweb tangle :mkdirp yes :eval never-html -# terminals/zsh.nix -{ lib, pkgs, ... }: +{ lib, ... }: let - username = "henrov"; + # --- Program-specific values --- + programName = "zsh"; + zshAssets = ../../../assets/system/conf/${programName}; + zshFiles = builtins.readDir zshAssets; + files = lib.genAttrs (builtins.attrNames zshFiles) (name: { + src = "${zshAssets}/${name}"; + }); + + # Enable toggle for this program + enableProgram = true; in { - # Export as a flake module - zsh = { config, pkgs, lib, ... }: { - options.mySystem.terminals.zsh.enable = - lib.mkEnableOption "Enable Zsh terminal with Oh-My-Zsh"; + # Top-level toggle for this program + options.enableZsh = + lib.mkEnableOption "Enable Zsh terminal with Oh-My-Zsh"; - config = lib.mkIf (config.mySystem.terminals.zsh.enable or false) { - home-manager.users.${username} = { - programs.zsh.enable = true; - programs.zsh.enableCompletion = true; + # Configuration applied only if enabled + config = lib.mkIf enableProgram { + myApps = { + zsh = { + enable = true; + assetsDir = zshAssets; + files = files; - programs.zsh.ohMyZsh = { + # Reference default user + user = config.defaultUser or "henrov"; + + # Zsh-specific settings + ohMyZsh = { enable = true; theme = "catppuccin-mocha"; plugins = [ @@ -1379,7 +1393,7 @@ in ]; }; - programs.zsh.initExtra = '' + initExtra = '' # Catppuccin Mocha colors local mocha_base="#1E1E2E" local mocha_surface0="#313244" @@ -1402,9 +1416,9 @@ in PROMPT='%{$fg[$mocha_blue]%}%n%{$reset_color%}@%{$fg[$mocha_peach]%}%m%{$reset_color%} %{$fg[$mocha_lavender]%}%~%{$reset_color%} %{$fg[$mocha_red]%}$%{$reset_color%} ' RPROMPT='%{$fg[$mocha_green]%}%T%{$reset_color%}' - # Source zsh-syntax-highlighting - if [ -f ${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]; then - source ${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh + # Source zsh-syntax-highlighting if present + if [ -f ${files."zsh-syntax-highlighting".src} ]; then + source ${files."zsh-syntax-highlighting".src} fi ''; }; diff --git a/Droidnix/generated/modules/terminals/zsh.nix b/Droidnix/generated/modules/terminals/zsh.nix index 88628f279..5f784d816 100644 --- a/Droidnix/generated/modules/terminals/zsh.nix +++ b/Droidnix/generated/modules/terminals/zsh.nix @@ -1,21 +1,35 @@ -# terminals/zsh.nix -{ lib, pkgs, ... }: +{ lib, ... }: let - username = "henrov"; + # --- Program-specific values --- + programName = "zsh"; + zshAssets = ../../../assets/system/conf/${programName}; + zshFiles = builtins.readDir zshAssets; + files = lib.genAttrs (builtins.attrNames zshFiles) (name: { + src = "${zshAssets}/${name}"; + }); + + # Enable toggle for this program + enableProgram = true; in { - # Export as a flake module - zsh = { config, pkgs, lib, ... }: { - options.mySystem.terminals.zsh.enable = - lib.mkEnableOption "Enable Zsh terminal with Oh-My-Zsh"; + # Top-level toggle for this program + options.enableZsh = + lib.mkEnableOption "Enable Zsh terminal with Oh-My-Zsh"; - config = lib.mkIf (config.mySystem.terminals.zsh.enable or false) { - home-manager.users.${username} = { - programs.zsh.enable = true; - programs.zsh.enableCompletion = true; + # Configuration applied only if enabled + config = lib.mkIf enableProgram { + myApps = { + zsh = { + enable = true; + assetsDir = zshAssets; + files = files; - programs.zsh.ohMyZsh = { + # Reference default user + user = config.defaultUser or "henrov"; + + # Zsh-specific settings + ohMyZsh = { enable = true; theme = "catppuccin-mocha"; plugins = [ @@ -29,7 +43,7 @@ in ]; }; - programs.zsh.initExtra = '' + initExtra = '' # Catppuccin Mocha colors local mocha_base="#1E1E2E" local mocha_surface0="#313244" @@ -52,9 +66,9 @@ in PROMPT='%{$fg[$mocha_blue]%}%n%{$reset_color%}@%{$fg[$mocha_peach]%}%m%{$reset_color%} %{$fg[$mocha_lavender]%}%~%{$reset_color%} %{$fg[$mocha_red]%}$%{$reset_color%} ' RPROMPT='%{$fg[$mocha_green]%}%T%{$reset_color%}' - # Source zsh-syntax-highlighting - if [ -f ${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]; then - source ${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh + # Source zsh-syntax-highlighting if present + if [ -f ${files."zsh-syntax-highlighting".src} ]; then + source ${files."zsh-syntax-highlighting".src} fi ''; };