2024-04-20 09:42:06 -04:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
2025-01-20 22:35:40 -05:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.nmasur.presets.programs.nixpkgs;
|
|
|
|
in
|
|
|
|
|
2024-04-20 09:42:06 -04:00
|
|
|
{
|
2025-01-20 22:35:40 -05:00
|
|
|
|
|
|
|
options.nmasur.presets.programs.nixpkgs.enable = lib.mkEnableOption "Nixpkgs presets";
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
2022-07-06 15:50:10 -04:00
|
|
|
|
|
|
|
programs.fish = {
|
|
|
|
shellAbbrs = {
|
2022-07-07 07:49:48 -04:00
|
|
|
n = "nix";
|
2022-09-25 04:19:46 +00:00
|
|
|
ns = "nix-shell -p";
|
|
|
|
nsf = "nix-shell --run fish -p";
|
2022-07-06 15:50:10 -04:00
|
|
|
nsr = "nix-shell-run";
|
2024-11-06 13:56:00 -05:00
|
|
|
nps = "nix repl --expr 'import <nixpkgs>{}'";
|
2022-07-06 15:50:10 -04:00
|
|
|
nixo = "man configuration.nix";
|
|
|
|
nixh = "man home-configuration.nix";
|
2025-02-05 17:25:29 -05:00
|
|
|
nr = lib.mkIf config.nmasur.presets.programs.dotfiles.enable {
|
2024-12-05 22:00:14 +00:00
|
|
|
function = "rebuild-nixos";
|
|
|
|
};
|
2025-02-05 17:25:29 -05:00
|
|
|
nro = lib.mkIf config.nmasur.presets.programs.dotfiles.enable {
|
2024-12-16 13:43:54 -05:00
|
|
|
function = "rebuild-nixos-offline";
|
|
|
|
};
|
2025-02-05 17:25:29 -05:00
|
|
|
hm = lib.mkIf config.nmasur.presets.programs.dotfiles.enable {
|
2024-12-16 13:43:54 -05:00
|
|
|
function = "rebuild-home";
|
|
|
|
};
|
2022-07-06 15:50:10 -04:00
|
|
|
};
|
|
|
|
functions = {
|
|
|
|
nix-shell-run = {
|
2025-02-02 21:45:34 -05:00
|
|
|
body = # fish
|
|
|
|
''
|
|
|
|
set program $argv[1]
|
|
|
|
if test (count $argv) -ge 2
|
|
|
|
commandline -r "nix run nixpkgs#$program -- $argv[2..-1]"
|
|
|
|
else
|
|
|
|
commandline -r "nix run nixpkgs#$program"
|
|
|
|
end
|
|
|
|
commandline -f execute
|
|
|
|
'';
|
2022-07-06 15:50:10 -04:00
|
|
|
};
|
|
|
|
nix-fzf = {
|
2025-02-02 21:45:34 -05:00
|
|
|
body = # fish
|
|
|
|
''
|
|
|
|
commandline -i (nix-instantiate --eval --json \
|
|
|
|
-E 'builtins.attrNames (import <nixpkgs> {})' \
|
|
|
|
| ${lib.getExe pkgs.jq} '.[]' -r | ${lib.getExe pkgs.fzf})
|
|
|
|
commandline -f repaint
|
|
|
|
'';
|
2022-07-06 15:50:10 -04:00
|
|
|
};
|
2025-02-05 17:25:29 -05:00
|
|
|
rebuild-nixos = lib.mkIf config.nmasur.presets.programs.dotfiles.enable {
|
2025-02-02 21:45:34 -05:00
|
|
|
body = # fish
|
|
|
|
''
|
2025-02-05 17:25:29 -05:00
|
|
|
git -C ${config.nmasur.presets.programs.dotfiles.path} add --intent-to-add --all
|
2025-02-25 04:10:25 +00:00
|
|
|
echo "doas nixos-rebuild switch --flake ${config.nmasur.presets.programs.dotfiles.path}"
|
2025-02-02 21:45:34 -05:00
|
|
|
'';
|
2024-12-16 13:43:54 -05:00
|
|
|
};
|
2025-02-05 17:25:29 -05:00
|
|
|
rebuild-nixos-offline = lib.mkIf config.nmasur.presets.programs.dotfiles.enable {
|
2025-02-02 21:45:34 -05:00
|
|
|
body = # fish
|
|
|
|
''
|
2025-02-05 17:25:29 -05:00
|
|
|
git -C ${config.nmasur.presets.programs.dotfiles.path} add --intent-to-add --all
|
2025-02-25 04:10:25 +00:00
|
|
|
echo "doas nixos-rebuild switch --option substitute false --flake ${config.nmasur.presets.programs.dotfiles.path}"
|
2025-02-02 21:45:34 -05:00
|
|
|
'';
|
2022-07-06 15:50:10 -04:00
|
|
|
};
|
2025-02-05 17:25:29 -05:00
|
|
|
rebuild-home = lib.mkIf config.nmasur.presets.programs.dotfiles.enable {
|
2025-02-02 21:45:34 -05:00
|
|
|
body = # fish
|
|
|
|
''
|
2025-02-05 17:25:29 -05:00
|
|
|
git -C ${config.nmasur.presets.programs.dotfiles.path} add --intent-to-add --all
|
2025-02-25 04:10:25 +00:00
|
|
|
echo "${lib.getExe pkgs.home-manager} switch --flake ${config.nmasur.presets.programs.dotfiles.path}";
|
2025-02-02 21:45:34 -05:00
|
|
|
'';
|
2022-10-30 20:14:41 -04:00
|
|
|
};
|
2022-07-06 15:50:10 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2025-02-14 15:36:54 -05:00
|
|
|
nmasur.presets.programs.fish.fish_user_key_bindings = # fish
|
2025-02-02 21:45:34 -05:00
|
|
|
''
|
|
|
|
# Ctrl-n
|
|
|
|
bind -M insert \cn 'commandline -r "nix shell nixpkgs#"'
|
|
|
|
bind -M default \cn 'commandline -r "nix shell nixpkgs#"'
|
|
|
|
# Ctrl-Shift-n (defined by terminal)
|
|
|
|
bind -M insert \x11F nix-fzf
|
|
|
|
bind -M default \x11F nix-fzf
|
|
|
|
'';
|
|
|
|
|
2022-09-17 21:15:31 -04:00
|
|
|
};
|
2025-02-17 14:05:23 -05:00
|
|
|
|
2022-07-06 15:50:10 -04:00
|
|
|
}
|