mirror of
https://github.com/itme-brain/nixos.git
synced 2026-03-24 00:29:43 -04:00
install script
This commit is contained in:
parent
27c2207f85
commit
4368228862
2 changed files with 154 additions and 85 deletions
128
justfile
128
justfile
|
|
@ -1,89 +1,47 @@
|
|||
# Run a dry-build
|
||||
test TYPE="nix" SYSTEM="":
|
||||
@if [ "{{TYPE}}" = "home" ]; then \
|
||||
if [ -n "{{SYSTEM}}" ]; then \
|
||||
echo "Error: Undefined argument"; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
echo "Testing home configuration..."; \
|
||||
nix build --dry-run .#homeConfigurations."workstation".config.system.build.toplevel -L; \
|
||||
elif [ "{{TYPE}}" = "nix" ]; then \
|
||||
if [ -z "{{SYSTEM}}" ]; then \
|
||||
SYSTEM="desktop"; \
|
||||
fi; \
|
||||
if [ "{{SYSTEM}}" = "desktop" ] || [ "{{SYSTEM}}" = "server" ] || [ "{{SYSTEM}}" = "wsl" ] || [ "{{SYSTEM}}" = "laptop" ]; then \
|
||||
echo "Testing NixOS configuration for {{SYSTEM}}..."; \
|
||||
nix build --dry-run .#nixosConfigurations."{{SYSTEM}}".config.system.build.toplevel -L; \
|
||||
else \
|
||||
echo "Error: Unknown argument - '{{SYSTEM}}'"; \
|
||||
echo "Use one of:"; \
|
||||
echo " desktop"; \
|
||||
echo " server"; \
|
||||
echo " laptop"; \
|
||||
echo " wsl"; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
else \
|
||||
echo "Invalid usage: {{TYPE}}. Use 'home' or 'nix'."; \
|
||||
exit 1; \
|
||||
# Output what derivations will be built
|
||||
test TYPE="nixos" SYSTEM="desktop":
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
if [ "{{TYPE}}" = "home" ]; then
|
||||
if [ -n "{{SYSTEM}}" ]; then
|
||||
echo "Error: Undefined argument"
|
||||
exit 1
|
||||
fi
|
||||
echo "Testing home configuration..."
|
||||
nix build --dry-run .#homeConfigurations."workstation".config.system.build.toplevel -L
|
||||
elif [ "{{TYPE}}" = "nixos" ]; then
|
||||
if [ "{{SYSTEM}}" = "desktop" ] || [ "{{SYSTEM}}" = "server" ] || [ "{{SYSTEM}}" = "wsl" ] || [ "{{SYSTEM}}" = "laptop" ]; then
|
||||
echo "Testing NixOS configuration for {{SYSTEM}}..."
|
||||
nix build --dry-run .#nixosConfigurations."{{SYSTEM}}".config.system.build.toplevel -L
|
||||
else
|
||||
echo "Error: Unknown argument - '{{SYSTEM}}'"
|
||||
echo "Use one of:"
|
||||
echo " desktop"
|
||||
echo " server"
|
||||
echo " laptop"
|
||||
echo " wsl"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Invalid usage: {{TYPE}}.";
|
||||
echo "Use one of:"
|
||||
echo " nixos"
|
||||
echo " home"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Install this repo
|
||||
install TYPE="nixos":
|
||||
if [ "${{TYPE}}" = "nixos" ]; then \
|
||||
echo "Install this NixOS Configuration? (y/n)" \
|
||||
read res; \
|
||||
if [ "$res" = "y"] || [ "$res" = "Y"]; then \
|
||||
echo "Installing..."; \
|
||||
if [ -d "/etc/nixos" ]; then \
|
||||
echo "The /etc/nixos directory exists. Would you like to back up and proceed? (y/n)"; \
|
||||
read answer; \
|
||||
if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then \
|
||||
sudo cp -r /etc/nixos $(git rev-parse --show-toplevel)/nixos.bkup.$(date +%Y%m%d%H%M%S); \
|
||||
elif [ "$answer" = "n" ] || [ "$answer" = "N" ]; then \
|
||||
echo "Cancelled. Aborting..."; \
|
||||
exit 1; \
|
||||
else \
|
||||
echo "Error: Please enter a valid response (y/n)" \
|
||||
fi \
|
||||
else \
|
||||
sudo ln -s /etc/nixos $(git rev-parse --show-toplevel) \
|
||||
fi \
|
||||
elif [ "$res" = "n"] || [ "$res" = "N"]; then \
|
||||
echo "Cancelled. Aborting..."; \
|
||||
else \
|
||||
echo "Error: Please enter a valid response (y/n)" \
|
||||
fi
|
||||
if [ "${{TYPE}}" = "home" ]; then \
|
||||
echo "Install this Home-Manager Configuration? (y/n)" \
|
||||
read res; \
|
||||
if [ "$res" = "y"] || [ "$res" = "Y"]; then \
|
||||
echo "Installing..."; \
|
||||
if [ -d "~/.config/home-manager" ]; then \
|
||||
echo "The ~/.config/home-manager directory exists. Would you like to back up and proceed? (y/n)"; \
|
||||
read answer; \
|
||||
if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then \
|
||||
sudo cp -r ~/.config/home-manager $(git rev-parse --show-toplevel)/home-manager.bkup.$(date +%Y%m%d%H%M%S); \
|
||||
elif [ "$answer" = "n" ] || [ "$answer" = "N" ]; then \
|
||||
echo "Cancelled. Aborting..."; \
|
||||
exit 1; \
|
||||
else \
|
||||
echo "Error: Please enter a valid response (y/n)" \
|
||||
fi \
|
||||
else \
|
||||
sudo ln -s ~/.config/home-manager $(git rev-parse --show-toplevel) \
|
||||
fi \
|
||||
elif [ "$res" = "n"] || [ "$res" = "N"]; then \
|
||||
echo "Cancelled. Aborting..."; \
|
||||
else \
|
||||
echo "Error: Please enter a valid response (y/n)" \
|
||||
fi
|
||||
fi
|
||||
# Symlinks /etc/nixos or ~/.config/home-manager to this repo
|
||||
install:
|
||||
source ./install
|
||||
|
||||
# Commit all changes and push to upstream
|
||||
gh:
|
||||
@echo "Commit message:"
|
||||
@read message
|
||||
git add -A
|
||||
git commit -m "$$message"
|
||||
git push
|
||||
gh MESSAGE="":
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
if [ -n "{{MESSAGE}}" ]; then
|
||||
git add -A
|
||||
git commit -m "{{MESSAGE}}"
|
||||
git push
|
||||
else
|
||||
echo "Error: Empty commit message"
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue