From ecc269ae373420ca0d9caac42a5d8f708f431f92 Mon Sep 17 00:00:00 2001
From: Julian Mutter <julian.mutter@comumail.de>
Date: Sat, 15 Jun 2024 08:27:10 +0200
Subject: [PATCH] Fix config problems mainly with pianonix

---
 systems/x86_64-linux/aspi/default.nix         |  2 +-
 systems/x86_64-linux/nix-builder/default.nix  |  2 +-
 systems/x86_64-linux/pianonix/default.nix     |  6 +-
 .../pianonix/hardware-configuration.nix       | 80 +++++++++++++++++++
 4 files changed, 86 insertions(+), 4 deletions(-)
 create mode 100644 systems/x86_64-linux/pianonix/hardware-configuration.nix

diff --git a/systems/x86_64-linux/aspi/default.nix b/systems/x86_64-linux/aspi/default.nix
index 11f2921..b465a58 100644
--- a/systems/x86_64-linux/aspi/default.nix
+++ b/systems/x86_64-linux/aspi/default.nix
@@ -58,7 +58,7 @@
   ];
 
   networking.hostName = "aspi";
-  networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
+  # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
   networking.networkmanager.enable = true;
 
   # Set your time zone.
diff --git a/systems/x86_64-linux/nix-builder/default.nix b/systems/x86_64-linux/nix-builder/default.nix
index f3023ea..d409ce7 100644
--- a/systems/x86_64-linux/nix-builder/default.nix
+++ b/systems/x86_64-linux/nix-builder/default.nix
@@ -110,7 +110,7 @@
     acceleration = "cuda";
   };
 
-  security.pam.sshAgentAuth = true; # enable sudo logins via ssh
+  security.pam.sshAgentAuth.enable = true; # enable sudo logins via ssh
 
   # Open ports in the firewall.
   # networking.firewall.allowedTCPPorts = [ ... ];
diff --git a/systems/x86_64-linux/pianonix/default.nix b/systems/x86_64-linux/pianonix/default.nix
index fe298a5..29a6a85 100644
--- a/systems/x86_64-linux/pianonix/default.nix
+++ b/systems/x86_64-linux/pianonix/default.nix
@@ -20,7 +20,7 @@
 
   networking.networkmanager.enable = true;
   networking.hostName = "pianonix"; # Define your hostname.
-  networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
+  # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
 
   # Set your time zone.
   time.timeZone = "Europe/Berlin";
@@ -95,7 +95,6 @@
     isNormalUser = true;
     description = "Julian";
     uid = 1000;
-    gid = 1000;
     group = "julian";
     extraGroups = [
       "networkmanager"
@@ -104,6 +103,9 @@
     ];
     packages = with pkgs; [ ]; # Using home-manager instead
   };
+  users.groups.julian = {
+    gid = 1000;
+  };
 
   programs.nix-ld.enable = true;
 
diff --git a/systems/x86_64-linux/pianonix/hardware-configuration.nix b/systems/x86_64-linux/pianonix/hardware-configuration.nix
new file mode 100644
index 0000000..8cd9409
--- /dev/null
+++ b/systems/x86_64-linux/pianonix/hardware-configuration.nix
@@ -0,0 +1,80 @@
+{
+  config,
+  lib,
+  pkgs,
+  modulesPath,
+  ...
+}:
+
+{
+
+  # TODO: This has to adapted yet !!!
+
+  boot.initrd.availableKernelModules = [
+    "vmd"
+    "xhci_pci"
+    "ahci"
+    "nvme"
+    "usb_storage"
+    "usbhid"
+    "sd_mod"
+  ];
+  boot.initrd.kernelModules = [ "dm-snapshot" ];
+  boot.kernelModules = [ "kvm-intel" ];
+  boot.extraModulePackages = [ ];
+
+  boot.initrd.luks.devices = {
+    root = {
+      device = "/dev/disk/by-uuid/a4dc9a2c-725b-4252-8fbb-093a271c31ba";
+      preLVM = true;
+      allowDiscards = true;
+    };
+  };
+
+  fileSystems."/" = {
+    device = "/dev/disk/by-uuid/bbc45be3-75f5-40c5-8427-2a425de8422c";
+    fsType = "btrfs";
+    options = [
+      "subvol=root"
+      "compress=zstd"
+    ];
+  };
+
+  fileSystems."/home" = {
+    device = "/dev/disk/by-uuid/bbc45be3-75f5-40c5-8427-2a425de8422c";
+    fsType = "btrfs";
+    options = [
+      "subvol=home"
+      "compress=zstd"
+    ];
+  };
+
+  fileSystems."/nix" = {
+    device = "/dev/disk/by-uuid/bbc45be3-75f5-40c5-8427-2a425de8422c";
+    fsType = "btrfs";
+    options = [
+      "subvol=nix"
+      "compress=zstd"
+      "noatime"
+    ];
+  };
+
+  fileSystems."/boot" = {
+    device = "/dev/disk/by-uuid/7040-F37C";
+    fsType = "vfat";
+  };
+
+  swapDevices = [ { device = "/dev/disk/by-uuid/26140b4a-0579-406d-a484-35aa31b32e80"; } ];
+
+  # 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.<interface>.useDHCP`.
+  networking.useDHCP = lib.mkDefault true;
+  # networking.interfaces.enp1s0.useDHCP = lib.mkDefault true;
+  # networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true;
+
+  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
+  powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
+  hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
+}