removed GIT
This commit is contained in:
@@ -4,7 +4,6 @@ set -euo pipefail
|
||||
### ─────────────────────────────
|
||||
### Configuration
|
||||
### ─────────────────────────────
|
||||
REPO_URL="https://gitea.data-pro.nu/henrov/nixos.git"
|
||||
ZIP_URL="https://gitea.data-pro.nu/henrov/nixos/archive/main.zip"
|
||||
|
||||
TARGET_DIR="$HOME/Droidnix"
|
||||
@@ -26,7 +25,7 @@ rm -rf "$TARGET_DIR"
|
||||
mkdir -p "$TARGET_DIR"
|
||||
|
||||
### ─────────────────────────────
|
||||
### Step 3 — Download repository
|
||||
### Step 3 — Download repository (ZIP ONLY)
|
||||
### ─────────────────────────────
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
|
||||
@@ -35,28 +34,26 @@ cleanup() {
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
if command -v git >/dev/null 2>&1; then
|
||||
echo "Using git clone..."
|
||||
git clone "$REPO_URL" "$TMP_DIR/repo"
|
||||
cp -r "$TMP_DIR/repo/Droidnix/"* "$TARGET_DIR/"
|
||||
|
||||
elif command -v wget >/dev/null 2>&1; then
|
||||
echo "Using wget..."
|
||||
if command -v wget >/dev/null 2>&1; then
|
||||
echo "Downloading with wget..."
|
||||
wget -O "$TMP_DIR/main.zip" "$ZIP_URL"
|
||||
unzip -q "$TMP_DIR/main.zip" -d "$TMP_DIR/unzipped"
|
||||
cp -r "$TMP_DIR/unzipped"/*/Droidnix/* "$TARGET_DIR/"
|
||||
|
||||
elif command -v curl >/dev/null 2>&1; then
|
||||
echo "Using curl..."
|
||||
echo "Downloading with curl..."
|
||||
curl -L "$ZIP_URL" -o "$TMP_DIR/main.zip"
|
||||
unzip -q "$TMP_DIR/main.zip" -d "$TMP_DIR/unzipped"
|
||||
cp -r "$TMP_DIR/unzipped"/*/Droidnix/* "$TARGET_DIR/"
|
||||
|
||||
else
|
||||
echo "Error: need git, wget, or curl"
|
||||
echo "Error: need wget or curl"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Extracting..."
|
||||
unzip -q "$TMP_DIR/main.zip" -d "$TMP_DIR/unzipped"
|
||||
|
||||
# Gitea zip contains folder like: repo-main/
|
||||
# Adjusting safely:
|
||||
cp -r "$TMP_DIR"/unzipped/*/Droidnix/* "$TARGET_DIR/"
|
||||
|
||||
### ─────────────────────────────
|
||||
### Step 4 — Rename files (deepest first)
|
||||
### ─────────────────────────────
|
||||
@@ -67,7 +64,6 @@ find "$TARGET_DIR" -depth | while read -r path; do
|
||||
base=$(basename "$path")
|
||||
|
||||
newbase="$base"
|
||||
|
||||
newbase="${newbase//traveldroid/$HOSTNAME}"
|
||||
newbase="${newbase//henrov/$USER_NAME}"
|
||||
|
||||
@@ -84,26 +80,21 @@ done
|
||||
echo "Replacing content..."
|
||||
|
||||
# 5.1 generated/ henrov → user
|
||||
echo "henrov → $USER..."
|
||||
if [ -d "$TARGET_DIR/generated" ]; then
|
||||
find "$TARGET_DIR/generated" -type f -exec sed -i "s/henrov/$USER_NAME/g" {} +
|
||||
fi
|
||||
|
||||
|
||||
# 5.3 path replacement (skip binaries loosely)
|
||||
echo "path replacement..."
|
||||
# 5.3 path replacement
|
||||
find "$TARGET_DIR" -type f -exec grep -Iq . {} \; -print | while read -r file; do
|
||||
sed -i "s#~/Repos/nixos/Droidnix#~/Droidnix#g" "$file" || true
|
||||
done
|
||||
|
||||
# 5.4 traveldroid → hostname everywhere
|
||||
echo "traveldroid → $HOSTNAME"
|
||||
# 5.4 traveldroid → hostname
|
||||
find "$TARGET_DIR" -type f -exec grep -Iq . {} \; -print | while read -r file; do
|
||||
sed -i "s/traveldroid/$HOSTNAME/g" "$file" || true
|
||||
done
|
||||
|
||||
# 5.2 & 5.6 README.org block replacement
|
||||
echo "README.org block replacement"
|
||||
# README.org block replacement
|
||||
README="$TARGET_DIR/README.org"
|
||||
|
||||
if [ -f "$README" ]; then
|
||||
@@ -112,11 +103,14 @@ if [ -f "$README" ]; then
|
||||
|
||||
{
|
||||
if ($0 ~ /^\*\* =/) inblock=1
|
||||
|
||||
if (inblock == 1) {
|
||||
gsub("henrov", user)
|
||||
gsub("traveldroid", host)
|
||||
}
|
||||
|
||||
print $0
|
||||
|
||||
if ($0 ~ /^#\+END_SRC/) inblock=0
|
||||
}' "$README" > "$README.tmp" && mv "$README.tmp" "$README"
|
||||
fi
|
||||
@@ -125,7 +119,6 @@ fi
|
||||
### Step 6 — Hardware config
|
||||
### ─────────────────────────────
|
||||
HOST_DIR="$TARGET_DIR/generated/hosts/$HOSTNAME"
|
||||
echo "$HOST_DIR/hardware-configuration.nix"
|
||||
mkdir -p "$HOST_DIR"
|
||||
|
||||
echo "Generating hardware configuration..."
|
||||
@@ -135,7 +128,7 @@ sudo nixos-generate-config --show-hardware-config > \
|
||||
### ─────────────────────────────
|
||||
### Step 7 — Inject hardware into README.org
|
||||
### ─────────────────────────────
|
||||
echo "$HOST_DIR/hardware-configuration.nix"
|
||||
|
||||
if [ -f "$README" ]; then
|
||||
awk -v file="$HOST_DIR/hardware-configuration.nix" '
|
||||
BEGIN {inblock=0}
|
||||
@@ -163,12 +156,9 @@ fi
|
||||
### ─────────────────────────────
|
||||
### Step 8 — Build system
|
||||
### ─────────────────────────────
|
||||
echo "sudo nixos-rebuild switch --flake .#$HOSTNAME in $TARGET_DIR"
|
||||
echo "Building NixOS configuration..."
|
||||
cd "$TARGET_DIR"
|
||||
git init
|
||||
git branch -m main
|
||||
git add "flake.nix"
|
||||
git commit -m "1st install"
|
||||
|
||||
sudo nixos-rebuild switch --flake ".#$HOSTNAME"
|
||||
|
||||
### ─────────────────────────────
|
||||
@@ -178,16 +168,9 @@ cat <<EOF
|
||||
|
||||
Installation complete. Please reboot your system.
|
||||
|
||||
After rebooting, any changes to your NixOS configuration must be made in
|
||||
After rebooting, any changes must be made in:
|
||||
|
||||
~/Droidnix/README.org. Before rebuilding, first tangle the org file using:
|
||||
|
||||
emacs --batch --no-init-file ~/Droidnix/README.org \
|
||||
--eval "(require 'org)" \
|
||||
--eval "(require 'ob-tangle)" \
|
||||
--eval "(find-file \"README.org\")" \
|
||||
--eval "(with-temp-message \"\" (org-babel-tangle))" \
|
||||
--eval "(with-temp-message \"\" (org-html-export-to-html))"
|
||||
~/Droidnix/README.org
|
||||
|
||||
Then rebuild with:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user