end of refactor for now

This commit is contained in:
2025-12-19 08:04:19 +03:00
parent aeb61e6690
commit 3e9e074cc5
12 changed files with 44 additions and 66 deletions
+11
View File
@@ -0,0 +1,11 @@
# NixOS
sudo nixos-rebuild switch --flake .#myhost \
--override-input personal path:/home/$USER/.config/nix/personal.nix \
--override-input hw path:/etc/nixos/hardware-configuration.nix
# Home Manager only
home-manager switch --flake .#$(nix eval --raw --expr '(import ./personal.stub.nix).username') \
--override-input personal path:/home/$USER/.config/nix/personal.nix
sudo nixos-rebuild switch --flake . \
--override-input hw path:/etc/nixos/hardware-configuration.nix
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root (sudo)." 1>&2
exit 1
fi
echo "Removing all backups in /etc/nixos..."
rm -rf /etc/nixos.bak.*
echo "Removing all backups in $HOME/.config/home-manager..."
rm -rf $HOME/.config/home-manager.bak.*
echo "Run nix-collect-garbage"
nix-collect-garbage --delete-older-than 7d
echo "Done!"
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -euo pipefail
# ---------------- CONFIG ----------------
SRC_FOLDER="./home-manager" # source folder in your repo
DEST_FOLDER="$HOME/.config/home-manager" # target folder
# ----------------------------------------
# Create backup if destination exists
if [ -d "$DEST_FOLDER" ]; then
BACKUP_DIR="$DEST_FOLDER.bak.$(date +%Y%m%d%H%M%S)"
echo "Creating backup of existing configuration at $BACKUP_DIR..."
cp -r "$DEST_FOLDER" "$BACKUP_DIR"
fi
echo "Copying Home Manager configuration from '$SRC_FOLDER' to '$DEST_FOLDER'..."
mkdir -p "$DEST_FOLDER"
cp -a "$SRC_FOLDER/." "$DEST_FOLDER/"
echo "Running home-manager switch..."
nix flake update "$DEST_FOLDER"
home-manager switch --flake ~/.config/home-manager
echo "Done! Backup (if any) stored at $BACKUP_DIR"
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -euo pipefail
# ---------------- CONFIG ----------------
SRC_FOLDER="./nixos" # folder in your repo
DEST_FOLDER="/etc/nixos" # target folder
# ----------------------------------------
# Check for root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root (sudo)." 1>&2
exit 1
fi
echo "Copying files from '$SRC_FOLDER' to '$DEST_FOLDER'..."
# Backup existing /etc/nixos (optional)
BACKUP_DIR="/etc/nixos.bak.$(date +%Y%m%d%H%M%S)"
echo "Backing up current /etc/nixos to $BACKUP_DIR"
cp -r "$DEST_FOLDER" "$BACKUP_DIR"
# Copy files
cp -a "$SRC_FOLDER/." "$DEST_FOLDER/"
echo "Done! Files from '$SRC_FOLDER' have been copied to '$DEST_FOLDER'."
# echo "You may now run 'sudo nixos-rebuild switch' if needed."
nixos-rebuild switch --fast
echo "Done!"