From 00e3ea65c8acd2c16887f1fd64a733e090e66aaf Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Sat, 14 Jun 2025 19:15:48 +0800 Subject: [PATCH] feat(home): move cli config to homes and use home-manager modules --- homes/x86_64-linux/rafiq/cli/fetch.nix | 26 +++++++ homes/x86_64-linux/rafiq/cli/file-browser.nix | 20 +++++ homes/x86_64-linux/rafiq/cli/finder.nix | 6 ++ .../x86_64-linux/rafiq/cli/multiplexer.nix | 8 +- homes/x86_64-linux/rafiq/cli/shell.nix | 42 +++++++++++ .../x86_64-linux/rafiq/cli/utilities/git.nix | 24 ++++++ .../x86_64-linux/rafiq/cli/utilities/misc.nix | 53 +++++++++++++ homes/x86_64-linux/rafiq/default.nix | 46 +----------- modules/home/cli/default.nix | 74 ------------------- modules/home/cli/fetch/default.nix | 31 -------- modules/home/cli/file-browser/default.nix | 23 ------ modules/home/cli/finder/default.nix | 11 --- modules/home/cli/multiplexer/default.nix | 14 ---- modules/home/cli/shell/default.nix | 38 ---------- modules/home/cli/utilities/default.nix | 3 - modules/home/cli/utilities/git.nix | 27 ------- modules/home/default.nix | 23 +++++- 17 files changed, 198 insertions(+), 271 deletions(-) create mode 100644 homes/x86_64-linux/rafiq/cli/fetch.nix create mode 100644 homes/x86_64-linux/rafiq/cli/file-browser.nix create mode 100644 homes/x86_64-linux/rafiq/cli/finder.nix rename modules/home/cli/multiplexer/zellij.nix => homes/x86_64-linux/rafiq/cli/multiplexer.nix (93%) create mode 100644 homes/x86_64-linux/rafiq/cli/shell.nix create mode 100644 homes/x86_64-linux/rafiq/cli/utilities/git.nix create mode 100644 homes/x86_64-linux/rafiq/cli/utilities/misc.nix delete mode 100644 modules/home/cli/default.nix delete mode 100644 modules/home/cli/fetch/default.nix delete mode 100644 modules/home/cli/file-browser/default.nix delete mode 100644 modules/home/cli/finder/default.nix delete mode 100644 modules/home/cli/multiplexer/default.nix delete mode 100644 modules/home/cli/shell/default.nix delete mode 100644 modules/home/cli/utilities/default.nix delete mode 100644 modules/home/cli/utilities/git.nix diff --git a/homes/x86_64-linux/rafiq/cli/fetch.nix b/homes/x86_64-linux/rafiq/cli/fetch.nix new file mode 100644 index 0000000..112892a --- /dev/null +++ b/homes/x86_64-linux/rafiq/cli/fetch.nix @@ -0,0 +1,26 @@ +{ lib, pkgs, ... }: +let + inherit (lib) singleton; +in +{ + home = { + packages = singleton pkgs.fastfetch; + sessionVariables.FETCH = "hyfetch"; + shellAliases.fetch = "hyfetch"; + }; + programs.hyfetch = { + enable = true; + settings = { + preset = "bisexual"; + mode = "rgb"; + light_dark = "dark"; + lightness = 0.5; + color_align = { + mode = "horizontal"; + custom_colors = [ ]; + fore_back = null; + }; + backend = "fastfetch"; + }; + }; +} diff --git a/homes/x86_64-linux/rafiq/cli/file-browser.nix b/homes/x86_64-linux/rafiq/cli/file-browser.nix new file mode 100644 index 0000000..00a4034 --- /dev/null +++ b/homes/x86_64-linux/rafiq/cli/file-browser.nix @@ -0,0 +1,20 @@ +{ + home.sessionVariables.FILE_BROWSER = "yazi"; + programs.yazi = { + enable = true; + shellWrapperName = "t"; + settings = { + mgr = { + sort_by = "natural"; + }; + opener = { + play = [ + { + run = "vlc \"$@\""; + desc = "Open"; + } + ]; + }; + }; + }; +} diff --git a/homes/x86_64-linux/rafiq/cli/finder.nix b/homes/x86_64-linux/rafiq/cli/finder.nix new file mode 100644 index 0000000..983fc8d --- /dev/null +++ b/homes/x86_64-linux/rafiq/cli/finder.nix @@ -0,0 +1,6 @@ +{ + programs.fzf = { + enable = true; + enableZshIntegration = true; + }; +} diff --git a/modules/home/cli/multiplexer/zellij.nix b/homes/x86_64-linux/rafiq/cli/multiplexer.nix similarity index 93% rename from modules/home/cli/multiplexer/zellij.nix rename to homes/x86_64-linux/rafiq/cli/multiplexer.nix index 61ade89..6eb8971 100644 --- a/modules/home/cli/multiplexer/zellij.nix +++ b/homes/x86_64-linux/rafiq/cli/multiplexer.nix @@ -1,11 +1,7 @@ -{ - config, - pkgs, - osConfig, -}: +{ pkgs, osConfig, ... }: { home.sessionVariables.MULTIPLEXER = "zellij"; - home.persistence."/persist/home/${config.snowfallorg.user.name}".directories = [ "/.cache/zellij" ]; + persistDirs = [ "/.cache/zellij" ]; programs.zellij = { enable = true; enableZshIntegration = true; diff --git a/homes/x86_64-linux/rafiq/cli/shell.nix b/homes/x86_64-linux/rafiq/cli/shell.nix new file mode 100644 index 0000000..186a91b --- /dev/null +++ b/homes/x86_64-linux/rafiq/cli/shell.nix @@ -0,0 +1,42 @@ +{ lib, pkgs, ... }: +let + inherit (builtins) toString; + inherit (lib) mkOrder; + screensaverTimeout = toString 100; + screensaverCommand = "${pkgs.cbonsai}/bin/cbonsai -S -w 0.1 -L 40 -M 2 -b 2"; +in +{ + home.shell.enableShellIntegration = true; + home.sessionVariables.SHELL = "zsh"; + programs.zsh = { + enable = true; + enableVteIntegration = true; + syntaxHighlighting.enable = true; + historySubstringSearch.enable = true; + history = { + append = true; + extended = true; + ignoreDups = true; + ignoreSpace = true; + save = 10000; + share = true; + size = 10000; + }; + }; + programs.zsh.initContent = + mkOrder 1200 + # zsh + '' + precmd() { + TMOUT=${screensaverTimeout} + } + + TRAPALRM() { + TMOUT=1 + ${screensaverCommand} + # If we exit, assume the previous command was exited out of + TMOUT=${screensaverTimeout} + zle reset-prompt + } + ''; +} diff --git a/homes/x86_64-linux/rafiq/cli/utilities/git.nix b/homes/x86_64-linux/rafiq/cli/utilities/git.nix new file mode 100644 index 0000000..c1730bb --- /dev/null +++ b/homes/x86_64-linux/rafiq/cli/utilities/git.nix @@ -0,0 +1,24 @@ +{ + home.sessionVariables.GIT_CONFIG_GLOBAL = "$HOME/.config/git/config"; + home.shellAliases = { + gs = "git status"; + gc = "git commit"; + gcam = "git commit -am"; + gu = "git push"; + gy = "git pull"; + }; + programs.git = { + enable = true; + userName = "Mohammad Rafiq"; + userEmail = "rafiq@rrv.sh"; + signing.key = "~/.ssh/id_ed25519.pub"; + signing.signByDefault = true; + extraConfig = { + init.defaultBranch = "prime"; + push.autoSetupRemote = true; + pull.rebase = false; + core.editor = "$EDITOR"; + gpg.format = "ssh"; + }; + }; +} diff --git a/homes/x86_64-linux/rafiq/cli/utilities/misc.nix b/homes/x86_64-linux/rafiq/cli/utilities/misc.nix new file mode 100644 index 0000000..7bb3251 --- /dev/null +++ b/homes/x86_64-linux/rafiq/cli/utilities/misc.nix @@ -0,0 +1,53 @@ +{ inputs, pkgs, ... }: +{ + programs = { + nh.enable = true; + tealdeer.enable = true; + tealdeer.settings.updates.auto_update = true; + pay-respects.enable = true; + direnv = { + enable = true; + nix-direnv.enable = true; + }; + starship = { + enable = true; + settings = { + add_newline = false; + format = '' + $directory$character + ''; + right_format = '' + $all + ''; + git_branch.format = "[$symbol$branch(:$remote_branch)]($style) "; + shlvl.disabled = false; + hostname.disabled = true; + username.disabled = true; + }; + }; + }; + home = { + shellAliases = { + v = "nvim"; + e = "edit"; + cd = "z"; + ai = "aichat -r %shell% -e"; + }; + packages = with pkgs; [ + aichat + devenv + pantheon.rebuild + pantheon.deploy + pantheon.edit + pantheon.commit + pantheon.check + inputs.nixspect.packages."x86_64-linux".nixspect + ]; + }; + + xdg.configFile."aichat/config.yaml".text = '' + model: gemini:gemini-2.0-flash + clients: + - type: gemini + ''; +} diff --git a/homes/x86_64-linux/rafiq/default.nix b/homes/x86_64-linux/rafiq/default.nix index 7975baf..6d25b6f 100644 --- a/homes/x86_64-linux/rafiq/default.nix +++ b/homes/x86_64-linux/rafiq/default.nix @@ -1,5 +1,4 @@ { - pkgs, inputs, osConfig, lib, @@ -26,7 +25,9 @@ let }; in { - imports = (optional osConfig.desktop.enable (import-tree ./desktop)) ++ singleton (import-tree ./cli); + imports = + (optional osConfig.desktop.enable (import-tree ./desktop)) + ++ singleton (import-tree ./cli); config = { accounts = { @@ -40,46 +41,5 @@ in }; }; }; - cli = { - shell = "zsh"; - finder = "fzf"; - screensaver.enable = true; - screensaver.timeout = "100"; - screensaver.command = "cbonsai -S -w 0.1 -L 40 -M 2 -b 2"; - file-browser = "yazi"; - multiplexer = "zellij"; - fetch = "hyfetch"; - git.name = "Mohammad Rafiq"; - git.email = "rafiq@rrv.sh"; - git.defaultBranch = "prime"; - }; - home = { - shellAliases = { - v = "nvim"; - e = "edit"; - }; - - packages = with pkgs; [ - cbonsai - ripgrep - devenv - pantheon.rebuild - pantheon.deploy - pantheon.edit - pantheon.commit - pantheon.check - inputs.nixspect.packages."x86_64-linux".nixspect - ]; - }; - programs = { - nh.enable = true; - tealdeer.enable = true; - tealdeer.settings.updates.auto_update = true; - pay-respects.enable = true; - direnv = { - enable = true; - nix-direnv.enable = true; - }; - }; }; } diff --git a/modules/home/cli/default.nix b/modules/home/cli/default.nix deleted file mode 100644 index 5d663c2..0000000 --- a/modules/home/cli/default.nix +++ /dev/null @@ -1,74 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: -{ - options.cli = { - shell = lib.pantheon.mkStrOption; - finder = lib.pantheon.mkStrOption; - screensaver.enable = lib.mkEnableOption ""; - screensaver.timeout = lib.pantheon.mkStrOption; - screensaver.command = lib.pantheon.mkStrOption; - file-browser = lib.pantheon.mkStrOption; - multiplexer = lib.pantheon.mkStrOption; - fetch = lib.pantheon.mkStrOption; - git = { - name = lib.pantheon.mkStrOption; - email = lib.pantheon.mkStrOption; - defaultBranch = lib.pantheon.mkStrOption; - }; - }; - - config = lib.mkMerge [ - { - home.shell.enableShellIntegration = true; - programs.ssh = { - enable = true; - extraConfig = '' - Host * - SetEnv TERM=xterm-256color - ''; - }; - programs.zoxide.enable = true; - home.shellAliases.cd = "z"; - home.persistence."/persist/home/${config.snowfallorg.user.name}".directories = [ - ".local/share/zoxide" - ]; - } - { - programs.nix-index.enable = true; - programs.nix-index-database.comma.enable = true; - } - { - home.shellAliases.ai = "aichat -r %shell% -e"; - - home.packages = with pkgs; [ aichat ]; - - xdg.configFile."aichat/config.yaml".text = '' - model: gemini:gemini-2.0-flash - clients: - - type: gemini - ''; - } - { - programs.starship = { - enable = true; - settings = { - add_newline = false; - format = '' - $directory$character - ''; - right_format = '' - $all - ''; - git_branch.format = "[$symbol$branch(:$remote_branch)]($style) "; - shlvl.disabled = false; - hostname.disabled = true; - username.disabled = true; - }; - }; - } - ]; -} diff --git a/modules/home/cli/fetch/default.nix b/modules/home/cli/fetch/default.nix deleted file mode 100644 index 1aa53ef..0000000 --- a/modules/home/cli/fetch/default.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: -{ - config = lib.mkMerge [ - (lib.mkIf (config.cli.fetch == "hyfetch") { - home.packages = [ pkgs.fastfetch ]; - home.sessionVariables.FETCH = "hyfetch"; - home.shellAliases.fetch = "hyfetch"; - programs.hyfetch = { - enable = true; - settings = { - preset = "bisexual"; - mode = "rgb"; - light_dark = "dark"; - lightness = 0.5; - color_align = { - mode = "horizontal"; - custom_colors = [ ]; - fore_back = null; - }; - backend = "fastfetch"; - }; - }; - - }) - ]; -} diff --git a/modules/home/cli/file-browser/default.nix b/modules/home/cli/file-browser/default.nix deleted file mode 100644 index 1385e21..0000000 --- a/modules/home/cli/file-browser/default.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ config, lib, ... }: -{ - config = lib.mkIf (config.cli.file-browser == "yazi") { - home.sessionVariables.FILE_BROWSER = "yazi"; - programs.yazi = { - enable = true; - shellWrapperName = "t"; - settings = { - mgr = { - sort_by = "natural"; - }; - opener = { - play = [ - { - run = "vlc \"$@\""; - desc = "Open"; - } - ]; - }; - }; - }; - }; -} diff --git a/modules/home/cli/finder/default.nix b/modules/home/cli/finder/default.nix deleted file mode 100644 index 894cbc1..0000000 --- a/modules/home/cli/finder/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ config, lib, ... }: -{ - config = lib.mkMerge [ - (lib.mkIf (config.cli.finder == "fzf") { - programs.fzf = { - enable = true; - enableZshIntegration = lib.mkIf (config.cli.shell == "zsh") true; - }; - }) - ]; -} diff --git a/modules/home/cli/multiplexer/default.nix b/modules/home/cli/multiplexer/default.nix deleted file mode 100644 index bf420eb..0000000 --- a/modules/home/cli/multiplexer/default.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ - osConfig, - config, - lib, - pkgs, - ... -}: -{ - config = lib.mkMerge [ - (lib.mkIf (config.cli.multiplexer == "zellij") ( - import ./zellij.nix { inherit config pkgs osConfig; } - )) - ]; -} diff --git a/modules/home/cli/shell/default.nix b/modules/home/cli/shell/default.nix deleted file mode 100644 index 966a01d..0000000 --- a/modules/home/cli/shell/default.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ config, lib, ... }: -{ - config = lib.mkIf (config.cli.shell == "zsh") { - home.sessionVariables.SHELL = "zsh"; - programs.zsh = { - enable = true; - enableVteIntegration = true; - syntaxHighlighting.enable = true; - historySubstringSearch.enable = true; - history = { - append = true; - extended = true; - ignoreDups = true; - ignoreSpace = true; - save = 10000; - share = true; - size = 10000; - }; - }; - programs.zsh.initContent = lib.mkIf config.cli.screensaver.enable ( - lib.mkOrder 1200 - # zsh - '' - precmd() { - TMOUT=${config.cli.screensaver.timeout} - } - - TRAPALRM() { - TMOUT=1 - ${config.cli.screensaver.command} - # If we exit, assume the previous command was exited out of - TMOUT=${config.cli.screensaver.timeout} - zle reset-prompt - } - '' - ); - }; -} diff --git a/modules/home/cli/utilities/default.nix b/modules/home/cli/utilities/default.nix deleted file mode 100644 index 3199378..0000000 --- a/modules/home/cli/utilities/default.nix +++ /dev/null @@ -1,3 +0,0 @@ -{ - imports = [ ./git.nix ]; -} diff --git a/modules/home/cli/utilities/git.nix b/modules/home/cli/utilities/git.nix deleted file mode 100644 index 9de797a..0000000 --- a/modules/home/cli/utilities/git.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ config, ... }: -{ - config = { - home.sessionVariables.GIT_CONFIG_GLOBAL = "$HOME/.config/git/config"; - home.shellAliases = { - gs = "git status"; - gc = "git commit"; - gcam = "git commit -am"; - gu = "git push"; - gy = "git pull"; - }; - programs.git = { - enable = true; - userName = config.cli.git.name; - userEmail = config.cli.git.email; - signing.key = "~/.ssh/id_ed25519.pub"; - signing.signByDefault = true; - extraConfig = { - init.defaultBranch = config.cli.git.defaultBranch; - push.autoSetupRemote = true; - pull.rebase = false; - core.editor = "$EDITOR"; - gpg.format = "ssh"; - }; - }; - }; -} diff --git a/modules/home/default.nix b/modules/home/default.nix index d061d19..07c8cfb 100644 --- a/modules/home/default.nix +++ b/modules/home/default.nix @@ -1,4 +1,9 @@ -{ config, lib, ... }: +{ + config, + lib, + pkgs, + ... +}: let inherit (lib) mkOption; inherit (lib.types) listOf str; @@ -12,15 +17,31 @@ in }; config = { + # Helper options home.persistence."/persist/home/${config.snowfallorg.user.name}" = { directories = config.persistDirs; allowOther = true; }; + # Global options persistDirs = [ ".ssh" ".config/sops/age" + ".local/share/zoxide" ]; + home.packages = with pkgs; [ ripgrep ]; + programs = { + zoxide.enable = true; + nix-index.enable = true; + nix-index-database.comma.enable = true; + ssh = { + enable = true; + extraConfig = '' + Host * + SetEnv TERM=xterm-256color + ''; + }; + }; home.stateVersion = "24.11"; };