From 0dab2619f25de379e3f2d572662f61d4789c5e15 Mon Sep 17 00:00:00 2001 From: Riley Apeldoorn Date: Sat, 17 Jun 2023 10:15:20 +0200 Subject: [PATCH] Import generated config because the network is broken otherwise --- flake.lock | 16 +++++++ flake.nix | 6 ++- system/lime/configuration.nix | 33 ++++++++++++++ system/lime/core.nix | 56 +++--------------------- system/lime/hardware-configuration.nix | 60 ++++++++++++++++++++++++++ 5 files changed, 118 insertions(+), 53 deletions(-) create mode 100644 system/lime/configuration.nix create mode 100644 system/lime/hardware-configuration.nix diff --git a/flake.lock b/flake.lock index de1330e..06738a4 100644 --- a/flake.lock +++ b/flake.lock @@ -112,6 +112,21 @@ "type": "github" } }, + "nixos-hardware": { + "locked": { + "lastModified": 1686838567, + "narHash": "sha256-aqKCUD126dRlVSKV6vWuDCitfjFrZlkwNuvj5LtjRRU=", + "owner": "NixOS", + "repo": "nixos-hardware", + "rev": "429f232fe1dc398c5afea19a51aad6931ee0fb89", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixos-hardware", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1677676435, @@ -203,6 +218,7 @@ "inputs": { "agenix": "agenix", "home-manager": "home-manager_2", + "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs_3", "pwnix": "pwnix" } diff --git a/flake.nix b/flake.nix index 64db92e..117189d 100644 --- a/flake.nix +++ b/flake.nix @@ -8,9 +8,10 @@ url = git+https://im.badat.dev/bad/pwnix.git; }; agenix.url = github:ryantm/agenix; + nixos-hardware.url = github:NixOS/nixos-hardware; }; - outputs = args@{ home-manager, nixpkgs, agenix, ... }: with nixpkgs; { + outputs = args@{ home-manager, nixpkgs, agenix, nixos-hardware, ... }: with nixpkgs; { # Configurations for NixOS machines. nixosConfigurations = @@ -47,6 +48,7 @@ modules = [ (mkUserConfig ./system/lime) agenix.nixosModules.default + nixos-hardware.nixosModules.lenovo-thinkpad-x390 ./system/lime/core.nix ./shared/core ./shared/secrets.nix @@ -73,4 +75,4 @@ }; -} \ No newline at end of file +} diff --git a/system/lime/configuration.nix b/system/lime/configuration.nix new file mode 100644 index 0000000..eab4ead --- /dev/null +++ b/system/lime/configuration.nix @@ -0,0 +1,33 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). + +{ config, pkgs, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + # Use the systemd-boot EFI boot loader. + services.xserver.enable = true; + services.xserver.desktopManager.lxqt.enable = true; + services.xserver.displayManager.gdm.enable = true; + programs.firefox.enable = true; + + networking.hostName = "lime"; + networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. + + # Set your time zone. + time.timeZone = "Europe/Amsterdam"; + + + # Enable touchpad support (enabled default in most desktopManager). + services.xserver.libinput.enable = true; + + system.stateVersion = "22.11"; # Did you read the comment? + + programs.git.enable = true; + nix.settings.experimental-features = ["nix-command" "flakes"]; +} diff --git a/system/lime/core.nix b/system/lime/core.nix index 94d0d1e..2e3155e 100644 --- a/system/lime/core.nix +++ b/system/lime/core.nix @@ -1,59 +1,13 @@ -{ lib, ... }: { +{ lib, modulesPath, ... }: { + + imports = [./configuration.nix]; custom = { gui.enable = true; backups.enable = true; }; - system.stateVersion = "22.11"; - home-manager.users.riley.home.stateVersion = "22.11"; - - networking = { - hostName = "lime"; - interfaces."wlp0s20f3".useDHCP = true; - interfaces."enp0s31f6".useDHCP = true; - }; - - boot = { - initrd.availableKernelModules = [ - "nvme" - "xhci_pci" - "usbhid" - "usb_storage" - "sd_mod" - "sdhci_pci" - ]; - kernelModules = [ "kvm-intel" ]; - loader.grub = { - enable = true; - efiSupport = true; - device = "nodev"; - }; - loader.efi.canTouchEfiVariables = true; - initrd.luks.devices.root.device = "/dev/disk/by-uuid/bd5edcc6-35b7-4829-901f-8593c16f0324"; - resumeDevice = "/dev/disk/by-label/NIXOS-ROOT"; - kernelParams = [ - # btrfs inspect-internal map-swapfile -r /swap/swapfile - "resume_offset=2630912" - ]; - }; - - fileSystems."/" = { - device = "/dev/disk/by-label/NIXOS-ROOT"; - fsType = "btrfs"; - }; - - fileSystems."/boot" = { - device = "/dev/disk/by-uuid/2745-1284"; - fsType = "vfat"; - }; - - swapDevices = [{ - device = "/swap/swapfile"; - size = 16 * 1024; - }]; - - nixpkgs.hostPlatform = "x86_64-linux"; - powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + home-manager.users."riley".home.stateVersion = "22.11"; } + diff --git a/system/lime/hardware-configuration.nix b/system/lime/hardware-configuration.nix new file mode 100644 index 0000000..57662fb --- /dev/null +++ b/system/lime/hardware-configuration.nix @@ -0,0 +1,60 @@ +# 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" "nvme" "usb_storage" "sd_mod" "sdhci_pci" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + boot.loader.grub = { +efiSupport = true; +device = "nodev"; + enable = true; +}; + boot.loader.efi.canTouchEfiVariables = true; + + fileSystems."/" = + { device = "/dev/disk/by-label/NIXOS-ROOT"; + fsType = "btrfs"; + }; + + boot.initrd.luks.devices."root".device = "/dev/disk/by-uuid/bd5edcc6-35b7-4829-901f-8593c16f0324"; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/2745-1284"; + fsType = "vfat"; + }; + + swapDevices = [ + { + device = "/swap/swapfile"; + size = 16*1024; + } + ]; + +# Hibernation +# https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Hibernation_into_swap_file +boot.resumeDevice = "/dev/disk/by-label/NIXOS-ROOT"; +boot.kernelParams = [ + # btrfs inspect-internal map-swapfile -r /swap/swapfile + "resume_offset=2630912" +]; + # 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.enp0s31f6.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; +}