feat(home): move cli config to homes and use home-manager modules

This commit is contained in:
Mohammad Rafiq 2025-06-14 19:15:48 +08:00
parent 1a3ff4b92a
commit 00e3ea65c8
No known key found for this signature in database
17 changed files with 198 additions and 271 deletions

View file

@ -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;
};
};
}
];
}

View file

@ -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";
};
};
})
];
}

View file

@ -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";
}
];
};
};
};
};
}

View file

@ -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;
};
})
];
}

View file

@ -1,14 +0,0 @@
{
osConfig,
config,
lib,
pkgs,
...
}:
{
config = lib.mkMerge [
(lib.mkIf (config.cli.multiplexer == "zellij") (
import ./zellij.nix { inherit config pkgs osConfig; }
))
];
}

View file

@ -1,58 +0,0 @@
{
config,
pkgs,
osConfig,
}:
{
home.sessionVariables.MULTIPLEXER = "zellij";
home.persistence."/persist/home/${config.snowfallorg.user.name}".directories = [ "/.cache/zellij" ];
programs.zellij = {
enable = true;
enableZshIntegration = true;
settings = {
pane_frames = false;
show_startup_tips = false;
show_release_notes = false;
};
};
xdg.configFile."zellij/layouts/default.kdl".text = # kdl
''
layout {
default_tab_template {
pane size=1 borderless=true {
plugin location="file:${pkgs.zjstatus}/bin/zjstatus.wasm" {
format_left "{mode} ${osConfig.system.hostname}"
format_center "{tabs}"
format_right "{datetime}"
format_space ""
format_hide_on_overlength "true"
format_precedence "lrc"
border_enabled "false"
border_char ""
border_format "#[fg=#6C7086]{char}"
border_position "top"
hide_frame_for_single_pane "false"
mode_default_to_mode "normal"
mode_normal "#[bg=#89B4FA] {name} "
mode_locked "#[bg=#f55e18] {name} "
mode_session "#[bg=#00ff00] {name} "
tab_normal "#[fg=#6C7086] {index} "
tab_active "#[fg=#9399B2,bold,italic] {index} "
tab_display_count "3" // limit to showing 3 tabs
tab_truncate_start_format "..."
tab_truncate_end_format "..."
datetime "#[fg=#6C7086,bold] {format}"
datetime_format "%H:%M:%S"
datetime_timezone "Asia/Singapore"
}
}
children
}
}
'';
}

View file

@ -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
}
''
);
};
}

View file

@ -1,3 +0,0 @@
{
imports = [ ./git.nix ];
}

View file

@ -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";
};
};
};
}

View file

@ -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";
};