From 47500b78e322d902a90c3efd918c1b1d77265cef Mon Sep 17 00:00:00 2001 From: derped Date: Thu, 25 Nov 2021 22:03:04 +0100 Subject: [PATCH] Add new machine Marid. --- machines/Marid/configuration.nix | 7 ++ machines/Marid/hardware-configuration.nix | 79 +++++++++++++++++++++++ machines/Marid/options.nix | 67 +++++++++++++++++++ pkgsets/xpkgs.nix | 6 +- services/desktop.nix | 1 - services/fprintd.nix | 18 ++++++ 6 files changed, 175 insertions(+), 3 deletions(-) create mode 100644 machines/Marid/configuration.nix create mode 100644 machines/Marid/hardware-configuration.nix create mode 100644 machines/Marid/options.nix create mode 100644 services/fprintd.nix diff --git a/machines/Marid/configuration.nix b/machines/Marid/configuration.nix new file mode 100644 index 0000000..22a41f0 --- /dev/null +++ b/machines/Marid/configuration.nix @@ -0,0 +1,7 @@ +{ pkgs, ... }: + +{ + services.cron.enable = false; + networking.dhcpcd.extraConfig = "noarp"; + system.stateVersion = "21.05"; +} diff --git a/machines/Marid/hardware-configuration.nix b/machines/Marid/hardware-configuration.nix new file mode 100644 index 0000000..75678ad --- /dev/null +++ b/machines/Marid/hardware-configuration.nix @@ -0,0 +1,79 @@ +{ config, pkgs, modulesPath, ... }: + +let + cfg = config.machine; +in { + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; + + boot = { + loader.systemd-boot = { + enable = true; + }; + loader.efi.canTouchEfiVariables = true; + tmpOnTmpfs = true; + cleanTmpDir = true; + + kernelPackages = pkgs.linuxPackages_latest; + initrd.availableKernelModules = [ "nvme" "xhci_pci" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; + kernelModules = [ "kvm-amd" ]; + kernelParams = [ + # get backlight service to work part one (fixes systemd backlight service) + "acpi_backlight=native" + ]; + kernel.sysctl = { + "kernel.nmi_watchdog" = 0; + "fs.inotify.max_user_watches" = 524288; + "vm.dirty_writeback_centisecs" = 1500; + }; + }; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/cf8db7d5-5da7-4fb9-818d-ed5dd2815f0d"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/96E4-9DF3"; + fsType = "vfat"; + }; + + hardware = { + firmware = with pkgs; [ firmwareLinuxNonfree ]; + enableAllFirmware = true; + ksm.enable = true; + opengl = { + driSupport = true; + driSupport32Bit = true; + }; + + pulseaudio = { + enable = true; + support32Bit = true; + package = pkgs.pulseaudioFull; + zeroconf.discovery.enable = false; + extraClientConf = '' + autospawn = no + ''; + }; + + bluetooth = { + enable = true; + powerOnBoot = true; + }; + }; + + powerManagement = { + enable = true; + cpuFreqGovernor = "powersave"; + }; + services = { + upower.enable = true; + # Fix Backlight Part 2 (allows acpilight to modify brightness) + udev.extraRules = '' + ACTION=="add", SUBSYSTEM=="backlight", RUN+="${pkgs.coreutils}/bin/chgrp video /sys/class/backlight/%k/brightness" + ACTION=="add", SUBSYSTEM=="backlight", RUN+="${pkgs.coreutils}/bin/chmod 664 /sys/class/backlight/%k/brightness" + ''; + }; + + time.timeZone = "Europe/Berlin"; +} diff --git a/machines/Marid/options.nix b/machines/Marid/options.nix new file mode 100644 index 0000000..0390133 --- /dev/null +++ b/machines/Marid/options.nix @@ -0,0 +1,67 @@ +{ pkgs, lib, ... }: + +with lib; + +{ + imports = [ + ../../options/copySysConf.nix + ]; + config.machine = { + allowUnfree = true; + hostName = "Marid"; + administrators = [ { name = "derped"; id = 1337; } ]; + conffiles = [ + "etcfiles" + "etcvars" + "fonts" + "zsh" + ]; + pkgs = [ + "base" + "dict" + "nodejs" + "emacs" + "emacs::company" + "emacs::docker" + "emacs::doom-modeline" + "emacs::doom-themes" + "emacs::elpy" + "emacs::fcitx" + "emacs::flycheck" + "emacs::flyspell" + "emacs::undo-tree" + "emacs::lsp" + "emacs::magit" + "emacs::mu4e" + "emacs::nix-mode" + "emacs::org" + "emacs::php-mode" + "emacs::web-mode" + "emacs::yasnippet" + "extra" + "mail_utils" + "python3" + "xpkgs" + ]; + services = [ + "docker" + "desktop" + "udev" + "fprintd" + ]; + firewall = { + enable = true; + allowPing = true; + allowedUDPPorts = [ ]; + allowedTCPPorts = [ ]; + allowedUDPPortRanges = [ ]; + allowedTCPPortRanges = [ ]; + }; + desktop.wms = [ "none+i3" "i3" ]; + }; + + config.system.copySysConf = { + enable = false; + addToNixPath = false; + }; +} diff --git a/pkgsets/xpkgs.nix b/pkgsets/xpkgs.nix index f70574c..a11247b 100644 --- a/pkgsets/xpkgs.nix +++ b/pkgsets/xpkgs.nix @@ -1,6 +1,8 @@ { config, pkgs, ... }: -{ +let + cfg = config.machine; +in { config.machine.pkgsets.xpkgs.pkgs = with pkgs; [ feh scrot @@ -15,7 +17,7 @@ pavucontrol xclip xlibs.xkill - xorg.xbacklight + (if (cfg.hostName == "Marid") then xbacklight else xorg.xbacklight) xdiskusage ]; } diff --git a/services/desktop.nix b/services/desktop.nix index cc2edbc..d7ee21e 100644 --- a/services/desktop.nix +++ b/services/desktop.nix @@ -39,7 +39,6 @@ in mkIf (elem "desktop" cfg.services) { services.xserver = { enable = !(elem "sway" cfg.desktop.wms); layout = "de"; - videoDrivers = [ "intel" ]; displayManager.defaultSession = ifelse (cfg.desktop.wms != []) (elemAt cfg.desktop.wms 0) null; windowManager = mkIf (cfg.desktop.wms != []) { i3 = mkIf (elem "i3" cfg.desktop.wms) (import ./desktop/i3.nix { inherit pkgs; }); diff --git a/services/fprintd.nix b/services/fprintd.nix new file mode 100644 index 0000000..c0d59c6 --- /dev/null +++ b/services/fprintd.nix @@ -0,0 +1,18 @@ +{ config, lib, ... }: + +with lib; + +mkIf (elem "fprintd" config.machine.services) { + security.pam.services = let + unlock = [ + "sudo" + "i3lock" + "login" + "lightdm" + ]; + in listToAttrs (forEach unlock (n: {name = n; value = { fprintAuth = true; }; })); + + services.fprintd = { + enable = true; + }; +}