just recipe improvements

This commit is contained in:
Bryan Ramos 2024-05-13 20:57:23 -04:00
parent 48ac13ac19
commit ca986b2ab2
Signed by: bryan
GPG key ID: 6ABDCD144D6643C8

View file

@ -1,8 +1,10 @@
SYSTEM := "$(echo $HOSTNAME)"
default: default:
@just --list @just --list
# Output what derivations will be built # Output what derivations will be built
test TYPE="nixos" SYSTEM="desktop": test SYSTEM TYPE="nix":
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
case "{{TYPE}}" in case "{{TYPE}}" in
@ -35,15 +37,75 @@ test TYPE="nixos" SYSTEM="desktop":
;; ;;
esac esac
# Build the nix expression and hydrate the results directory - pass VM flag to build a VM
build SYSTEM TYPE="nix":
#!/usr/bin/env bash
set -euo pipefail
case "{{TYPE}}" in
"nix")
if [ "{{SYSTEM}}" = "desktop" ] || [ "{{SYSTEM}}" = "server" ] || [ "{{SYSTEM}}" = "wsl" ] || [ "{{SYSTEM}}" = "laptop" ]; then
echo "Hydrating resulting NixOS configuration for {{SYSTEM}}..."
nix build .#nixosConfigurations."{{SYSTEM}}".config.system.build.toplevel -L
exit 0
else
echo "Error: Unknown argument - '{{SYSTEM}}'"
echo "Use one of:"
echo " desktop"
echo " server"
echo " laptop"
echo " wsl"
exit 1
fi
;;
"home")
echo "Hydrating resulting home configuration..."
nix build --dry-run .#homeConfigurations."workstation".config.home-manager.build.toplevel -L
exit 0
;;
"vm")
if [ "{{SYSTEM}}" = "desktop" ] || [ "{{SYSTEM}}" = "server" ] || [ "{{SYSTEM}}" = "wsl" ] || [ "{{SYSTEM}}" = "laptop" ]; then
echo "Building VM for {{SYSTEM}}..."
nixos-rebuild build-vm --flake .#{{SYSTEM}}
result/bin/run-{{SYSTEM}}-vm
exit 0
else
echo "Error: Unknown argument - '{{SYSTEM}}'"
echo "Use one of:"
echo " desktop"
echo " server"
echo " laptop"
echo " wsl"
exit 1
fi
;;
*)
echo "Invalid usage: {{TYPE}}."
echo "Use one of:"
echo " nixos"
echo " home"
exit 1
;;
esac
search PKG:
nix search nixpkgs {{PKG}}
pkgs:
@xdg-open https://search.nixos.org/packages
options:
@xdg-open https://search.nixos.org/options
# NixOS-rebuild switch short-hand # NixOS-rebuild switch short-hand
up SYSTEM="desktop": switch BACK:
@echo "Switching to next generation" @echo -e "\033[32m->> Switching to next generation ->>\033[0m"
sudo nixos-rebuild switch --flake .#{{SYSTEM}} @sudo nixos-rebuild switch --flake .#{{SYSTEM}}
# NixOS-rebuild boot short-hand # NixOS-rebuild boot short-hand
boot SYSTEM="desktop": boot:
@echo -e "\033[34m->> Reboot to new generation ->>\033[0m"
@echo "Switching to next generation on reboot" @echo "Switching to next generation on reboot"
sudo nixos-rebuild boot --flake .#{{SYSTEM}} @sudo nixos-rebuild boot --flake .#{{SYSTEM}}
# Commit all changes and push to upstream # Commit all changes and push to upstream
gh MESSAGE: gh MESSAGE: