-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
249 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
boot-plymouth | ||
cli-btop | ||
cli-eza | ||
cli-just | ||
cli-nvim | ||
cli-oh-my-posh | ||
cli-zellij | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
# Variables | ||
hostname := `hostname` | ||
flake_dir := env_var_or_default("FLAKE_DIR", "~/.config/nixos") | ||
flake_url := env_var_or_default("FLAKE_URL", "github:airone01/flake") | ||
|
||
# Default recipe to display help | ||
default: | ||
@just --list | ||
|
||
# Build and switch to a new configuration | ||
switch host=hostname *args="": check-dirty | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
echo "🔄 Rebuilding system for {{host}}..." | ||
sudo nixos-rebuild switch --flake {{flake_dir}}#{{host}} {{args}} 2>&1 | tee nixos-switch.log || ( | ||
grep --color error nixos-switch.log && false | ||
) | ||
echo "✅ System successfully rebuilt!" | ||
# Build and test configuration without switching | ||
test host=hostname *args="": check-dirty | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
echo "🧪 Testing configuration for {{host}}..." | ||
nixos-rebuild test --flake {{flake_dir}}#{{host}} {{args}} 2>&1 | tee nixos-test.log || ( | ||
grep --color error nixos-test.log && false | ||
) | ||
echo "✅ Test build successful!" | ||
# Build an ISO image | ||
iso system="ursamajor" format="install-iso": | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
echo "📀 Building {{format}} for {{system}}..." | ||
nix build {{flake_dir}}#{{system}}-{{format}} | ||
echo "✅ ISO build complete!" | ||
# Update all flake inputs | ||
update: | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
echo "⬆️ Updating flake inputs..." | ||
nix flake update {{flake_dir}} | ||
echo "✅ Flake inputs updated!" | ||
# Update specific flake input | ||
update-input input: | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
echo "⬆️ Updating {{input}}..." | ||
nix flake lock {{flake_dir}} --update-input {{input}} | ||
echo "✅ {{input}} updated!" | ||
# Format all nix files | ||
fmt: | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
echo "🎨 Formatting nix files..." | ||
find . -name "*.nix" -exec alejandra {} + | ||
echo "✅ Formatting complete!" | ||
# Check nix file formatting | ||
fmt-check: | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
echo "🔍 Checking nix formatting..." | ||
find . -name "*.nix" -exec alejandra --check {} + | ||
echo "✅ Format check passed!" | ||
# Run checks on the flake | ||
check: | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
echo "🔍 Running flake checks..." | ||
nix flake check {{flake_dir}} | ||
echo "✅ All checks passed!" | ||
# Clean old generations | ||
clean generations="14d": | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
echo "🧹 Cleaning generations older than {{generations}}..." | ||
sudo nix-collect-garbage --delete-older-than {{generations}} | ||
sudo /run/current-system/bin/switch-to-configuration switch | ||
echo "✅ System cleaned!" | ||
# Enter a development shell | ||
develop shell="commitlint": | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
echo "🚀 Launching {{shell}} development environment..." | ||
nix develop {{flake_dir}}#{{shell}} | ||
# Show the diff of staged nix files | ||
show-diff: | ||
git diff -U0 *.nix | ||
|
||
# Internal recipe to check for dirty git state | ||
[private] | ||
check-dirty: | ||
#!/usr/bin/env bash | ||
if [ -n "$(git status --porcelain)" ]; then | ||
echo "⚠️ Warning: Working directory is dirty. Uncommitted changes may be lost." | ||
echo "Continue? [y/N]" | ||
read -r response | ||
if [[ ! "$response" =~ ^[Yy]$ ]]; then | ||
echo "Operation cancelled." | ||
exit 1 | ||
fi | ||
fi | ||
# Generate an initial SOPS key | ||
sops-key: | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
echo "🔑 Generating SOPS age key..." | ||
mkdir -p ~/.config/sops/age | ||
if [ ! -f ~/.config/sops/age/keys.txt ]; then | ||
age-keygen -o ~/.config/sops/age/keys.txt | ||
echo "✅ Key generated at ~/.config/sops/age/keys.txt" | ||
else | ||
echo "⚠️ Key already exists at ~/.config/sops/age/keys.txt" | ||
fi | ||
# Bootstrap a new system | ||
bootstrap host tools="git curl": | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
echo "🚀 Bootstrapping new system for {{host}}..." | ||
sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos | ||
sudo nix-channel --update | ||
sudo nix-env -iA nixos.{{tools}} | ||
if [ ! -d "{{flake_dir}}" ]; then | ||
git clone {{flake_url}} {{flake_dir}} | ||
fi | ||
echo "✅ Bootstrap complete! You can now run: just switch {{host}}" |
Oops, something went wrong.