Add justfile

This commit is contained in:
Oliver Davies 2025-04-06 22:57:46 +01:00
parent a8fff66029
commit 877845ad1a
4 changed files with 38 additions and 63 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

View file

@ -53,7 +53,7 @@
in
{
packages.${system} = {
default = mkShell { buildInputs = with pkgs; [ bashInteractive ]; };
default = mkShell { buildInputs = with pkgs; [ just ]; };
};
formatter.${system} = pkgs.nixfmt-rfc-style;

36
justfile Normal file
View file

@ -0,0 +1,36 @@
alias b := build
alias s := switch
alias t := test
alias u := update
_default:
just --list
build *args:
@just _nixos build {{ args }}
check:
nix flake check
clean:
nix store optimise --verbose
nix store gc --verbose
collect-garbage:
nix-collect-garbage -d
sudo nix-collect-garbage -d
format:
nix fmt flake.nix hosts modules
switch *args:
@just _nixos switch {{ args }}
test *args:
@just _nixos test {{ args }}
update:
nix flake update
_nixos command *args:
sudo nixos-rebuild {{ command }} --flake . {{ args }}

62
run
View file

@ -1,62 +0,0 @@
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
function build {
_nixos build "$@"
}
function clean {
nix store optimise --verbose
nix store gc --verbose
}
function check {
nix flake check
}
function clean {
nix store gc --verbose
nix store optimise --verbose
}
function collect-garbage {
nix-collect-garbage -d
sudo nix-collect-garbage -d
}
function format {
nix fmt flake.nix home hosts lib modules
}
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 switch {
_nixos switch "$@"
}
function test {
_nixos test "$@"
}
function update {
nix flake update
}
function _nixos {
local command="$1"
shift 1
sudo nixos-rebuild "$command" --flake . "$@"
}
TIMEFORMAT=$'\nTask completed in %3lR'
time "${@:-help}"