From a4765b4fee3d73a13a19d895d744ea4f045edf20 Mon Sep 17 00:00:00 2001 From: Paul-Mathias Logue Date: Sun, 14 Dec 2025 00:23:16 +0100 Subject: [PATCH] Cleaning up --- flake.nix | 9 ++++---- machines/hermes/default.nix | 36 +++++++----------------------- machines/hermes/gpu.nix | 2 -- machines/hermes/hardware.nix | 43 ++++++++++++++++++++++++++++++++++++ overlays/default.nix | 3 +++ overlays/openrgb/default.nix | 20 ----------------- overlays/openrgb/package.nix | 25 +++++++++++++++++++++ 7 files changed, 84 insertions(+), 54 deletions(-) create mode 100644 machines/hermes/hardware.nix create mode 100644 overlays/default.nix delete mode 100644 overlays/openrgb/default.nix create mode 100644 overlays/openrgb/package.nix diff --git a/flake.nix b/flake.nix index b86d612..6c79a2b 100644 --- a/flake.nix +++ b/flake.nix @@ -4,10 +4,8 @@ inputs = { nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/*"; - lanzaboote = { - url = "github:nix-community/lanzaboote/v1.0.0"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + lanzaboote.url = "github:nix-community/lanzaboote/v1.0.0"; + lanzaboote.inputs.nixpkgs.follows = "nixpkgs"; apple-fonts.url = "github:Lyndeno/apple-fonts.nix"; apple-fonts.inputs.nixpkgs.follows = "nixpkgs"; @@ -40,11 +38,14 @@ system = "x86_64-linux"; specialArgs = { inherit inputs; }; modules = [ + { nixpkgs.overlays = [ self.overlays.default ]; } ./machines/hermes ./users/pml.nix ]; }; + overlays.default = import ./overlays; + devShells = forEachSupportedSystem ( { pkgs, system }: { diff --git a/machines/hermes/default.nix b/machines/hermes/default.nix index 07752bd..f83a98e 100644 --- a/machines/hermes/default.nix +++ b/machines/hermes/default.nix @@ -1,4 +1,9 @@ -{ lib, pkgs, ... }: +{ + inputs, + lib, + pkgs, + ... +}: { imports = [ @@ -9,6 +14,7 @@ ./audio.nix ./bluetooth.nix ./networking.nix + ./hardware.nix ]; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; @@ -38,30 +44,10 @@ # You can use https://search.nixos.org/ to find more packages (and options). environment.systemPackages = with pkgs; [ wget - sbctl alacritty fuzzel - libva-utils firefox - (openrgb.overrideAttrs (old: { - src = pkgs.fetchFromGitLab { - owner = "CalcProgrammer1"; - repo = "OpenRGB"; - rev = "release_candidate_1.0rc2"; - sha256 = "vdIA9i1ewcrfX5U7FkcRR+ISdH5uRi9fz9YU5IkPKJQ="; - }; - patches = [ - ./remove_systemd_service.patch - ]; - postPatch = '' - patchShebangs scripts/build-udev-rules.sh - substituteInPlace scripts/build-udev-rules.sh \ - --replace-fail /usr/bin/env "${pkgs.coreutils}/bin/env" - ''; - version = "1.0rc2"; - })) adwaita-icon-theme - i2c-tools ]; fonts.fontconfig = { @@ -75,7 +61,6 @@ rgba = "rgb"; lcdfilter = "default"; }; - defaultFonts = { serif = [ "SF Pro" @@ -145,15 +130,10 @@ polkitPolicyOwners = [ "pml" ]; }; - #services.hardware.openrgb.enable = true; - services.udev.packages = [ pkgs.openrgb ]; - boot.kernelModules = [ "i2c-dev" ]; - hardware.i2c.enable = true; - environment.etc = { "1password/custom_allowed_browsers" = { text = '' - firefox + firefox ''; mode = "0755"; }; diff --git a/machines/hermes/gpu.nix b/machines/hermes/gpu.nix index a9a0639..cba3087 100644 --- a/machines/hermes/gpu.nix +++ b/machines/hermes/gpu.nix @@ -1,7 +1,5 @@ { config, - inputs, - lib, pkgs, ... }: diff --git a/machines/hermes/hardware.nix b/machines/hermes/hardware.nix new file mode 100644 index 0000000..5f1b3f9 --- /dev/null +++ b/machines/hermes/hardware.nix @@ -0,0 +1,43 @@ +{ pkgs, ... }: +let + no-rgb = pkgs.writeScriptBin "no-rgb" '' + #!/bin/sh + NUM_DEVICES=$(${pkgs.openrgb}/bin/openrgb --list-devices | grep -E '^[0-9]+: ' | wc -l) + + for i in $(seq 0 $(($NUM_DEVICES - 1))); do + ${pkgs.openrgb}/bin/openrgb --device $i --mode static --color 000000 + done + ''; +in +{ + environment.systemPackages = with pkgs; [ + i2c-tools + lm_sensors + ]; + + boot.kernelModules = [ "i2c-dev" ]; + boot.blacklistedKernelModules = [ + # The spd5118 driver is in conflict with openrgb by holding onto I2C adresses when using Kingston Fury DRAM. + # On boot, I need to access those i2c regions in other to poweroff the RGB lighting. + # Then, I manually enable the kernel module in any script. + # It's possible to let this module disabled, but I lose the ability to get temperature values for the DIMMs. + # https://gitlab.com/CalcProgrammer1/OpenRGB/-/merge_requests/2557 + "spd5118" + ]; + + hardware.i2c.enable = true; + + # OpenRGB + services.udev.packages = [ pkgs.openrgb ]; + services.hardware.openrgb.enable = true; + systemd.services.no-rgb = { + description = "no-rgb"; + serviceConfig = { + ExecStart = "${no-rgb}/bin/no-rgb"; + Type = "oneshot"; + }; + after = [ "openrgb.service" ]; + requires = [ "openrgb.service" ]; + wantedBy = [ "multi-user.target" ]; + }; +} diff --git a/overlays/default.nix b/overlays/default.nix new file mode 100644 index 0000000..de540cd --- /dev/null +++ b/overlays/default.nix @@ -0,0 +1,3 @@ +final: prev: { + openrgb = final.callPackage ./openrgb/package.nix { openrgb = prev.openrgb; }; +} diff --git a/overlays/openrgb/default.nix b/overlays/openrgb/default.nix deleted file mode 100644 index e7481b0..0000000 --- a/overlays/openrgb/default.nix +++ /dev/null @@ -1,20 +0,0 @@ -final: prev: { - openrgb = prev.openrgb.overrideAttrs (old: { - src = final.fetchFromGitLab { - owner = "CalcProgrammer1"; - repo = "OpenRGB"; - rev = "release_candidate_1.0rc2"; - sha256 = "vdIA9i1ewcrfX5U7FkcRR+ISdH5uRi9fz9YU5IkPKJQ="; - }; - patches = [ - ./remove_systemd_service.patch - ]; - postPatch = '' - patchShebangs scripts/build-udev-rules.sh - substituteInPlace scripts/build-udev-rules.sh \ - --replace-fail /usr/bin/env "${final.coreutils}/bin/env" - ''; - - version = "1.0rc2"; - }); -} diff --git a/overlays/openrgb/package.nix b/overlays/openrgb/package.nix new file mode 100644 index 0000000..b29f946 --- /dev/null +++ b/overlays/openrgb/package.nix @@ -0,0 +1,25 @@ +{ + coreutils, + fetchFromGitLab, + openrgb, + ... +}: + +openrgb.overrideAttrs (old: { + version = "1.0rc2"; + src = fetchFromGitLab { + owner = "CalcProgrammer1"; + repo = "OpenRGB"; + rev = "release_candidate_1.0rc2"; + sha256 = "vdIA9i1ewcrfX5U7FkcRR+ISdH5uRi9fz9YU5IkPKJQ="; + }; + patches = [ + ./remove_systemd_service.patch + ]; + postPatch = '' + patchShebangs scripts/build-udev-rules.sh + substituteInPlace scripts/build-udev-rules.sh \ + --replace-fail /usr/bin/env "${coreutils}/bin/env" + ''; + +})