Skip to content

Commit

Permalink
Merge branch 'feat/t510-updates'
Browse files Browse the repository at this point in the history
  • Loading branch information
tcarrio committed Oct 21, 2024
2 parents d36e5c8 + f962d5a commit 2d2a3cf
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 65 deletions.
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
glass = libx.mkHost { systemType = "workstation"; hostname = "glass"; username = "tcarrio"; desktop = "kde6"; };
kuroi = libx.mkHost { systemType = "workstation"; hostname = "kuroi"; username = "tcarrio"; desktop = "pantheon"; };
t510 = libx.mkHost { systemType = "workstation"; hostname = "t510"; username = "tcarrio"; desktop = "i3"; };
t510-headless = libx.mkHost { systemType = "workstation"; hostname = "t510-headless"; username = "tcarrio"; };

# Servers
# Can be executed locally:
Expand Down
35 changes: 26 additions & 9 deletions install.sh
100644 → 100755
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

Expand Down Expand Up @@ -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
Expand All @@ -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
1 change: 1 addition & 0 deletions nixos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
./mixins/services/firewall.nix
./mixins/services/fwupd.nix
./mixins/services/kmscon.nix
./mixins/services/networkmanager.nix
./mixins/services/openssh.nix
./mixins/services/smartmon.nix
./mixins/users/root
Expand Down
11 changes: 11 additions & 0 deletions nixos/workstation/t510-headless/default.nix
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
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
disko.devices = {
disk = {
sda = {
device = builtins.elemAt disks 0;
device = "/dev/disk/by-id/ata-Samsung_SSD_850_PRO_512GB_S250NXAH211618D";
type = "disk";
content = {
type = "gpt";
Expand Down
5 changes: 3 additions & 2 deletions nixos/workstation/t510/default.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Device: Lenovo ThinkPad T510
# CPU: Intel i5 M 520
# RAM: 8GB DDR2
# SATA: 120GB SSD
# SATA: 500GB SSD

{ inputs, lib, pkgs, ... }: {
imports = [
(import ./disks.nix { })
(import ../t510-headless/disks.nix { })

inputs.nixos-hardware.nixosModules.common-cpu-intel
inputs.nixos-hardware.nixosModules.common-pc
Expand Down Expand Up @@ -74,3 +74,4 @@

nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
}

50 changes: 0 additions & 50 deletions nixos/workstation/t510/hardware-configuration.nix

This file was deleted.

0 comments on commit 2d2a3cf

Please sign in to comment.