From 066b65c34c6d7b79417c82a667de6fe97ac206dc Mon Sep 17 00:00:00 2001 From: twoneis Date: Sat, 13 Jan 2024 22:06:10 +0100 Subject: [PATCH] added options to build with to avoid removing and re-adding stuff --- devices/desktop/default.nix | 1 + devices/desktop/options.nix | 5 ++ devices/surface/default.nix | 1 + devices/surface/options.nix | 5 ++ modules/system/default.nix | 116 +++++++++++++++++-------------- modules/system/gnome/default.nix | 2 +- modules/system/niri/default.nix | 2 +- modules/system/virt.nix | 5 ++ 8 files changed, 81 insertions(+), 56 deletions(-) create mode 100644 devices/desktop/options.nix create mode 100644 devices/surface/options.nix create mode 100644 modules/system/virt.nix diff --git a/devices/desktop/default.nix b/devices/desktop/default.nix index e9db86b..e7d861f 100644 --- a/devices/desktop/default.nix +++ b/devices/desktop/default.nix @@ -1,6 +1,7 @@ { config, pkgs, ... }: { imports = [ ./hardware-config.nix + ./options.nix ]; networking.hostName = "desktop"; diff --git a/devices/desktop/options.nix b/devices/desktop/options.nix new file mode 100644 index 0000000..43e5fd0 --- /dev/null +++ b/devices/desktop/options.nix @@ -0,0 +1,5 @@ +{ ... }: { + withNiri = false; + withGnome = true; + withVM = false; +} diff --git a/devices/surface/default.nix b/devices/surface/default.nix index 361d6fd..7b4df37 100644 --- a/devices/surface/default.nix +++ b/devices/surface/default.nix @@ -1,6 +1,7 @@ { pkgs, ... }: { imports = [ ./hardware-config.nix + ./options.nix ]; networking.hostName = "surface"; diff --git a/devices/surface/options.nix b/devices/surface/options.nix new file mode 100644 index 0000000..43e5fd0 --- /dev/null +++ b/devices/surface/options.nix @@ -0,0 +1,5 @@ +{ ... }: { + withNiri = false; + withGnome = true; + withVM = false; +} diff --git a/modules/system/default.nix b/modules/system/default.nix index c958f38..9610823 100644 --- a/modules/system/default.nix +++ b/modules/system/default.nix @@ -2,80 +2,88 @@ # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). -{ pkgs, ... }: { +{ pkgs, lib, config, ... }: { + options = { + withNiri = with lib; mkEnableOption "Enable niri"; + withGnome = with lib; mkEnableOption "Enable gnome"; + withVM = with lib; mkEnableOption "Enable VM related configuration"; + }; + imports = [ ./audio.nix ./containers.nix ./fonts.nix ./gnome ./niri + ./virt.nix ]; - - # Allow packages from nixpkgs - nixpkgs.config = { - allowUnfree = true; - }; - - #Optimise nix store - nix = { - gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 1w"; + config = { + # Allow packages from nixpkgs + nixpkgs.config = { + allowUnfree = true; }; - settings.auto-optimise-store = true; - }; - # Enable nix flakes - nix.settings.experimental-features = [ "nix-command" "flakes" ]; + #Optimise nix store + nix = { + gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 1w"; + }; + settings.auto-optimise-store = true; + }; - # Disable documentation - documentation.nixos.enable = false; + # Enable nix flakes + nix.settings.experimental-features = [ "nix-command" "flakes" ]; - # Enable networking - networking.networkmanager.enable = true; + # Disable documentation + documentation.nixos.enable = false; - # Set your time zone. - time.timeZone = "Europe/Amsterdam"; + # Enable networking + networking.networkmanager.enable = true; - # Select internationalisation properties. - i18n.defaultLocale = "en_US.UTF-8"; + # Set your time zone. + time.timeZone = "Europe/Amsterdam"; - 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"; - }; + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; - # Enable the X11 windowing system. - services.xserver.enable = true; + 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"; + }; - # Remove XTerm - services.xserver.excludePackages = [ pkgs.xterm ]; + # Enable the X11 windowing system. + services.xserver.enable = true; - # Configure keymap in X11 - services.xserver = { - layout = "us"; - xkbVariant = ""; - }; + # Remove XTerm + services.xserver.excludePackages = [ pkgs.xterm ]; - # Enable CUPS to print documents. - services.printing.enable = false; + # Configure keymap in X11 + services.xserver = { + layout = "us"; + xkbVariant = ""; + }; - # Security - security.rtkit.enable = true; + # Enable CUPS to print documents. + services.printing.enable = false; - # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.twoneis = { - isNormalUser = true; - description = "twoneis"; - extraGroups = [ "networkmanager" "wheel" ]; + # Security + security.rtkit.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" ]; + }; }; } diff --git a/modules/system/gnome/default.nix b/modules/system/gnome/default.nix index fd069ff..343f1be 100644 --- a/modules/system/gnome/default.nix +++ b/modules/system/gnome/default.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: { +{ pkgs, lib, config, ... }: lib.mkIf (config.withGnome) { # Enable the GNOME Desktop Environment. services.xserver.displayManager.gdm.enable = true; services.xserver.desktopManager.gnome.enable = true; diff --git a/modules/system/niri/default.nix b/modules/system/niri/default.nix index 90e31e2..8aadec2 100644 --- a/modules/system/niri/default.nix +++ b/modules/system/niri/default.nix @@ -1,3 +1,3 @@ -{ ... }: { +{ lib, config, ... }: lib.mkIf (config.withNiri) { programs.niri.enable = true; } diff --git a/modules/system/virt.nix b/modules/system/virt.nix new file mode 100644 index 0000000..a80421d --- /dev/null +++ b/modules/system/virt.nix @@ -0,0 +1,5 @@ +{ lib, config, ... }: lib.mkIf (config.withVM) { + virtualisation.libvirtd.enable = true; + programs.virt-manager.enable = true; + users.users.twoneis.extraGroups = [ "libvirtd" ]; +}