Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@
];
};

# Hostname: weller-bootstrap (Initial install target)
weller-bootstrap = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit inputs; };
modules = [
./hosts/weller/hardware.nix
./hosts/weller/disk-config.nix
./modules/bootstrap.nix
inputs.disko.nixosModules.disko
];
};

# Hostname: weller (dual-boot Windows 11 + NixOS workstation)
weller = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
Expand Down
92 changes: 1 addition & 91 deletions hosts/weller/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
config,
lib,
pkgs,
modulesPath,
inputs,
Expand All @@ -9,7 +8,7 @@

{
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
./hardware.nix
../../modules/common/system.nix
../../modules/common/users.nix
../../modules/common/workstation.nix
Expand All @@ -19,95 +18,6 @@
cosmo.user.default = "patrick";
cosmo.user.email = "big.pat@gmail.com";

# ---------------------------------------------------------------------------
# Hardware (normally in hardware-configuration.nix, but disko handles mounts)
# ---------------------------------------------------------------------------
boot.initrd.availableKernelModules = [
"nvme"
"xhci_pci"
"ahci"
"usbhid"
"sd_mod"
];
boot.kernelModules = [ "kvm-amd" ];
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";

# ---------------------------------------------------------------------------
# Bootloader - systemd-boot
# ---------------------------------------------------------------------------
# Windows is on Disk 0, NixOS on Disk 1 - use UEFI boot menu (F11/F12) to switch
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.initrd.systemd.enable = true;

# Seagate FireCuda 510 firmware crashes with APST power saving (#263)
boot.kernelParams = [
"nvme_core.default_ps_max_latency_us=0"
"btusb.enable_autosuspend=n"
];

# ---------------------------------------------------------------------------
# Filesystem - Btrfs with LUKS encryption (managed by disko)
# ---------------------------------------------------------------------------
boot.supportedFilesystems = [
"btrfs"
"ntfs"
];

# ---------------------------------------------------------------------------
# Networking
# ---------------------------------------------------------------------------
networking.hostName = "weller";
networking.networkmanager.enable = true;

# ---------------------------------------------------------------------------
# Hardware - NVIDIA RTX 4090
# ---------------------------------------------------------------------------
nixpkgs.config.allowUnfree = true;

hardware.graphics.enable = true;

services.xserver.videoDrivers = [ "nvidia" ];
hardware.nvidia = {
modesetting.enable = true;
powerManagement.enable = false;
powerManagement.finegrained = false;
open = false; # Use proprietary driver for best compatibility
nvidiaSettings = true;
package = config.boot.kernelPackages.nvidiaPackages.stable;
};

# ---------------------------------------------------------------------------
# Bluetooth – optimised for Kinesis Advantage 360 Pro (ZMK / BLE)
# ---------------------------------------------------------------------------
hardware.bluetooth = {
enable = true;
powerOnBoot = true;
settings = {
General = {
# Keep adapter in page-scan mode for instant reconnects
FastConnectable = "true";
# ZMK uses "Just Works" pairing – always allow re-pairing
JustWorksRepairing = "always";
# Better LE handling & battery reporting
Experimental = "true";
};
LE = {
# Tighter polling interval (7.5–11.25 ms) for lower input latency
MinConnectionInterval = 6;
MaxConnectionInterval = 9;
ConnectionLatency = 0;
};
Policy = {
AutoEnable = "true";
ReconnectAttempts = 7;
ReconnectIntervals = "1,2,4,8,16,32,64";
};
};
};
environment.systemPackages = with pkgs; [ bluetuith ];

# ---------------------------------------------------------------------------
# Remote Access
# ---------------------------------------------------------------------------
Expand Down
103 changes: 103 additions & 0 deletions hosts/weller/hardware.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
config,
lib,
pkgs,
modulesPath,
...
}:

{
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];

# ---------------------------------------------------------------------------
# Hardware (normally in hardware-configuration.nix, but disko handles mounts)
# ---------------------------------------------------------------------------
boot.initrd.availableKernelModules = [
"nvme"
"xhci_pci"
"ahci"
"usbhid"
"sd_mod"
];
boot.kernelModules = [ "kvm-amd" ];
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";

# ---------------------------------------------------------------------------
# Bootloader - systemd-boot
# ---------------------------------------------------------------------------
# Windows is on Disk 0, NixOS on Disk 1 - use UEFI boot menu (F11/F12) to switch
boot.loader.systemd-boot.enable = true;
boot.loader.systemd-boot.memtest86.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.initrd.systemd.enable = true;

# Seagate FireCuda 510 firmware crashes with APST power saving (#263)
boot.kernelParams = [
"nvme_core.default_ps_max_latency_us=0"
"btusb.enable_autosuspend=n"
];

