From b7f40d25ebe0e89abb8d557e162592e9088f240e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Thu, 9 Oct 2025 15:05:51 +0100 Subject: [PATCH] nixos/facter: add initial commit This is the first step to upstream nixos-facter-modules into nixpkgs/nixos: https://github.com/numtide/nixos-facter-modules/ We tried to stick close to the semantics nixos-generate-config + some extra features. We choose a new prefix for hardware.facter to live in so that existing users of nixos-facter-modules can continue using it while the upstreaming is in progress. The reason for upstreaming is to make it easier to have nixos-facter as choice for hardware detection as part of our normal NixOS installation workflow. Hardware from my experience takes many hands since it is hard to test without having access to a large variety of hardware. We hope that with nixos-facter we can reduce the boiler code required in the nixos-hardware project and provide better out-of-the-box support, even if a model has not been explicitly added to nixos-hardware. I.e. unlike ubuntu we don't have support for detecting required GPU drivers. We believe that nixos-hardware will be still required for some vendor specific quirks, but we could in future automatically select the profiles based on reported SKU from facter. For more details watch the 2024 NixCon talk: https://www.youtube.com/watch?v=3H3YUqibC6c --- nixos/modules/hardware/facter/default.nix | 40 +++++++++++++++++++++++ nixos/modules/module-list.nix | 1 + 2 files changed, 41 insertions(+) create mode 100644 nixos/modules/hardware/facter/default.nix diff --git a/nixos/modules/hardware/facter/default.nix b/nixos/modules/hardware/facter/default.nix new file mode 100644 index 000000000000..0d3163185b98 --- /dev/null +++ b/nixos/modules/hardware/facter/default.nix @@ -0,0 +1,40 @@ +{ + lib, + config, + ... +}: +{ + meta.maintainers = with lib.maintainers; [ mic92 ]; + + options.hardware.facter = with lib; { + report = mkOption { + type = types.attrsOf types.anything; + default = + if config.hardware.facter.reportPath == null then + { } + else + builtins.fromJSON (builtins.readFile config.hardware.facter.reportPath); + defaultText = "A JSON import from config.hardware.facter.reportPath (if not null), {} otherwise."; + description = '' + Hardware report data generated by nixos-facter. + + See for more information. + ''; + }; + + reportPath = mkOption { + type = types.nullOr types.path; + default = null; + description = '' + Path to a hardware report generated by nixos-facter. + + To generate a report, run the following as root: + ``` + nix-shell -p nixos-facter --run nixos-facter > facter.json + ``` + + See for more information. + ''; + }; + }; +} diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 5b285ee24580..45351dd2b145 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -66,6 +66,7 @@ ./hardware/decklink.nix ./hardware/device-tree.nix ./hardware/digitalbitbox.nix + ./hardware/facter ./hardware/flipperzero.nix ./hardware/flirc.nix ./hardware/fw-fanctrl.nix