From 9677ef8ecd37ce2b9b44fc31fde2fbd50e68369f Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 8 Jul 2024 19:20:17 +0100 Subject: [PATCH] Replace `justfile` with `run` --- flake.nix | 2 +- justfile | 34 ------------------------------ run | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 35 deletions(-) delete mode 100644 justfile create mode 100755 run diff --git a/flake.nix b/flake.nix index 73bc019..8900756 100644 --- a/flake.nix +++ b/flake.nix @@ -33,7 +33,7 @@ inherit (pkgs) mkShell; in { - packages.${system}.default = mkShell { buildInputs = with pkgs; [ just ]; }; + packages.${system}.default = mkShell { buildInputs = with pkgs; [ bashInteractive ]; }; formatter.${system} = pkgs.nixfmt-rfc-style; diff --git a/justfile b/justfile deleted file mode 100644 index 86c5bd4..0000000 --- a/justfile +++ /dev/null @@ -1,34 +0,0 @@ -_default: - just --list - -check: - nix flake check - -fmt: - nix fmt flake.nix lib - -nixos-build *args: - sudo nixos-rebuild build --flake . {{ args }} - -nixos-switch *args: - sudo nixos-rebuild switch --flake . {{ args }} - -nixos-test *args: - sudo nixos-rebuild test --flake . {{ args }} - -update: - nix flake update - -wsl-build: - NIXPKGS_ALLOW_UNFREE=1 home-manager build \ - --extra-experimental-features flakes \ - --extra-experimental-features nix-command \ - --flake ".#wsl2" \ - --impure - -wsl-switch: - NIXPKGS_ALLOW_UNFREE=1 home-manager switch \ - --extra-experimental-features flakes \ - --extra-experimental-features nix-command \ - --flake ".#wsl2" \ - --impure diff --git a/run b/run new file mode 100755 index 0000000..3b90fb2 --- /dev/null +++ b/run @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail + +function check { + nix flake check +} + +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 nixos:build { + _nixos build "$@" +} + +function nixos:switch { + _nixos switch "$@" +} + +function nixos:test { + _nixos test "$@" +} + +function update { + nix flake update +} + +function wsl:build { + _home build wsl2 +} + +function wsl:switch { + _home switch wsl2 +} + +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}"