refactor fish.nix
This commit is contained in:
parent
e893ff6a39
commit
0d4b6f0107
3 changed files with 51 additions and 29 deletions
|
@ -38,7 +38,6 @@
|
||||||
pamixer
|
pamixer
|
||||||
sqlitebrowser
|
sqlitebrowser
|
||||||
obs-studio
|
obs-studio
|
||||||
yt-dlp
|
|
||||||
aseprite
|
aseprite
|
||||||
cloc
|
cloc
|
||||||
viu
|
viu
|
||||||
|
|
|
@ -1,51 +1,64 @@
|
||||||
{ lib, pkgs, config, hostname, ... }: let
|
{ lib, pkgs, config, ... }: let
|
||||||
inherit (lib) mkIf mkEnableOption mkOption types mergeAttrs;
|
inherit (lib) mkIf mkEnableOption mkOption types;
|
||||||
cfg = config.chuj.stuff.fish;
|
cfg = config.chuj.stuff.fish;
|
||||||
user = config.chuj.system.user;
|
user = config.chuj.system.user;
|
||||||
in {
|
in {
|
||||||
options.chuj.stuff.fish = {
|
options.chuj.stuff.fish = {
|
||||||
enable = mkEnableOption "fish";
|
enable = mkEnableOption "fish";
|
||||||
extraAliases = mkOption {
|
aliases = mkOption {
|
||||||
|
type = types.attrs;
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
abbrs = mkOption {
|
||||||
|
type = types.attrs;
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
functions = mkOption {
|
||||||
type = types.attrs;
|
type = types.attrs;
|
||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = let
|
config = mkIf cfg.enable {
|
||||||
XDG_DATA_HOME = config.home-manager.users.${user}.xdg.dataHome;
|
|
||||||
in mkIf cfg.enable {
|
|
||||||
environment.systemPackages = [ pkgs.fish ];
|
environment.systemPackages = [ pkgs.fish ];
|
||||||
programs.fish.enable = true;
|
programs.fish.enable = true;
|
||||||
users.users.${user}.shell = pkgs.fish;
|
users.users.${user}.shell = pkgs.fish;
|
||||||
|
|
||||||
programs.fish.promptInit = ''
|
programs.fish.promptInit = ''
|
||||||
${pkgs.any-nix-shell}/bin/any-nix-shell fish --info-right | source
|
${lib.getExe pkgs.any-nix-shell} fish --info-right | source
|
||||||
'';
|
'';
|
||||||
|
|
||||||
home-manager.users.${user}.programs.fish = {
|
home-manager.users.${user}.programs.fish = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
# todo: move some to abbrs
|
shellAliases = let
|
||||||
shellAliases = mergeAttrs {
|
XDG_DATA_HOME = config.home-manager.users.${user}.xdg.dataHome;
|
||||||
"ls" = "${pkgs.eza}/bin/eza -lhs type";
|
yt-dlp = lib.getExe pkgs.yt-dlp;
|
||||||
|
curl = lib.getExe pkgs.curl;
|
||||||
|
wget = lib.getExe pkgs.wget;
|
||||||
|
xclip = lib.getExe pkgs.xclip;
|
||||||
|
in {
|
||||||
|
"ytmp3" = "${yt-dlp} -o '%(title)s.%(ext)s' -x --audio-format mp3";
|
||||||
|
"myip" = "${curl} ifconfig.me";
|
||||||
|
"wget" = "${wget} --hsts-file='${XDG_DATA_HOME}/wget-hsts'";
|
||||||
|
"2clip" = "${xclip} -selection clipboard";
|
||||||
|
} // cfg.aliases;
|
||||||
|
|
||||||
|
shellAbbrs = {
|
||||||
|
"ls" = "eza -lhs type";
|
||||||
"cp" = "cp -v";
|
"cp" = "cp -v";
|
||||||
"mv" = "mv -v";
|
"mv" = "mv -v";
|
||||||
"ytmp3" = "yt-dlp -o '%(title)s.%(ext)s' -x --audio-format mp3";
|
} // cfg.abbrs;
|
||||||
"myip" = "curl ifconfig.me";
|
|
||||||
"0x0" = ''curl -F"file=@$argv" https://0x0.st'';
|
|
||||||
"wget" = "${pkgs.wget}/bin/wget --hsts-file='${XDG_DATA_HOME}/wget-hsts'";
|
|
||||||
|
|
||||||
# ulimit -n 4096 fixes the "too many open files" error i get sometimes when
|
functions = let
|
||||||
# updating the entire flake
|
readlink = lib.getExe' pkgs.coreutils "readlink";
|
||||||
"rebuild" = "ulimit -n 4096 && sudo nixos-rebuild switch --flake ~/nix#${hostname} -v";
|
which = lib.getExe pkgs.which;
|
||||||
} cfg.extraAliases;
|
curl = lib.getExe pkgs.curl;
|
||||||
|
fortune = lib.getExe (pkgs.fortune.override { withOffensive = true; });
|
||||||
shellAbbrs = { # todo: mkif xclip in pkgs
|
in {
|
||||||
"2clip" = "xclip -selection clipboard";
|
"WHICH" = "${readlink} -f $(${which} $argv[1])";
|
||||||
};
|
"0x0" = ''${curl} -F"file=@$argv[1]" https://0x0.st'';
|
||||||
|
"fish_greeting" = "${fortune}";
|
||||||
functions = {
|
|
||||||
"fish_greeting" = "${(pkgs.fortune.override { withOffensive = true; })}/bin/fortune";
|
|
||||||
"fish_prompt" = ''
|
"fish_prompt" = ''
|
||||||
# name: Informative Vcs
|
# name: Informative Vcs
|
||||||
# author: Mariusz Smykula <mariuszs at gmail.com>
|
# author: Mariusz Smykula <mariuszs at gmail.com>
|
||||||
|
@ -112,7 +125,7 @@ in {
|
||||||
echo -n "$suffix "
|
echo -n "$suffix "
|
||||||
# end
|
# end
|
||||||
'';
|
'';
|
||||||
};
|
} // cfg.functions;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, pkgs, config, ... } @ args: let
|
{ lib, pkgs, config, hostname, ... } @ args: let
|
||||||
inherit (lib) mkOption types;
|
inherit (lib) mkOption types;
|
||||||
cfg = config.chuj.system;
|
cfg = config.chuj.system;
|
||||||
in {
|
in {
|
||||||
|
@ -57,7 +57,10 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; let
|
||||||
|
nixos-rebuild = lib.getExe pkgs.nixos-rebuild;
|
||||||
|
sudo = "/run/wrappers/bin/sudo"; # is this correct
|
||||||
|
in [
|
||||||
ed # is the standard text editor.
|
ed # is the standard text editor.
|
||||||
|
|
||||||
ripgrep
|
ripgrep
|
||||||
|
@ -65,6 +68,7 @@ in {
|
||||||
tree
|
tree
|
||||||
btop
|
btop
|
||||||
wget
|
wget
|
||||||
|
eza
|
||||||
|
|
||||||
zip
|
zip
|
||||||
unzip
|
unzip
|
||||||
|
@ -76,6 +80,12 @@ in {
|
||||||
gcc
|
gcc
|
||||||
gnumake
|
gnumake
|
||||||
python311
|
python311
|
||||||
|
|
||||||
|
(writeShellScriptBin "rebuild" ''
|
||||||
|
set -e
|
||||||
|
ulimit -n 4096 # this fixes the "too many open files" error
|
||||||
|
${sudo} ${nixos-rebuild} switch --flake ~/nix#${hostname} -v
|
||||||
|
'')
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue