diff --git a/flake.lock b/flake.lock index 4271c422..58445563 100644 --- a/flake.lock +++ b/flake.lock @@ -115,11 +115,11 @@ ] }, "locked": { - "lastModified": 1724639687, - "narHash": "sha256-L2h46/z8WExNvtCEdZ8YuMu5TwfAGsKXXgM7pyIShvs=", + "lastModified": 1729281548, + "narHash": "sha256-MuojlSnwAJAwfhgmW8ZtZrwm2Sko4fqubCvReqbUzYw=", "owner": "nix-community", "repo": "disko", - "rev": "b09eb605e376c9e95c87c0ef3fcb8008e11c8368", + "rev": "a6a3179ddf396dfc28a078e2f169354d0c137125", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index b244bf2d..84c53864 100644 --- a/flake.nix +++ b/flake.nix @@ -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: diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index 1af02e18..55889e9d --- a/install.sh +++ b/install.sh @@ -1,26 +1,37 @@ -#!/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 [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 @@ -28,6 +39,8 @@ 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 @@ -35,6 +48,8 @@ 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,7 +82,9 @@ 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" @@ -75,12 +92,12 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then 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 git@github.com:tcarrio/nix-config.git + pushd "$TARGET_USER_HOME/0xc/nixcfg" + git remote set-url origin git@github.com: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 \ No newline at end of file +fi diff --git a/nixos/default.nix b/nixos/default.nix index 51c49ff1..570fe49b 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -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 diff --git a/nixos/workstation/t510-headless/default.nix b/nixos/workstation/t510-headless/default.nix new file mode 100644 index 00000000..9cf53071 --- /dev/null +++ b/nixos/workstation/t510-headless/default.nix @@ -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 + ]; +} diff --git a/nixos/workstation/t510/disks.nix b/nixos/workstation/t510-headless/disks.nix similarity index 87% rename from nixos/workstation/t510/disks.nix rename to nixos/workstation/t510-headless/disks.nix index 3bcd2352..d76997df 100644 --- a/nixos/workstation/t510/disks.nix +++ b/nixos/workstation/t510-headless/disks.nix @@ -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"; diff --git a/nixos/workstation/t510/default.nix b/nixos/workstation/t510/default.nix index 1c27aa9a..c52525ec 100644 --- a/nixos/workstation/t510/default.nix +++ b/nixos/workstation/t510/default.nix @@ -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 @@ -74,3 +74,4 @@ nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; } + diff --git a/nixos/workstation/t510/hardware-configuration.nix b/nixos/workstation/t510/hardware-configuration.nix deleted file mode 100644 index b68629a5..00000000 --- a/nixos/workstation/t510/hardware-configuration.nix +++ /dev/null @@ -1,50 +0,0 @@ -# Do not modify this file! It was generated by ‘nixos-generate-config’ -# and may be overwritten by future invocations. Please make changes -# to /etc/nixos/configuration.nix instead. -{ config, lib, modulesPath, ... }: - -{ - imports = - [ - (modulesPath + "/installer/scan/not-detected.nix") - ]; - - fileSystems."/" = - { - device = "/dev/disk/by-uuid/140fca12-c2a2-411c-8b0f-1dd4547f1f0e"; - fsType = "ext4"; - }; - - # Bootloader. - boot.loader.grub = { - enable = true; - device = "/dev/sda"; - useOSProber = true; - - # Enable grub cryptodisk - enableCryptodisk = true; - }; - - # Setup keyfile - boot.initrd = { - secrets = { - "/crypto_keyfile.bin" = null; - }; - - luks.devices."luks-1175ca46-0654-4ba3-b8bf-a82a29545879".device = "/dev/disk/by-uuid/1175ca46-0654-4ba3-b8bf-a82a29545879"; - }; - - - swapDevices = [ ]; - - # Enables DHCP on each ethernet and wireless interface. In case of scripted networking - # (the default) this is the recommended approach. When using systemd-networkd it's - # still possible to use this option, but it's recommended to use it in conjunction - # with explicit per-interface declarations with `networking.interfaces..useDHCP`. - networking.useDHCP = lib.mkDefault true; - # networking.interfaces.enp0s25.useDHCP = lib.mkDefault true; - # networking.interfaces.wlp3s0.useDHCP = lib.mkDefault true; - - nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; -}