From 9a43edcd92f104e38c0e2d53aa136ac6c330e3d3 Mon Sep 17 00:00:00 2001 From: twoneis Date: Sun, 12 Nov 2023 16:59:43 +0100 Subject: [PATCH] finished (?) system part of config --- devices/desktop/default.nix | 37 ++++++++++++ devices/desktop/hardware-config.nix | 40 +++++++++++++ devices/surface/default.nix | 18 ++++++ devices/surface/hardware-config.nix | 40 +++++++++++++ flake.nix | 39 +++++++++++++ modules/home/default.nix | 5 ++ modules/system/default.nix | 90 +++++++++++++++++++++++++++++ modules/system/packages.nix | 14 +++++ 8 files changed, 283 insertions(+) create mode 100644 devices/desktop/default.nix create mode 100644 devices/desktop/hardware-config.nix create mode 100644 devices/surface/default.nix create mode 100644 devices/surface/hardware-config.nix create mode 100644 modules/home/default.nix create mode 100644 modules/system/default.nix create mode 100644 modules/system/packages.nix diff --git a/devices/desktop/default.nix b/devices/desktop/default.nix new file mode 100644 index 0000000..ac77b11 --- /dev/null +++ b/devices/desktop/default.nix @@ -0,0 +1,37 @@ +{ config, pkgs }: { + imports = [ + ../../modules/system + + ./hardware-config.nix + ]; + + networking.hostName = "desktop"; + + # Enable OpenGL + hardware.opengl = { + enable = true; + driSupport = true; + driSupport32Bit = true; + }; + + # Load nvidia driver + services.xserver.videoDrivers = ["nvidia"]; + + hardware.nvidia = { + modesetting.enable = true; + powerManagement.enable = false; + powerManagement.finegrained = false; + open = false; + nvidiaSettings = true; + package = config.boot.kernelPackages.nvidiaPackages.stable; + }; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "23.05"; # Did you read the comment? + +} diff --git a/devices/desktop/hardware-config.nix b/devices/desktop/hardware-config.nix new file mode 100644 index 0000000..87e44a6 --- /dev/null +++ b/devices/desktop/hardware-config.nix @@ -0,0 +1,40 @@ +# 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 = [ "nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/95b15244-c97c-42a5-9be1-ed5df6872dcb"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/BF87-B3DE"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/b6445ced-1cc2-461f-a81f-6e8409c10f48"; } + ]; + + # 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.enp7s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp6s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/devices/surface/default.nix b/devices/surface/default.nix new file mode 100644 index 0000000..97162f2 --- /dev/null +++ b/devices/surface/default.nix @@ -0,0 +1,18 @@ +{ config, pkgs }: { + imports = [ + ../../modules/system + + ./hardware-config.nix + ]; + + networking.hostName = "surface"; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "23.05"; # Did you read the comment? + +} diff --git a/devices/surface/hardware-config.nix b/devices/surface/hardware-config.nix new file mode 100644 index 0000000..e03e407 --- /dev/null +++ b/devices/surface/hardware-config.nix @@ -0,0 +1,40 @@ +# 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" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/4ecc3b27-016f-4416-a819-bd0998fc993f"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/0721-3632"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/b35abec3-ff20-4b3b-b953-e36f2df719cb"; } + ]; + + # 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.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; +} diff --git a/flake.nix b/flake.nix index ab90a3f..5ac2b94 100644 --- a/flake.nix +++ b/flake.nix @@ -11,4 +11,43 @@ inputs.nixpkgs.follows = "nixpkgs"; }; }; + + outputs = { nixpkgs, home-manager }: + let + x86 = "x86_64-linux"; + in { + nixosConfigurations = { + desktop = nixpkgs.lib.nixosSystem { + specialArgs = { inherit x86; }; + + modules = [ + ./devices/desktop + + home-manager.nixosModules.home-manager { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users.twoneis = import ./home; + }; + } + ]; + }; + + surface = nixpkgs.lib.nixosSystem { + specialArgs = { inherit x86; }; + + modules = [ + ./devices/surface + + home-manager.nixosModules.home-manager { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users.twoneis = import ./home; + }; + } + ]; + }; + }; + }; } diff --git a/modules/home/default.nix b/modules/home/default.nix new file mode 100644 index 0000000..8c9e300 --- /dev/null +++ b/modules/home/default.nix @@ -0,0 +1,5 @@ +{ config, pkgs }: { + imports = [ + + ]; +} diff --git a/modules/system/default.nix b/modules/system/default.nix new file mode 100644 index 0000000..59b360e --- /dev/null +++ b/modules/system/default.nix @@ -0,0 +1,90 @@ +# 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’). + +{ pkgs }: { + + imports = + [ # Include the results of the hardware scan. + ./packages.nix + ]; + + # Enable nix flakes + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + # Disable documentation + documentation.nixos.enable = false; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + # Select kernel version + boot.kernelPackages = pkgs.linuxPackages_zen; + + # Enable networking + networking.networkmanager.enable = true; + + # Set your time zone. + time.timeZone = "Europe/Amsterdam"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "en_US.UTF-8"; + LC_IDENTIFICATION = "en_US.UTF-8"; + LC_MEASUREMENT = "en_US.UTF-8"; + LC_MONETARY = "en_US.UTF-8"; + LC_NAME = "en_US.UTF-8"; + LC_NUMERIC = "en_US.UTF-8"; + LC_PAPER = "en_US.UTF-8"; + LC_TELEPHONE = "en_US.UTF-8"; + LC_TIME = "en_US.UTF-8"; + }; + + # Enable the X11 windowing system. + services.xserver.enable = true; + + # Remove XTerm + services.xserver.excludePackages = [ pkgs.xterm ]; + + # Enable the GNOME Desktop Environment. + services.xserver.displayManager.gdm.enable = true; + services.xserver.desktopManager.gnome.enable = true; + # Don't pull unnecessary packages + services.gnome.core-utilities.enable = false; + environment.gnome.excludePackages = [ pkgs.gnome-tour ]; + + # Configure keymap in X11 + services.xserver = { + layout = "us"; + xkbVariant = ""; + }; + + # Enable CUPS to print documents. + services.printing.enable = false; + + # Enable sound with pipewire. + sound.enable = true; + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + #jack.enable = true; + }; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.twoneis = { + isNormalUser = true; + description = "twoneis"; + extraGroups = [ "networkmanager" "wheel" ]; + packages = import ./packages/user-core-packages.nix pkgs ++ import ./packages/user-game-packages.nix pkgs; + }; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; +} diff --git a/modules/system/packages.nix b/modules/system/packages.nix new file mode 100644 index 0000000..f749d13 --- /dev/null +++ b/modules/system/packages.nix @@ -0,0 +1,14 @@ +{ pkgs }: { + environment.systemPackages = with pkgs; [ + alacritty + git + gh + man-pages + man-pages-posix + bottom + firefox + gnome.nautilus + vlc + image-roll + ]; +}