initial commit

This commit is contained in:
2025-05-04 02:47:36 +02:00
commit d5e06f3f49
91 changed files with 9063 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
{
config,
lib,
...
}:
with lib; let
cfg = config.modules.bash;
in {
options.modules.bash = {
enable = lib.mkEnableOption "enables bash";
aliases = lib.mkOption {
type = types.attrsOf types.str;
default = {};
example = {
cp = "cp -i";
lns = "ln -si";
};
};
bashrcExtra = lib.mkOption {
type = types.lines;
default = "";
};
};
config = lib.mkIf cfg.enable {
programs.bash = {
enable = true;
shellAliases = cfg.aliases;
shellOptions = [
"histappend"
"cmdhist"
"lithist"
"checkwinsize"
"extglob"
"globstar"
"checkjobs"
"autocd"
"cdspell"
"dirspell"
];
};
};
}

View File

@@ -0,0 +1,124 @@
{
config,
lib,
...
}:
with lib; let
aliases = {
df = "df -H";
diskspace = "sudo df -h | grep -E \"sd|lv|Size\"";
du = "du -ch";
meminfo = "free -m -l -t";
gpumeminfo = "grep -i --color memory /var/log/Xorg.0.log";
cpuinfo = "lscpu";
pscpu = "ps auxf | sort -nr -k 3";
pscpu10 = "ps auxf | sort -nr -k 3 | head -10";
psmem = "ps auxf | sort -nr -k 4";
psmem10 = "ps auxf | sort -nr -k 4 | head -10";
s = "systemctl";
dc = "docker compose";
dcd = "docker compose down";
dcl = "docker compose logs";
dclf = "docker compose logs -f";
dcp = "docker compose pull";
dcu = "docker compose up";
dcud = "docker compose up -d";
dcudp = "docker compose up -d --pull=always";
dcr = "docker compose restart";
enw = "emacsclient -nw";
e = "emacsclient -n -c";
cp = "cp -i";
rsync = "rsync -Pa --progress";
ln = "ln -i";
lns = "ln -si";
mv = "mv -i";
rm = "rm -Iv";
rmd = "rm --preserve-root -Irv";
rmdf = "rm --preserve-root -Irfv";
rmf = "rm --preserve-root -Ifv";
chgrp = "chgrp --preserve-root -v";
chmod = "chmod --preserve-root -v";
chown = "chown --preserve-root -v";
lsl = "eza -halg@ --group-directories-first --git";
flac = "yt-dlp -x --audio-format flac --audio-quality 0 o \"~/Music/%(uploader)s/%(title)s.%(ext)s\"";
please = "sudo -A";
wget = "wget --hsts-file=\"$XDG_DATA_HOME/wget-hsts\" -c";
};
cfg = config.modules.shell;
in {
imports = [
./bash.nix
./fish.nix
./starship.nix
./zsh.nix
];
options.modules.shell = {
enableBash = mkOption {
type = types.bool;
default = true;
description = "enables bash";
};
enableFish = mkOption {
type = types.bool;
default = true;
description = "enables fish";
};
enableZsh = mkOption {
type = types.bool;
default = true;
description = "enables zsh";
};
starship = {
enable = mkEnableOption "Enables the starship prompt.";
jjIntegration = mkEnableOption "Enables Jujutsu integration in starship.";
};
zoxide = {
enable = mkOption {
type = types.bool;
default = true;
description = "enables zoxide";
};
replaceCd = mkOption {
type = types.bool;
default = true;
description = "makes zoxide replace cd";
};
};
};
config = {
home.shell = {
enableFishIntegration = mkDefault cfg.enableFish;
enableBashIntegration = mkDefault cfg.enableBash;
enableZshIntegration = mkDefault cfg.enableZsh;
};
modules = {
fish = {
enable = mkDefault cfg.enableFish;
abbrs = mkDefault aliases;
};
bash = {
enable = mkDefault cfg.enableBash;
aliases = mkDefault aliases;
};
zsh = {
enable = mkDefault cfg.enableZsh;
abbrs = mkDefault aliases;
};
inherit (cfg) starship;
};
programs.zoxide = mkIf cfg.zoxide.enable {
enable = true;
options = mkIf cfg.zoxide.replaceCd [
"--cmd cd"
];
};
};
}

View File

