From 596ba4ac142b0cb917aee86bc753adc67c661b4c Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sat, 7 Oct 2023 00:05:16 +0100 Subject: [PATCH] build: replace justfile with run --- justfile | 14 -------------- run | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 14 deletions(-) delete mode 100644 justfile create mode 100755 run diff --git a/justfile b/justfile deleted file mode 100644 index 9a831a3..0000000 --- a/justfile +++ /dev/null @@ -1,14 +0,0 @@ -default: - just --list - -clean: - rm -rf ./result - -nixos profile command: && clean - sudo nixos-rebuild {{ command }} --flake .#{{ profile }} - -wsl2 command: && clean - NIXPKGS_ALLOW_UNFREE=1 home-manager {{ command }} --flake .#wsl2 --impure - -update: - nix flake update diff --git a/run b/run new file mode 100755 index 0000000..9af32ee --- /dev/null +++ b/run @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +set -eu + +# delete any temporary or generated files. +function clean { + rm -rf ./result +} + +# Display a list of all available commands. +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" +} + +# Perform nixos-rebuild commands for a specified flake on NixOS. +function nixos { + clean + + local profile="${1}" + local command="${2}" + + sudo nixos-rebuild "${command}" --flake ".#${profile}" +} + +# Update the Nix Flake. +function update { + nix flake update +} + +# Perform home-manager commands on WSL2. +function wsl2 { + clean + + local command="${1}" + + NIXPKGS_ALLOW_UNFREE=1 home-manager "${command}" --flake ".#wsl2" --impure +} + +TIMEFORMAT=$'\nTask completed in %3lR' +time "${@:-help}"