From 7facf2e7495ed5429197043b420a025ee7c4bedf Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Thu, 21 Mar 2024 11:04:01 -0500 Subject: [PATCH] clean up even more boilerplate --- hosts/algiz/system.nix | 27 +++++---- hosts/mannaz/system.nix | 59 +++++++++----------- hosts/othalan/system.nix | 48 ++++++---------- modules/desktop/window-managers/hyprland.nix | 3 +- modules/networking/vpn.nix | 3 +- modules/programs/chrome/default.nix | 3 +- modules/storage/restic.nix | 2 +- 7 files changed, 62 insertions(+), 83 deletions(-) diff --git a/hosts/algiz/system.nix b/hosts/algiz/system.nix index 7fe7c39..e1381ad 100644 --- a/hosts/algiz/system.nix +++ b/hosts/algiz/system.nix @@ -1,10 +1,12 @@ -{lib, ...}: { +{lib, ...}: let + inherit (lib) enabled; +in { users.motd = lib.mkRune { number = "6"; rune = "algiz"; }; - services.resolved.enable = true; + services.resolved = enabled; services.fail2ban = { enable = true; @@ -19,13 +21,15 @@ # networking.nameservers = [ "8.8.8.8"]; # allow tcp connections for revsere proxy - networking.firewall = { - enable = true; - allowedTCPPorts = [80 443]; - }; + networking.firewall = + enabled + // { + allowedTCPPorts = [80 443]; + }; - services.openssh.enable = true; - services.openssh.settings.PasswordAuthentication = false; + services.openssh = + enabled + // {settings.PasswordAuthentication = false;}; # users.mutableUsers = false; @@ -33,11 +37,6 @@ boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/sda"; # or "nodev" for efi only - # 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). + # don't delete this you foo bar system.stateVersion = "23.11"; # Did you read the comment? } diff --git a/hosts/mannaz/system.nix b/hosts/mannaz/system.nix index 540fd5a..5a21d74 100644 --- a/hosts/mannaz/system.nix +++ b/hosts/mannaz/system.nix @@ -3,7 +3,9 @@ pkgs, lib, ... -}: { +}: let + inherit (lib) enabled; +in { users.motd = lib.mkRune { number = "2"; rune = "mannaz"; @@ -11,7 +13,7 @@ # Use the systemd-boot EFI boot loader. boot.loader = { - systemd-boot.enable = true; + systemd-boot = enabled; efi.canTouchEfiVariables = true; }; @@ -26,27 +28,31 @@ } ]; - hardware.opengl = { - enable = true; - driSupport = true; - driSupport32Bit = true; - extraPackages = with pkgs; [ - libGL - ]; - setLdLibraryPath = true; - }; + hardware.opengl = + enabled + // { + driSupport = true; + driSupport32Bit = true; + extraPackages = with pkgs; [ + libGL + ]; + setLdLibraryPath = true; + }; # Load nvidia driver for Xorg and Wayland services.xserver.videoDrivers = ["nvidia"]; hardware.nvidia = { # Modesetting is required. - modesetting.enable = true; + modesetting = enabled; # Nvidia power management. Experimental, and can cause sleep/suspend to fail. - powerManagement.enable = false; - # Fine-grained power management. Turns off GPU when not in use. - # Experimental and only works on modern Nvidia GPUs (Turing or newer). - powerManagement.finegrained = false; + powerManagement = + enabled + // { + # Fine-grained power management. Turns off GPU when not in use. + # Experimental and only works on modern Nvidia GPUs (Turing or newer). + finegrained = false; + }; # Use the NVidia open source kernel module (not to be confused with the # independent third-party "nouveau" open source driver). @@ -65,8 +71,8 @@ package = config.boot.kernelPackages.nvidiaPackages.stable; }; - programs.nix-ld.enable = true; - services.openssh.enable = true; + programs.nix-ld = enabled; + services.openssh = enabled; networking.hostName = "mannaz"; # networking.wireless.enable = true; @@ -80,21 +86,6 @@ time.timeZone = "America/Chicago"; security.sudo.wheelNeedsPassword = false; - # This option defines the first version of NixOS you have installed on this particular machine, - # and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions. - # - # Most users should NEVER change this value after the initial install, for any reason, - # even if you've upgraded your system to a new NixOS release. - # - # This value does NOT affect the Nixpkgs version your packages and OS are pulled from, - # so changing it will NOT upgrade your system. - # - # This value being lower than the current NixOS release does NOT mean your system is - # out of date, out of support, or vulnerable. - # - # Do NOT change this value unless you have manually inspected all the changes it would make to your configuration, - # and migrated your data accordingly. - # - # For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion . + # don't delete this you foo bar system.stateVersion = "23.11"; # Did you read the comment? } diff --git a/hosts/othalan/system.nix b/hosts/othalan/system.nix index 76a0aa5..9d659da 100644 --- a/hosts/othalan/system.nix +++ b/hosts/othalan/system.nix @@ -2,26 +2,27 @@ pkgs, lib, ... -}: { - networking.networkmanager.enable = true; - services.printing.enable = true; - services.fwupd.enable = true; - hardware.bluetooth.enable = true; - hardware.bluetooth.powerOnBoot = true; +}: let + inherit (lib) enabled; +in { + networking.networkmanager = enabled; + services.printing = enabled; + services.fwupd = enabled; + hardware.bluetooth = enabled // {powerOnBoot = true;}; # https://github.com/NixOS/nixos-hardware/blob/c478b3d56969006e015e55aaece4931f3600c1b2/lenovo/thinkpad/x1/9th-gen/default.nix # https://github.com/NixOS/nixos-hardware/blob/c478b3d56969006e015e55aaece4931f3600c1b2/common/pc/ssd/default.nix - services.fstrim.enable = true; + services.fstrim = enabled; # rtkit is optional but recommended - security.rtkit.enable = true; - services.pipewire = { - enable = true; - audio.enable = true; - pulse.enable = true; - alsa.enable = true; - alsa.support32Bit = true; - }; + security.rtkit = enabled; + services.pipewire = + enabled + // { + audio = enabled; + pulse = enabled; + alsa = enabled // {support32Bit = true;}; + }; environment.systemPackages = with pkgs; [ pamixer @@ -46,21 +47,6 @@ boot.loader.efi.canTouchEfiVariables = true; # boot.kernelPackages = pkgs.linuxPackages_latest; - # This option defines the first version of NixOS you have installed on this particular machine, - # and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions. - # - # Most users should NEVER change this value after the initial install, for any reason, - # even if you've upgraded your system to a new NixOS release. - # - # This value does NOT affect the Nixpkgs version your packages and OS are pulled from, - # so changing it will NOT upgrade your system. - # - # This value being lower than the current NixOS release does NOT mean your system is - # out of date, out of support, or vulnerable. - # - # Do NOT change this value unless you have manually inspected all the changes it would make to your configuration, - # and migrated your data accordingly. - # - # For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion . + # don't delete this you foo bar system.stateVersion = "23.11"; # Did you read the comment? } diff --git a/modules/desktop/window-managers/hyprland.nix b/modules/desktop/window-managers/hyprland.nix index c67c1d7..03c898a 100644 --- a/modules/desktop/window-managers/hyprland.nix +++ b/modules/desktop/window-managers/hyprland.nix @@ -13,7 +13,8 @@ swaylock -c 1e1e2e ''; }; -in mkOizysModule config "hyprland" { +in + mkOizysModule config "hyprland" { security.pam.services.swaylock = {}; # Optional, hint electron apps to use wayland: environment.sessionVariables.NIXOS_OZONE_WL = "1"; diff --git a/modules/networking/vpn.nix b/modules/networking/vpn.nix index f150972..45294b2 100644 --- a/modules/networking/vpn.nix +++ b/modules/networking/vpn.nix @@ -5,6 +5,7 @@ ... }: let inherit (lib) mkOizysModule; -in mkOizysModule config "vpn" { +in + mkOizysModule config "vpn" { environment.systemPackages = [pkgs.openconnect]; } diff --git a/modules/programs/chrome/default.nix b/modules/programs/chrome/default.nix index 050aaa9..fb90a90 100644 --- a/modules/programs/chrome/default.nix +++ b/modules/programs/chrome/default.nix @@ -5,7 +5,8 @@ ... }: let inherit (lib) mkOizysModule; -in mkOizysModule config "chrome" { +in + mkOizysModule config "chrome" { programs.chromium = { enable = true; diff --git a/modules/storage/restic.nix b/modules/storage/restic.nix index 80d3918..8889975 100644 --- a/modules/storage/restic.nix +++ b/modules/storage/restic.nix @@ -5,7 +5,7 @@ ... }: let inherit (lib) mkOizysModule; -in +in mkOizysModule config "backups" { environment.systemPackages = with pkgs; [rclone];