From 51fdbb4a8761ac3c1f5fe627b2a87e05dfb74382 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Sat, 2 Sep 2023 15:51:02 +0200 Subject: [PATCH] Configuration is more flexible Add new host must be easier --- flake.nix | 2 +- hosts/mrmeeseeks/configuration.nix | 74 ------------------- hosts/mrmeeseeks/hardware-configuration.nix | 8 +- nixos/default.nix | 60 +++++++++++++++ .../includes/desktop}/pipewire.nix | 4 +- nixos/includes/desktop/swaylock.nix | 3 + .../includes/desktop}/xdg-portal.nix | 0 .../nixos => nixos/includes/gaming}/steam.nix | 0 nixos/includes/hardware/bootloader.nix | 6 ++ .../nixos => nixos/includes/system}/doas.nix | 0 {common => nixos/includes/system}/flakes.nix | 0 {common => nixos/includes/system}/locales.nix | 0 nixos/includes/system/lvm.nix | 10 +++ .../includes/system}/neovim.nix | 0 nixos/includes/system/udisks2.nix | 3 + {common => nixos/includes/system}/user.nix | 0 16 files changed, 91 insertions(+), 79 deletions(-) delete mode 100644 hosts/mrmeeseeks/configuration.nix create mode 100644 nixos/default.nix rename {modules/nixos => nixos/includes/desktop}/pipewire.nix (77%) create mode 100644 nixos/includes/desktop/swaylock.nix rename {modules/nixos => nixos/includes/desktop}/xdg-portal.nix (100%) rename {modules/nixos => nixos/includes/gaming}/steam.nix (100%) create mode 100644 nixos/includes/hardware/bootloader.nix rename {modules/nixos => nixos/includes/system}/doas.nix (100%) rename {common => nixos/includes/system}/flakes.nix (100%) rename {common => nixos/includes/system}/locales.nix (100%) create mode 100644 nixos/includes/system/lvm.nix rename {modules/nixos => nixos/includes/system}/neovim.nix (100%) create mode 100644 nixos/includes/system/udisks2.nix rename {common => nixos/includes/system}/user.nix (100%) diff --git a/flake.nix b/flake.nix index 5d87f1f..3948651 100644 --- a/flake.nix +++ b/flake.nix @@ -19,7 +19,7 @@ in rec { hostname = "mrmeeseeks"; }; modules = [ - ./hosts/mrmeeseeks/configuration.nix + ./nixos/default.nix home-manager.nixosModule ]; }; diff --git a/hosts/mrmeeseeks/configuration.nix b/hosts/mrmeeseeks/configuration.nix deleted file mode 100644 index 25a3db1..0000000 --- a/hosts/mrmeeseeks/configuration.nix +++ /dev/null @@ -1,74 +0,0 @@ -{ config, pkgs, lib, stateVersion, hostname, ... }: - -{ - imports = - [ # Include the results of the hardware scan. - ./hardware-configuration.nix - ../../common/locales.nix - ../../common/flakes.nix - ../../common/user.nix - ../../modules/nixos/pipewire.nix - ../../modules/nixos/steam.nix - ../../modules/nixos/xdg-portal.nix - ../../modules/nixos/doas.nix - ]; - - nixpkgs.config.allowUnfree = true; - - # Use the systemd-boot EFI boot loader. - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - - boot.kernelPackages = pkgs.linuxPackages_latest; - #CPU - hardware.cpu.amd.updateMicrocode = true; - # GPU - hardware.opengl.driSupport = true; - hardware.opengl.driSupport32Bit = true; - - # Bluetooth - hardware.bluetooth.enable = true; - hardware.xpadneo.enable = true; - networking.hostName = hostname; - - console = { - earlySetup = true; - font = "${pkgs.terminus_font}/share/consolefonts/ter-132n.psf.gz"; - packages = with pkgs; [terminus_font]; - # keyMap = "us"; - useXkbConfig = true; # use xkbOptions in tty. - }; - - security.rtkit.enable = true; - security.pam.services.swaylock = {}; - services.udisks2.enable = true; - - environment.systemPackages = with pkgs; [ - git - zsh - lvm2_dmeventd - ]; - - services.lvm.enable = true; - services.lvm.dmeventd.enable = true; - - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - users.ephase = { - home.stateVersion = stateVersion; - programs.home-manager.enable = true; - imports = [ - ../../modules/home/desktop - ../../modules/home/webcord.nix - ../../modules/home/cli - ../../modules/home/firefox - ../../modules/home/foot.nix - ../../modules/home/lutris.nix - ../../modules/home/zathura.nix - ]; - }; - }; - - system.stateVersion = "23.05"; -} diff --git a/hosts/mrmeeseeks/hardware-configuration.nix b/hosts/mrmeeseeks/hardware-configuration.nix index 3105f97..ac24d06 100644 --- a/hosts/mrmeeseeks/hardware-configuration.nix +++ b/hosts/mrmeeseeks/hardware-configuration.nix @@ -61,7 +61,11 @@ # networking.interfaces.enp34s0.useDHCP = lib.mkDefault true; # networking.interfaces.wlp37s0.useDHCP = lib.mkDefault true; - services.lvm.boot.thin.enable = true; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + + hardware.cpu.amd.updateMicrocode = true; + hardware.opengl.driSupport = true; + hardware.opengl.driSupport32Bit = true; + hardware.bluetooth.enable = true; + hardware.xpadneo.enable = true; } diff --git a/nixos/default.nix b/nixos/default.nix new file mode 100644 index 0000000..5d37b4c --- /dev/null +++ b/nixos/default.nix @@ -0,0 +1,60 @@ +{ config, pkgs, lib, stateVersion, hostname, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ../hosts/${hostname}/hardware-configuration.nix + ./includes/hardware/bootloader.nix + ./includes/system/locales.nix + ./includes/system/flakes.nix + ./includes/system/user.nix + ./includes/system/udisks2.nix + ./includes/system/lvm.nix + ./includes/system/doas.nix + ./includes/system/neovim.nix + ./includes/desktop/swaylock.nix + ./includes/desktop/pipewire.nix + ./includes/desktop/xdg-portal.nix + ./includes/gaming/steam.nix + ]; + + nixpkgs.config.allowUnfree = true; + + + boot.kernelPackages = pkgs.linuxPackages_latest; + networking.hostName = hostname; + + console = { + earlySetup = true; + font = "${pkgs.terminus_font}/share/consolefonts/ter-132n.psf.gz"; + packages = with pkgs; [terminus_font]; + # keyMap = "us"; + useXkbConfig = true; # use xkbOptions in tty. + }; + + + environment.systemPackages = with pkgs; [ + git + zsh + ]; + + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users.ephase = { + home.stateVersion = stateVersion; + programs.home-manager.enable = true; + imports = [ + ../modules/home/desktop + ../modules/home/webcord.nix + ../modules/home/cli + ../modules/home/firefox + ../modules/home/foot.nix + ../modules/home/lutris.nix + ../modules/home/zathura.nix + ]; + }; + }; + + system.stateVersion = "23.05"; +} diff --git a/modules/nixos/pipewire.nix b/nixos/includes/desktop/pipewire.nix similarity index 77% rename from modules/nixos/pipewire.nix rename to nixos/includes/desktop/pipewire.nix index 2b2312d..19c9744 100644 --- a/modules/nixos/pipewire.nix +++ b/nixos/includes/desktop/pipewire.nix @@ -1,5 +1,5 @@ -{ config, pkgs, ...}: -{ +_: { + security.rtkit.enable = true; services.pipewire = { enable = true; alsa.enable = true; diff --git a/nixos/includes/desktop/swaylock.nix b/nixos/includes/desktop/swaylock.nix new file mode 100644 index 0000000..bc48c63 --- /dev/null +++ b/nixos/includes/desktop/swaylock.nix @@ -0,0 +1,3 @@ +_: { + security.pam.services.swaylock = {}; +} diff --git a/modules/nixos/xdg-portal.nix b/nixos/includes/desktop/xdg-portal.nix similarity index 100% rename from modules/nixos/xdg-portal.nix rename to nixos/includes/desktop/xdg-portal.nix diff --git a/modules/nixos/steam.nix b/nixos/includes/gaming/steam.nix similarity index 100% rename from modules/nixos/steam.nix rename to nixos/includes/gaming/steam.nix diff --git a/nixos/includes/hardware/bootloader.nix b/nixos/includes/hardware/bootloader.nix new file mode 100644 index 0000000..6259fd5 --- /dev/null +++ b/nixos/includes/hardware/bootloader.nix @@ -0,0 +1,6 @@ +_: { + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.systemd-boot.configurationLimit = 10; + boot.loader.efi.canTouchEfiVariables = true; +} diff --git a/modules/nixos/doas.nix b/nixos/includes/system/doas.nix similarity index 100% rename from modules/nixos/doas.nix rename to nixos/includes/system/doas.nix diff --git a/common/flakes.nix b/nixos/includes/system/flakes.nix similarity index 100% rename from common/flakes.nix rename to nixos/includes/system/flakes.nix diff --git a/common/locales.nix b/nixos/includes/system/locales.nix similarity index 100% rename from common/locales.nix rename to nixos/includes/system/locales.nix diff --git a/nixos/includes/system/lvm.nix b/nixos/includes/system/lvm.nix new file mode 100644 index 0000000..06570e1 --- /dev/null +++ b/nixos/includes/system/lvm.nix @@ -0,0 +1,10 @@ +{ pkgs, ... }: { + + environment.systemPackages = with pkgs; [ + lvm2_dmeventd + ]; + + services.lvm.enable = true; + services.lvm.dmeventd.enable = true; + services.lvm.boot.thin.enable = true; +} diff --git a/modules/nixos/neovim.nix b/nixos/includes/system/neovim.nix similarity index 100% rename from modules/nixos/neovim.nix rename to nixos/includes/system/neovim.nix diff --git a/nixos/includes/system/udisks2.nix b/nixos/includes/system/udisks2.nix new file mode 100644 index 0000000..6034d3e --- /dev/null +++ b/nixos/includes/system/udisks2.nix @@ -0,0 +1,3 @@ +_: { + services.udisks2.enable = true; +} diff --git a/common/user.nix b/nixos/includes/system/user.nix similarity index 100% rename from common/user.nix rename to nixos/includes/system/user.nix