dotfiles/modules/shell/nixpkgs.nix

73 lines
2.1 KiB
Nix
Raw Permalink Normal View History

{ config, pkgs, lib, ... }: {
home-manager.users.${config.user} = {
programs.fish = {
shellAbbrs = {
2022-07-07 11:49:48 +00:00
n = "nix";
ns = "nix-shell -p";
nsf = "nix-shell --run fish -p";
nsr = "nix-shell-run";
nps = "nix repl '<nixpkgs>'";
nixo = "man configuration.nix";
nixh = "man home-configuration.nix";
nr = "rebuild-nixos";
nro = "rebuild-nixos offline";
hm = "rebuild-home";
};
functions = {
nix-shell-run = {
body = ''
set program $argv[1]
if test (count $argv) -ge 2
2022-11-03 15:26:31 +00:00
commandline -r "nix run nixpkgs#$program -- $argv[2..-1]"
else
2022-11-03 15:26:31 +00:00
commandline -r "nix run nixpkgs#$program"
end
commandline -f execute
'';
};
nix-fzf = {
body = ''
commandline -i (nix-instantiate --eval --json \
-E 'builtins.attrNames (import <nixpkgs> {})' \
| jq '.[]' -r | fzf)
commandline -f repaint
'';
};
rebuild-nixos = {
body = ''
if test "$argv[1]" = "offline"
set option "--option substitute false"
end
2022-07-13 02:15:00 +00:00
git -C ${config.dotfilesPath} add --intent-to-add --all
commandline -r "doas nixos-rebuild switch $option --flake ${config.dotfilesPath}#${config.networking.hostName}"
commandline --function execute
'';
};
rebuild-home = {
body = ''
git -C ${config.dotfilesPath} add --intent-to-add --all
commandline -r "${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#${config.networking.hostName}";
commandline --function execute
'';
};
};
};
# Provides "command-not-found" options
programs.nix-index = {
enable = true;
enableFishIntegration = true;
};
};
2022-09-18 01:15:31 +00:00
nix = {
# Set channel to flake packages, used for nix-shell commands
nixPath = [ "nixpkgs=${pkgs.path}" ];
};
}