mirror of
https://github.com/itme-brain/nixos.git
synced 2026-03-24 00:29:43 -04:00
justfile
This commit is contained in:
parent
4368228862
commit
fb399f2db9
2 changed files with 35 additions and 140 deletions
111
install.sh
111
install.sh
|
|
@ -1,111 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
arg="${1:-nixos}"
|
|
||||||
isNixOS=$(grep -q 'ID=nixos' /etc/os-release)
|
|
||||||
|
|
||||||
case "$arg" in
|
|
||||||
"nixos")
|
|
||||||
if ! isNixOS; then
|
|
||||||
echo "⚠️ - Requires NixOS & sudo priveledge"
|
|
||||||
fi
|
|
||||||
echo "Install this NixOS Configuration? (y/n)"
|
|
||||||
while true; do
|
|
||||||
read res;
|
|
||||||
if [ "$res" = "y" ] || [ "$res" = "Y" ]; then
|
|
||||||
echo "Installing...";
|
|
||||||
if [ "$EUID" -ne 0 ]; then
|
|
||||||
echo "Allow sudo access? (y/n)"
|
|
||||||
while true; do
|
|
||||||
read -r res
|
|
||||||
case "$res" in
|
|
||||||
[yY])
|
|
||||||
exec sudo bash "$0" "$@"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
[nN])
|
|
||||||
echo "Aborting..."
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Please enter a valid response (y/n)"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
if [ -d "/etc/nixos" ]; then
|
|
||||||
echo "The /etc/nixos directory exists."
|
|
||||||
echo "Would you like to back up and proceed? (y/n)"
|
|
||||||
while true; do
|
|
||||||
read -r res
|
|
||||||
case "$res" in
|
|
||||||
[yY])
|
|
||||||
mkdir -p $(git rev-parse --show-toplevel)/bkup
|
|
||||||
cp -r /etc/nixos $(git rev-parse --show-toplevel)/bkup.nixos_$(date +%Y%m%d%H%M%S)
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
[nN])
|
|
||||||
echo "Cancelled. Aborting..."
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Error: Please enter a valid response (y/n)"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
else
|
|
||||||
ln -s /etc/nixos $(git rev-parse --show-toplevel)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
elif [ "{{TYPE}}" = "home" ]; then
|
|
||||||
echo "Install this Home-Manager Configuration?"
|
|
||||||
echo "⚠️ - If you don't have nix + home-manager installed, this will install them both"
|
|
||||||
echo "Proceed? (y/n)"
|
|
||||||
while true; do
|
|
||||||
read -r res
|
|
||||||
case "$res" in
|
|
||||||
[yY])
|
|
||||||
echo "Installing..."
|
|
||||||
|
|
||||||
if grep -q
|
|
||||||
|
|
||||||
|
|
||||||
if [ -d "$HOME/.config/home-manager" ]; then
|
|
||||||
echo "The ~/.config/home-manager directory exists."
|
|
||||||
echo "Would you like to back up and proceed? (y/n)"
|
|
||||||
while true; do
|
|
||||||
read -r res
|
|
||||||
case "$res" in
|
|
||||||
[yY])
|
|
||||||
mkdir -p $(git rev-parse --show-toplevel)/bkup
|
|
||||||
mv $HOME/.config/home-manager $(git rev-parse --show-toplevel)/bkup/home-manager_$(date +%Y%m%d%H%M%S)
|
|
||||||
ln -s $HOME/.config/home-manager $(git rev-parse --show-toplevel)
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
[nN])
|
|
||||||
echo "Cancelled. Aborting..."
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Error: Please enter a valid response (y/n)"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
else
|
|
||||||
ln -s $HOME/.config/home-manager $(git rev-parse --show-toplevel)
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
[nN])
|
|
||||||
echo "Cancelled. Aborting..."
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Error: Please enter a valid response (y/n)"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
flake_config="experimental-features = nix-command flakes"
|
|
||||||
|
|
||||||
if [ -f "/etc/nix/nix.conf" ] || [ -f "$HOME/.config/nix/nix.conf" ]; then
|
|
||||||
if grep -q "^$flake_config" ""
|
|
||||||
64
justfile
64
justfile
|
|
@ -2,40 +2,46 @@
|
||||||
test TYPE="nixos" SYSTEM="desktop":
|
test TYPE="nixos" SYSTEM="desktop":
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
if [ "{{TYPE}}" = "home" ]; then
|
case "{{TYPE}}" in
|
||||||
if [ -n "{{SYSTEM}}" ]; then
|
"nixos")
|
||||||
echo "Error: Undefined argument"
|
if [ "{{SYSTEM}}" = "desktop" ] || [ "{{SYSTEM}}" = "server" ] || [ "{{SYSTEM}}" = "wsl" ] || [ "{{SYSTEM}}" = "laptop" ]; then
|
||||||
exit 1
|
echo "Testing NixOS configuration for {{SYSTEM}}..."
|
||||||
fi
|
nix build --dry-run .#nixosConfigurations."{{SYSTEM}}".config.system.build.toplevel -L
|
||||||
echo "Testing home configuration..."
|
exit 0
|
||||||
nix build --dry-run .#homeConfigurations."workstation".config.system.build.toplevel -L
|
else
|
||||||
elif [ "{{TYPE}}" = "nixos" ]; then
|
echo "Error: Unknown argument - '{{SYSTEM}}'"
|
||||||
if [ "{{SYSTEM}}" = "desktop" ] || [ "{{SYSTEM}}" = "server" ] || [ "{{SYSTEM}}" = "wsl" ] || [ "{{SYSTEM}}" = "laptop" ]; then
|
echo "Use one of:"
|
||||||
echo "Testing NixOS configuration for {{SYSTEM}}..."
|
echo " desktop"
|
||||||
nix build --dry-run .#nixosConfigurations."{{SYSTEM}}".config.system.build.toplevel -L
|
echo " server"
|
||||||
else
|
echo " laptop"
|
||||||
echo "Error: Unknown argument - '{{SYSTEM}}'"
|
echo " wsl"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
"home")
|
||||||
|
echo "Testing home configuration..."
|
||||||
|
nix build --dry-run .#homeConfigurations."workstation".config.home-manager.build.toplevel -L
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Invalid usage: {{TYPE}}.";
|
||||||
echo "Use one of:"
|
echo "Use one of:"
|
||||||
echo " desktop"
|
echo " nixos"
|
||||||
echo " server"
|
echo " home"
|
||||||
echo " laptop"
|
|
||||||
echo " wsl"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
;;
|
||||||
else
|
esac
|
||||||
echo "Invalid usage: {{TYPE}}.";
|
|
||||||
echo "Use one of:"
|
|
||||||
echo " nixos"
|
|
||||||
echo " home"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Symlinks /etc/nixos or ~/.config/home-manager to this repo
|
# NixOS-rebuild switch short-hand
|
||||||
install:
|
up SYSTEM="desktop":
|
||||||
source ./install
|
sudo nixos-rebuild switch --flake .#{{SYSTEM}}
|
||||||
|
|
||||||
|
# NixOS-rebuild boot short-hand
|
||||||
|
boot SYSTEM="desktop":
|
||||||
|
sudo nixos-rebuild boot --flake .#{{SYSTEM}}
|
||||||
|
|
||||||
# Commit all changes and push to upstream
|
# Commit all changes and push to upstream
|
||||||
gh MESSAGE="":
|
gh MESSAGE:
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
if [ -n "{{MESSAGE}}" ]; then
|
if [ -n "{{MESSAGE}}" ]; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue