dotfiles/run

73 lines
1.1 KiB
Plaintext
Raw Normal View History

2024-07-08 18:20:17 +00:00
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
function check {
nix flake check
}
2024-11-25 08:03:59 +00:00
function collect-garbage {
nix-collect-garbage -d
sudo nix-collect-garbage -d
}
2024-09-23 12:17:10 +00:00
function format {
nix fmt flake.nix home hosts lib modules
}
2024-07-08 18:20:17 +00:00
function help {
printf "%s <task> [args]\n\nTasks:\n" "$0"
compgen -A function | grep -v "^_" | cat -n
printf "\nExtended help:\n Each task has comments for general usage\n"
}
function nixos:build {
_nixos build "$@"
}
function nixos:switch {
_nixos switch "$@"
}
function nixos:test {
_nixos test "$@"
}
function update {
nix flake update
}
function wsl:build {
2024-08-12 09:49:02 +00:00
_home build wsl2 "$@"
2024-07-08 18:20:17 +00:00
}
function wsl:switch {
2024-08-12 09:49:02 +00:00
_home switch wsl2 "$@"
2024-07-08 18:20:17 +00:00
}
function _home {
local command="$1"
local flake="$2"
shift 2
NIXPKGS_ALLOW_UNFREE=1 home-manager "$command" \
--extra-experimental-features flakes \
--extra-experimental-features nix-command \
--flake ".#$flake" \
--impure "$@"
}
function _nixos {
local command="$1"
shift 1
sudo nixos-rebuild "$command" --flake . "$@"
}
TIMEFORMAT=$'\nTask completed in %3lR'
time "${@:-help}"