-
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
8 changed files
with
46 additions
and
65 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,40 +1,55 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
#set -euo pipefail | ||
|
||
TARGET_HOST="${1:-}" | ||
TARGET_USER="${2:-tcarrio}" | ||
TARGET_TYPE="${3:-}" | ||
TARGET_NIXOS_CONFIG_NAME="${4:-$TARGET_HOST}" | ||
|
||
function usage() { | ||
echo """ | ||
install.sh <host> <user> <system-type> [nixos-config-name] | ||
example: install.sh t510 tcarrio workstation t510-headless | ||
""" | ||
} | ||
|
||
if [ "$(id -u)" -eq 0 ]; then | ||
echo "ERROR! $(basename "$0") should be run as a regular user" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -d "$HOME/0xc/nix-config/.git" ]; then | ||
git clone https://github.com/tcarrio/nix-config.git "$HOME/0xc/nix-config" | ||
if [ ! -d "$HOME/0xc/nixcfg/.git" ]; then | ||
git clone https://github.com/tcarrio/nixcfg.git "$HOME/0xc/nixcfg" | ||
fi | ||
|
||
pushd "$HOME/0xc/nix-config" | ||
pushd "$HOME/0xc/nixcfg" | ||
|
||
if [[ -z "$TARGET_HOST" ]]; then | ||
echo "ERROR! $(basename "$0") requires a hostname as the first argument" | ||
echo " The following hosts are available" | ||
ls -1 nixos/*/default.nix | cut -d'/' -f2 | grep -v iso | ||
echo "" | ||
usage | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$TARGET_USER" ]]; then | ||
echo "ERROR! $(basename "$0") requires a username as the second argument" | ||
echo " The following users are available" | ||
ls -1 nixos/mixins/users/ | grep -v -E "nixos|root" | ||
echo "" | ||
usage | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$TARGET_TYPE" ]]; then | ||
echo "ERROR! $(basename "$0") requires a type as the third argument" | ||
echo " The following types are available" | ||
ls -1 nixos/ | grep -v -E "nixos|root|mixins" | ||
echo "" | ||
usage | ||
exit 1 | ||
fi | ||
|
||
|
@@ -67,20 +82,22 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then | |
--mode zap_create_mount \ | ||
"$TARGET_HOST_ROOT/disks.nix" | ||
|
||
sudo nixos-install --no-root-password --flake ".#$TARGET_HOST" | ||
MAX_CONCURRENCY=$(($(nproc) - 1)) | ||
|
||
sudo nixos-install -j $MAX_CONCURRENCY --cores $MAX_CONCURRENCY --no-root-password --flake ".#$TARGET_NIXOS_CONFIG_NAME" | ||
|
||
if [[ "$TARGET_USER" == "root" ]]; then | ||
TARGET_USER_HOME="/mnt/root" | ||
else | ||
TARGET_USER_HOME="/mnt/home/$TARGET_USER" | ||
fi | ||
|
||
# Rsync nix-config to the target install and set the remote origin to SSH. | ||
# Rsync nixcfg to the target install and set the remote origin to SSH. | ||
sudo mkdir -p "$TARGET_USER_HOME" | ||
sudo chown $(whoami):root -R "$TARGET_USER_HOME" | ||
rsync -a --delete "$HOME/0xc/" "$TARGET_USER_HOME/0xc/" | ||
pushd "$TARGET_USER_HOME/0xc/nix-config" | ||
git remote set-url origin [email protected]:tcarrio/nix-config.git | ||
pushd "$TARGET_USER_HOME/0xc/nixcfg" | ||
git remote set-url origin [email protected]:tcarrio/nixcfg.git | ||
popd | ||
|
||
# If there is a keyfile for a data disk, put copy it to the root partition and | ||
|
@@ -89,4 +106,4 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then | |
sudo cp /tmp/data.keyfile /mnt/etc/data.keyfile | ||
sudo chmod 0400 /mnt/etc/data.keyfile | ||
fi | ||
fi | ||
fi |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Device: Lenovo ThinkPad T510 | ||
# CPU: Intel i5 M 520 | ||
# RAM: 8GB DDR2 | ||
# SATA: 500GB SSD | ||
|
||
_: { | ||
imports = [ | ||
(import ./disks.nix { }) | ||
../../iso/iso-console | ||
]; | ||
} |
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
This file was deleted.
Oops, something went wrong.