@@ -0,0 +1,75 @@
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.modules.fish;
in {
options.modules.fish = {
enable = lib.mkEnableOption "enables fish";
abbrs = lib.mkOption {
type = types.attrsOf types.str;
default = {};
example = {
cp = "cp -i";
lns = "ln -si";
};
};
};
config = lib.mkIf cfg.enable {
programs.fish = {
enable = true;
shellAbbrs = cfg.abbrs;
preferAbbrs = true;
shellInit = ''
function fish_command_not_found
__fish_default_command_not_found_handler $argv
end
'';
plugins = [
{
name = "bass";
inherit (pkgs.fishPlugins.bass) src;
# src = pkgs.fishPlugins.bass.src;
}
{
name = "colored-man-pages";
inherit (pkgs.fishPlugins.colored-man-pages) src;
}
{
name = "done";
inherit (pkgs.fishPlugins.done) src;
}
{
name = "fzf";
inherit (pkgs.fishPlugins.fzf) src;
}
{
name = "pisces";
inherit (pkgs.fishPlugins.pisces) src;
}
{
name = "getopts.fish";
src = pkgs.fetchFromGitHub {
owner = "jorgebucaran";
repo = "getopts.fish";
rev = "4b74206725c3e11d739675dc2bb84c77d893e901";
sha256 = "9hRFBmjrCgIUNHuOJZvOufyLsfreJfkeS6XDcCPesvw=";
};
}
{
name = "replay.fish";
src = pkgs.fetchFromGitHub {
owner = "jorgebucaran";
repo = "replay.fish";
rev = "d2ecacd3fe7126e822ce8918389f3ad93b14c86c";
sha256 = "TzQ97h9tBRUg+A7DSKeTBWLQuThicbu19DHMwkmUXdg=";
};
}
];
};
};
}

View File

@@ -0,0 +1,45 @@
{
config,
lib,
...
}:
with lib; let
cfg = config.modules.starship;
in {
options.modules.starship = {
enable = mkEnableOption "Enables the starship prompt.";
jjIntegration = mkEnableOption "Enables Jujutsu integration in starship.";
};
config.programs.starship = mkIf cfg.enable {
inherit (cfg) enable;
enableTransience = true;
settings.custom = {
jj = {
description = "The current jj status";
detect_folders = [".jj"];
symbol = "🥋 ";
command = ''
jj log --revisions @ --no-graph --ignore-working-copy --color always --limit 1 --template '
separate(" ",
change_id.shortest(4),
bookmarks,
"|",
concat(
if(conflict, "💥"),
if(divergent, "🚧"),
if(hidden, "👻"),
if(immutable, "🔒"),
),
raw_escape_sequence("\x1b[1;32m") ++ if(empty, "(empty)"),
raw_escape_sequence("\x1b[1;32m") ++ coalesce(
truncate_end(29, description.first_line(), ""),
"(no description set)",
) ++ raw_escape_sequence("\x1b[0m"),
)
'
'';
};
};
};
}

View File

@@ -0,0 +1,96 @@
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.modules.zsh;
in {
options.modules.zsh = {
enable = lib.mkEnableOption "enables zsh";
abbrs = lib.mkOption {
type = types.attrsOf types.str;
default = {};
example = {
cp = "cp -i";
lns = "ln -si";
};
};
zshrcExtra = lib.mkOption {
type = types.lines;
default = ''
bindkey -e
bindkey '^p' history-search-backward
bindkey '^n' history-search-forward
# Completion styling
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
zstyle ':completion:*' list-colors "''${(s.:.)LS_COLORS}"
zstyle ':completion:*' menu no
zstyle ':fzf-tab:complete:cd:*' fzf-preview '${pkgs.eza}/bin/eza $realpath'
'';
};
};
config.programs.zsh = lib.mkIf cfg.enable {
enable = true;
autocd = true;
autosuggestion = {
enable = true;
strategy = ["match_prev_cmd" "completion"];
};
enableCompletion = true;
history = {
findNoDups = true;
ignoreAllDups = true;
ignoreDups = true;
ignoreSpace = true;
path = "${config.xdg.dataHome}/zsh/zsh_history";
saveNoDups = true;
};
historySubstringSearch.enable = true;
initContent = cfg.zshrcExtra;
oh-my-zsh = {
enable = true;
plugins = [
"dirhistory"
"sudo"
];
};
plugins = [
{
name = "fzf-tab";
src = pkgs.fetchFromGitHub {
owner = "Aloxaf";
repo = "fzf-tab";
rev = "v1.2.0";
sha256 = "sha256-q26XVS/LcyZPRqDNwKKA9exgBByE0muyuNb0Bbar2lY=";
};
}
{
name = "auto-notify";
src = pkgs.fetchFromGitHub {
owner = "MichaelAquilina";
repo = "zsh-auto-notify";
rev = "0.11.0";
sha256 = "sha256-8r5RsyldJIzlWr9+G8lrkHvJ8KxTVO859M//wDnYOUY=";
};
}
{
name = "zsh-autopair";
src = pkgs.fetchFromGitHub {
owner = "hlissner";
repo = "zsh-autopair";
rev = "449a7c3d095bc8f3d78cf37b9549f8bb4c383f3d";
sha256 = "sha256-3zvOgIi+q7+sTXrT+r/4v98qjeiEL4Wh64rxBYnwJvQ=";
};
}
];
syntaxHighlighting.enable = true;
zsh-abbr = {
enable = true;
abbreviations = cfg.abbrs;
};
};
}