From 877845ad1a88e1137d8eeb7d6e549a1fa0afc6c1 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sun, 6 Apr 2025 22:57:46 +0100 Subject: [PATCH] Add justfile --- .envrc | 1 + flake.nix | 2 +- justfile | 36 ++++++++++++++++++++++++++++++++ run | 62 ------------------------------------------------------- 4 files changed, 38 insertions(+), 63 deletions(-) create mode 100644 .envrc create mode 100644 justfile delete mode 100755 run diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..3550a30f --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/flake.nix b/flake.nix index df52100d..27e4c9c0 100644 --- a/flake.nix +++ b/flake.nix @@ -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; diff --git a/justfile b/justfile new file mode 100644 index 00000000..a5e93ac4 --- /dev/null +++ b/justfile @@ -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 }} diff --git a/run b/run deleted file mode 100755 index a4fc9c68..00000000 --- a/run +++ /dev/null @@ -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 [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}"