2024-01-25 02:52:33 +00:00
|
|
|
{ config, pkgs, lib, ... }: {
|
2022-07-06 19:50:10 +00:00
|
|
|
home-manager.users.${config.user} = {
|
|
|
|
|
|
|
|
programs.fish = {
|
|
|
|
shellAbbrs = {
|
2022-07-07 11:49:48 +00:00
|
|
|
n = "nix";
|
2022-09-25 04:19:46 +00:00
|
|
|
ns = "nix-shell -p";
|
|
|
|
nsf = "nix-shell --run fish -p";
|
2022-07-06 19:50:10 +00:00
|
|
|
nsr = "nix-shell-run";
|
|
|
|
nps = "nix repl '<nixpkgs>'";
|
|
|
|
nixo = "man configuration.nix";
|
|
|
|
nixh = "man home-configuration.nix";
|
|
|
|
nr = "rebuild-nixos";
|
|
|
|
nro = "rebuild-nixos offline";
|
2022-10-31 00:14:41 +00:00
|
|
|
hm = "rebuild-home";
|
2022-07-06 19:50:10 +00:00
|
|
|
};
|
|
|
|
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]"
|
2022-07-06 19:50:10 +00:00
|
|
|
else
|
2022-11-03 15:26:31 +00:00
|
|
|
commandline -r "nix run nixpkgs#$program"
|
2022-07-06 19:50:10 +00:00
|
|
|
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
|
2022-09-24 16:53:16 +00:00
|
|
|
commandline -r "doas nixos-rebuild switch $option --flake ${config.dotfilesPath}#${config.networking.hostName}"
|
2022-07-06 19:50:10 +00:00
|
|
|
commandline --function execute
|
|
|
|
'';
|
|
|
|
};
|
2022-10-31 00:14:41 +00:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
};
|
2022-07-06 19:50:10 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# Provides "command-not-found" options
|
|
|
|
programs.nix-index = {
|
|
|
|
enable = true;
|
|
|
|
enableFishIntegration = true;
|
|
|
|
};
|
|
|
|
|
2024-01-25 02:52:33 +00:00
|
|
|
# Create nix-index if doesn't exist
|
|
|
|
home.activation.createNixIndex =
|
|
|
|
let cacheDir = "${config.homePath}/.cache/nix-index";
|
|
|
|
in lib.mkIf
|
|
|
|
config.home-manager.users.${config.user}.programs.nix-index.enable
|
|
|
|
(config.home-manager.users.${config.user}.lib.dag.entryAfter
|
|
|
|
[ "writeBoundary" ] ''
|
|
|
|
if [ ! -d ${cacheDir} ]; then
|
|
|
|
$DRY_RUN_CMD ${pkgs.nix-index}/bin/nix-index -f ${pkgs.path}
|
|
|
|
fi
|
|
|
|
'');
|
|
|
|
|
2022-07-06 19:50:10 +00:00
|
|
|
};
|
|
|
|
|
2022-09-18 01:15:31 +00:00
|
|
|
nix = {
|
|
|
|
|
|
|
|
# Set channel to flake packages, used for nix-shell commands
|
2024-01-25 02:52:33 +00:00
|
|
|
nixPath = [{ nixpkgs = pkgs.path; }];
|
2022-09-18 01:15:31 +00:00
|
|
|
|
2023-04-15 16:58:37 +00:00
|
|
|
# Set registry to this flake's packages, used for nix X commands
|
|
|
|
registry.nixpkgs.to = {
|
|
|
|
type = "path";
|
2023-04-19 20:47:36 +00:00
|
|
|
path = builtins.toString pkgs.path;
|
2023-04-15 16:58:37 +00:00
|
|
|
};
|
|
|
|
|
2023-07-29 12:24:03 +00:00
|
|
|
# For security, only allow specific users
|
|
|
|
settings.allowed-users = [ "@wheel" config.user ];
|
|
|
|
|
2022-09-18 01:15:31 +00:00
|
|
|
};
|
2022-07-06 19:50:10 +00:00
|
|
|
|
|
|
|
}
|