From 4d026cac96f4a47de88ed255ef3d4e45b1c98a2c Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Tue, 2 Sep 2025 19:37:07 -0700 Subject: [PATCH] Starting config for rift. --- .gitignore | 1 + flake.lock | 21 ++++++++++ flake.nix | 7 +++- flash.sh | 21 ++++++++++ hw/rift/default.nix | 11 +++++ hw/rift/disk-config.nix | 67 ++++++++++++++++++++++++++++++ hw/rift/hardware-configuration.nix | 26 ++++++++++++ 7 files changed, 153 insertions(+), 1 deletion(-) create mode 100755 flash.sh create mode 100644 hw/rift/default.nix create mode 100644 hw/rift/disk-config.nix create mode 100644 hw/rift/hardware-configuration.nix diff --git a/.gitignore b/.gitignore index c4a847d..e96579f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /result +/*-linux.tar.gz diff --git a/flake.lock b/flake.lock index 1fc578f..9160a8a 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,25 @@ { "nodes": { + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1756733629, + "narHash": "sha256-dwWGlDhcO5SMIvMSTB4mjQ5Pvo2vtxvpIknhVnSz2I8=", + "owner": "nix-community", + "repo": "disko", + "rev": "a5c4f2ab72e3d1ab43e3e65aa421c6f2bd2e12a1", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, "nix-index-database": { "inputs": { "nixpkgs": [ @@ -68,6 +88,7 @@ }, "root": { "inputs": { + "disko": "disko", "nix-index-database": "nix-index-database", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs", diff --git a/flake.nix b/flake.nix index 59cde89..348ff2a 100644 --- a/flake.nix +++ b/flake.nix @@ -10,6 +10,9 @@ nix-index-database.inputs.nixpkgs.follows = "nixpkgs"; nixos-hardware.url = "github:NixOS/nixos-hardware/master"; + + disko.url = "github:nix-community/disko"; + disko.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = inputs@{ @@ -21,15 +24,17 @@ let lib = nixpkgs.lib; in { - nixosConfigurations = lib.genAttrs [ "imladris" "orion" ] (hostName: lib.nixosSystem { + nixosConfigurations = lib.genAttrs [ "imladris" "orion" "rift" ] (hostName: lib.nixosSystem { system = "x86_64-linux"; specialArgs = { inherit inputs; }; modules = [ { networking.hostName = hostName; } + inputs.disko.nixosModules.disko ./hw/${hostName} ./configuration.nix nix-index-database.nixosModules.nix-index { programs.nix-index-database.comma.enable = true; } + { system.configurationRevision = self.rev or "dirty"; } ]; }); }; diff --git a/flash.sh b/flash.sh new file mode 100755 index 0000000..57b1e29 --- /dev/null +++ b/flash.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +set -e + +if [[ ! $# -eq 2 ]] +then + echo "$0: " + exit +fi + +NIXOS_INSTALLER_VERSION=25.05 + +CONFIG=$1 +HOST=$2 + +wget -c https://github.com/nix-community/nixos-images/releases/download/nixos-${NIXOS_INSTALLER_VERSION}/nixos-kexec-installer-noninteractive-x86_64-linux.tar.gz + +nix run github:nix-community/nixos-anywhere -- \ + --flake .#${CONFIG} \ + --generate-hardware-config nixos-generate-config ./hw/${CONFIG}/hardware-configuration.nix \ + --kexec ./nixos-kexec-installer-noninteractive-x86_64-linux.tar.gz \ + --target-host ${HOST} diff --git a/hw/rift/default.nix b/hw/rift/default.nix new file mode 100644 index 0000000..25237e8 --- /dev/null +++ b/hw/rift/default.nix @@ -0,0 +1,11 @@ +{ inputs, ... }: + +{ + imports = [ + ./hardware-configuration.nix + ./disk-config.nix + ]; + + config = { + }; +} diff --git a/hw/rift/disk-config.nix b/hw/rift/disk-config.nix new file mode 100644 index 0000000..714d650 --- /dev/null +++ b/hw/rift/disk-config.nix @@ -0,0 +1,67 @@ +## (rift) disko config +## main disk is a 1T NVMe drive + +{ lib, ... }: + +{ + disko.devices = { + disk = { + main = { + type = "disk"; + device = "/dev/nvme0n1"; + content = { + type = "gpt"; + partitions = { + ESP = { + size = "500M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0077" ]; + }; + }; + luks = { + size = "100%"; + content = { + type = "luks"; + name = "crypted"; + extraOpenArgs = [ ]; + settings = { + # if you want to use the key for interactive login be sure there is no trailing newline + # for example use `echo -n "password" > /tmp/secret.key` + keyFile = "/dev/mmcblk0p1"; + allowDiscards = true; + }; + additionalKeyFiles = [ ]; + content = { + type = "lvm_pv"; + vg = "pool"; + }; + }; + }; + }; + }; + }; + }; + lvm_vg = { + pool = { + type = "lvm_vg"; + lvs = { + root = { + size = "100%"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + mountOptions = [ + "defaults" + ]; + }; + }; + }; + }; + }; + }; +} diff --git a/hw/rift/hardware-configuration.nix b/hw/rift/hardware-configuration.nix new file mode 100644 index 0000000..4a98e33 --- /dev/null +++ b/hw/rift/hardware-configuration.nix @@ -0,0 +1,26 @@ +# 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, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + # 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.enp89s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlo1.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +}