dotfiles/home/config/nushell/scripts/nix-utils.nu

33 lines
855 B
Text
Raw Normal View History

2023-09-10 15:36:32 +00:00
export alias update-system-flake = nix flake update ~/.config/nixpkgs -v
export def update-project-flake [] {
let envrc = (rg --no-line-number --color never '^use flake' ./.envrc)
if (not ('./.envrc' | path exists)) or $envrc =~ "^use flake$" {
nix flake update ./ -v
} else {
let flake_path = ($envrc | split column ' ' | get 0 | get column3)
nix flake update $flake_path -v
}
}
export def update-neovim-plugins [] {
2023-09-09 17:54:02 +00:00
let os = (uname)
match $os {
2023-09-10 15:36:32 +00:00
"Darwin" => { ~/.config/nixpkgs/home/programs/nvim/update-plugins.sh }
"Linux" => { /etc/nixos/home/programs/nvim/update-plugins.sh }
2023-09-09 17:54:02 +00:00
_ => { error make {msg: "unsupported operating system"} }
}
}
2023-09-10 15:36:32 +00:00
export def update-all [] {
update-system-flake
update-neovim-plugins
}
export def nix-garbage-collect [] {
nix-collect-garbage -d
sudo nix-collect-garbage -d
}