1

Modules/Fish: Update for nix-darwin

This commit is contained in:
2026-03-21 13:40:06 +01:00
parent 602aa4cd56
commit 9bec5f42b1
3 changed files with 172 additions and 151 deletions

View File

@ -210,6 +210,7 @@
mylib = darwinMylib; mylib = darwinMylib;
hostname = "darwinix"; hostname = "darwinix";
username = "christoph"; username = "christoph";
headless = false;
extraModules = []; extraModules = [];
}; };
}; };

View File

@ -42,8 +42,9 @@ in {
fish_pager_color_description ${color.hex.overlay0} fish_pager_color_description ${color.hex.overlay0}
''; '';
programs.fish = { programs.fish = lib.mkMerge [
enable = true; # Linux exclusive config
(lib.mkIf pkgs.stdenv.isLinux {
generateCompletions = nixosConfig.programs.fish.generateCompletions; generateCompletions = nixosConfig.programs.fish.generateCompletions;
functions = lib.mergeAttrsList [ functions = lib.mergeAttrsList [
@ -87,13 +88,6 @@ in {
}) })
]; ];
plugins = [];
shellInit = ''
set fish_greeting
yes | fish_config theme save "system-theme"
'';
shellAbbrs = let shellAbbrs = let
# Only add " | bat" if bat is installed # Only add " | bat" if bat is installed
batify = command: command + (lib.optionalString config.programs.bat.enable " | bat"); batify = command: command + (lib.optionalString config.programs.bat.enable " | bat");
@ -111,10 +105,6 @@ in {
lib.mkMerge [ lib.mkMerge [
# Abbrs that are always available are defined here. # Abbrs that are always available are defined here.
{ {
# Shell basics
c = "clear";
q = "exit";
# Fish # Fish
h = batifyWithArgs "history" "-l fish"; # -l fish sets syntax highlighting to fish h = batifyWithArgs "history" "-l fish"; # -l fish sets syntax highlighting to fish
abbrs = batifyWithArgs "abbr" "-l fish"; abbrs = batifyWithArgs "abbr" "-l fish";
@ -123,10 +113,8 @@ in {
cd = "z"; # zoxide for quickjump to previously visited locations cd = "z"; # zoxide for quickjump to previously visited locations
cdd = "zi"; cdd = "zi";
b = "z -"; # jump to previous dir b = "z -"; # jump to previous dir
mkdir = "mkdir -p"; # also create parents (-p)
blk = batify "lsblk -o NAME,LABEL,PARTLABEL,FSTYPE,SIZE,FSUSE%,MOUNTPOINT"; blk = batify "lsblk -o NAME,LABEL,PARTLABEL,FSTYPE,SIZE,FSUSE%,MOUNTPOINT";
blkids = batify "lsblk -o NAME,LABEL,FSTYPE,SIZE,PARTLABEL,MODEL,ID,UUID"; blkids = batify "lsblk -o NAME,LABEL,FSTYPE,SIZE,PARTLABEL,MODEL,ID,UUID";
watch = "watch -d -c -n 0.5";
nps = "nps -e"; nps = "nps -e";
nd = "nix develop"; nd = "nix develop";
nb = "nix build -L"; nb = "nix build -L";
@ -134,6 +122,46 @@ in {
nr = "nix run"; nr = "nix run";
ghidra = "_JAVA_AWT_WM_NONREPARENTING=1 ghidra"; # env var for wayland ghidra = "_JAVA_AWT_WM_NONREPARENTING=1 ghidra"; # env var for wayland
}
(abbrify pkgs.nix-search-tv {search = "nix-search-tv print --indexes 'nixos,home-manager,nixpkgs,nur' | fzf --preview 'nix-search-tv preview {}' --scheme history";})
# Doesn't work with abbrify because I have nnn.override...
(lib.optionalAttrs config.homemodules.nnn.enable {n = "nnncd -a";})
(lib.optionalAttrs config.homemodules.nnn.enable {np = "nnncd -a -P p";})
(abbrify pkgs.ranger {r = "ranger --choosedir=$HOME/.rangerdir; set LASTDIR (cat $HOME/.rangerdir); cd $LASTDIR";})
(lib.optionalAttrs config.homemodules.rmpc.enable {r = "rcmp";})
(abbrify pkgs.rsync rec {
rsync = "rsync -ahv --inplace --partial --info=progress2";
copy = rsync;
})
# (abbrify pkgs.sd {sed = "sd";})
];
})
# Common config
{
enable = true;
shellAbbrs = let
# These can be used for my config.homemodules and for HM config.programs,
# as both of these add the package to home.packages
hasHomePackage = package: (mylib.modules.contains config.home.packages package);
# Only add fish abbr if package is installed
abbrify = package: abbr: (lib.optionalAttrs (hasHomePackage package) abbr);
in
lib.mkMerge [
{
# Shell basics
c = "clear";
q = "exit";
mkdir = "mkdir -p"; # also create parents (-p)
watch = "watch -d -c -n 0.5";
sy = "sudo -u ${username} yazi"; sy = "sudo -u ${username} yazi";
} }
@ -144,6 +172,11 @@ in {
alldisks = "duf"; alldisks = "duf";
}) })
(abbrify pkgs.ripgrep {
rg = "rg --trim --pretty";
# grep = rg;
})
(abbrify pkgs.eza { (abbrify pkgs.eza {
ls = "eza --color=always --group-directories-first -F --git --icons=always --octal-permissions"; ls = "eza --color=always --group-directories-first -F --git --icons=always --octal-permissions";
lsl = "eza --color=always --group-directories-first -F --git --icons=always --octal-permissions -l"; lsl = "eza --color=always --group-directories-first -F --git --icons=always --octal-permissions -l";
@ -174,30 +207,16 @@ in {
(lib.optionalAttrs config.homemodules.kitty.enable {ssh = "kitty +kitten ssh";}) (lib.optionalAttrs config.homemodules.kitty.enable {ssh = "kitty +kitten ssh";})
(abbrify pkgs.lazygit {lg = "lazygit";}) (abbrify pkgs.lazygit {lg = "lazygit";})
(abbrify pkgs.nix-search-tv {search = "nix-search-tv print --indexes 'nixos,home-manager,nixpkgs,nur' | fzf --preview 'nix-search-tv preview {}' --scheme history";})
# Doesn't work with abbrify because I have nnn.override...
(lib.optionalAttrs config.homemodules.nnn.enable {n = "nnncd -a";})
(lib.optionalAttrs config.homemodules.nnn.enable {np = "nnncd -a -P p";})
(abbrify pkgs.ranger {r = "ranger --choosedir=$HOME/.rangerdir; set LASTDIR (cat $HOME/.rangerdir); cd $LASTDIR";})
(abbrify pkgs.ripgrep rec {
rg = "rg --trim --pretty";
# grep = rg;
})
(lib.optionalAttrs config.homemodules.rmpc.enable {r = "rcmp";})
(abbrify pkgs.rsync rec {
rsync = "rsync -ahv --inplace --partial --info=progress2";
copy = rsync;
})
# (abbrify pkgs.sd {sed = "sd";})
]; ];
};
plugins = [];
shellInit = ''
set fish_greeting
yes | fish_config theme save "system-theme"
'';
}
];
programs.starship = { programs.starship = {
enable = true; enable = true;

View File

@ -87,13 +87,14 @@
username, username,
publicKeys, publicKeys,
extraModules ? [], extraModules ? [],
headless ? false,
}: }:
inputs.nix-darwin.lib.darwinSystem { inputs.nix-darwin.lib.darwinSystem {
inherit system; inherit system;
# Values in "specialArgs" are propagated to all system modules. # Values in "specialArgs" are propagated to all system modules.
specialArgs = { specialArgs = {
inherit inputs system hostname mylib username publicKeys; inherit inputs system hostname mylib username publicKeys headless;
}; };
modules = builtins.concatLists [ modules = builtins.concatLists [
@ -121,7 +122,7 @@
home-manager = { home-manager = {
# Values in "extraSpecialArgs" are propagated to all HM modules. # Values in "extraSpecialArgs" are propagated to all HM modules.
extraSpecialArgs = { extraSpecialArgs = {
inherit inputs system hostname mylib username publicKeys; inherit inputs system hostname mylib username publicKeys headless;
}; };
# Use the "pkgs" from the system configuration. # Use the "pkgs" from the system configuration.