# ---------------------------------------------------------------------------
# Filesystem - Btrfs with LUKS encryption (managed by disko)
# ---------------------------------------------------------------------------
boot.supportedFilesystems = [
"btrfs"
"ntfs"
];

# ---------------------------------------------------------------------------
# Networking
# ---------------------------------------------------------------------------
networking.hostName = "weller";
networking.networkmanager.enable = true;

# ---------------------------------------------------------------------------
# Hardware - NVIDIA RTX 4090
# ---------------------------------------------------------------------------
nixpkgs.config.allowUnfree = true;

hardware.graphics.enable = true;

services.xserver.videoDrivers = [ "nvidia" ];
hardware.nvidia = {
modesetting.enable = true;
powerManagement.enable = false;
powerManagement.finegrained = false;
open = false; # Use proprietary driver for best compatibility
nvidiaSettings = true;
package = config.boot.kernelPackages.nvidiaPackages.stable;
};

# ---------------------------------------------------------------------------
# Bluetooth – optimised for Kinesis Advantage 360 Pro (ZMK / BLE)
# ---------------------------------------------------------------------------
hardware.bluetooth = {
enable = true;
powerOnBoot = true;
settings = {
General = {
# Keep adapter in page-scan mode for instant reconnects
FastConnectable = "true";
# ZMK uses "Just Works" pairing – always allow re-pairing
JustWorksRepairing = "always";
# Better LE handling & battery reporting
Experimental = "true";
};
LE = {
# Tighter polling interval (7.5–11.25 ms) for lower input latency
MinConnectionInterval = 6;
MaxConnectionInterval = 9;
ConnectionLatency = 0;
};
Policy = {
AutoEnable = "true";
ReconnectAttempts = 7;
ReconnectIntervals = "1,2,4,8,16,32,64";
};
};
};
environment.systemPackages = with pkgs; [ bluetuith ];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The bluetuith package is a user-space application. While related to Bluetooth, defining environment.systemPackages here mixes hardware configuration with software installation. For better separation of concerns, it's recommended to manage host-specific packages in a different module, like hosts/weller/default.nix. This keeps hardware.nix focused purely on hardware-level settings. Please consider moving this line to hosts/weller/default.nix.

}
51 changes: 51 additions & 0 deletions modules/bootstrap.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
config,
pkgs,
lib,
...
}:

let
keys = import ../secrets/keys.nix;
in
{
imports = [
./common/system.nix
];

# Define the default user options here since we are importing system.nix
cosmo.user.default = "patrick";
cosmo.user.email = "big.pat@gmail.com";

# Enable SSH
services.openssh = {
enable = true;
settings = {
PermitRootLogin = "yes";
PasswordAuthentication = true;
Comment on lines +24 to +25

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

Enabling password authentication and permitting root login over SSH is highly insecure, especially when combined with a hardcoded initial password. Since SSH keys are already configured, password authentication should be disabled to prevent unauthorized access during the bootstrap phase. Permitting root login is also unnecessary when a user with sudo access is available, and it's better to rely solely on SSH key authentication.

      PermitRootLogin = "no";
  PasswordAuthentication = false;

};
};

# Mutable users for bootstrap
users.mutableUsers = true;

users.users.root.openssh.authorizedKeys.keys = keys.users;

users.users.${config.cosmo.user.default} = {
isNormalUser = true;
uid = 1000;
extraGroups = [
"wheel"
"networkmanager"
"video"
];
initialPassword = "nixos";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

Hardcoding an initial password (nixos) is a significant security risk. If password authentication is enabled, an attacker could easily gain access to this user account. Since security.sudo.wheelNeedsPassword is false, this could lead to immediate root access. This hardcoded password should be removed, relying instead on SSH key authentication for initial access. If a password is required for local console access, consider using hashedPassword with a pre-computed hash.

openssh.authorizedKeys.keys = keys.users;
};

# Make it easy to assume root during bootstrap
security.sudo.wheelNeedsPassword = false;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-medium medium

Allowing members of the 'wheel' group to use sudo without a password reduces the security of the system. In combination with the hardcoded password and enabled SSH password authentication, this allows an attacker to gain root access immediately upon logging in as the default user. It is safer to require a password for sudo even during the bootstrap phase.

  security.sudo.wheelNeedsPassword = true;


# Ensure compatibility
system.stateVersion = "25.11";
}
6 changes: 6 additions & 0 deletions modules/common/system.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@

# Version Control
git

# Hardware Diagnostics
smartmontools
nvme-cli
lm_sensors
memtester
];

# Enable Flakes and new command line tools
Expand Down