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 a95f10ee110a..c1e41909951d 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
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 1c60715db7f5..e8427a17974e 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -520,6 +520,7 @@ in
etebase-server = runTest ./etebase-server.nix;
etesync-dav = runTest ./etesync-dav.nix;
evcc = runTest ./evcc.nix;
+ facter = runTest ./facter;
fail2ban = runTest ./fail2ban.nix;
fakeroute = runTest ./fakeroute.nix;
fancontrol = runTest ./fancontrol.nix;
diff --git a/nixos/tests/facter/default.nix b/nixos/tests/facter/default.nix
new file mode 100644
index 000000000000..7083d5d8bd09
--- /dev/null
+++ b/nixos/tests/facter/default.nix
@@ -0,0 +1,29 @@
+{ lib, pkgs, ... }:
+{
+ name = "facter";
+ meta = with lib.maintainers; {
+ maintainers = [ mic92 ];
+ };
+
+ nodes.machine = {
+ hardware.facter.reportPath = ./facter.json;
+ environment.systemPackages = [ pkgs.nixos-facter ];
+ };
+
+ testScript = ''
+ from pprint import pprint
+
+ machine.wait_for_unit("multi-user.target")
+
+ with subtest("Run nixos-facter and verify it produces valid JSON"):
+ import json
+ # Run nixos-facter and check it produces valid output
+ output = machine.succeed("nixos-facter")
+ # Parse JSON to verify it's valid
+ report = json.loads(output)
+ pprint(report)
+ assert "version" in report, "Expected version field in nixos-facter output"
+ assert "system" in report, "Expected system field in nixos-facter output"
+ assert report["version"] == 1, f"Expected version 1, got {report['version']}"
+ '';
+}
diff --git a/nixos/tests/facter/facter.json b/nixos/tests/facter/facter.json
new file mode 100644
index 000000000000..37d6ba87c14d
--- /dev/null
+++ b/nixos/tests/facter/facter.json
@@ -0,0 +1,31 @@
+{
+ "version": 1,
+ "system": "x86_64-linux",
+ "virtualisation": "kvm",
+ "hardware": {
+ "bios": {
+ "smbios_version": 520
+ },
+ "cpu": [
+ {
+ "architecture": "x86_64",
+ "vendor_name": "AuthenticAMD",
+ "family": 25,
+ "model": 33
+ }
+ ],
+ "system": {
+ "form_factor": "desktop"
+ }
+ },
+ "smbios": {
+ "bios": {
+ "vendor": "SeaBIOS",
+ "version": "test"
+ },
+ "system": {
+ "manufacturer": "QEMU",
+ "product": "Standard PC"
+ }
+ }
+}
diff --git a/pkgs/by-name/ni/nixos-facter/package.nix b/pkgs/by-name/ni/nixos-facter/package.nix
index 8c519a65256f..6b75db216fc4 100644
--- a/pkgs/by-name/ni/nixos-facter/package.nix
+++ b/pkgs/by-name/ni/nixos-facter/package.nix
@@ -7,6 +7,7 @@
gcc,
pkg-config,
makeWrapper,
+ nixosTests,
stdenv,
systemdMinimal,
}:
@@ -61,6 +62,10 @@ buildGoModule rec {
"-X github.com/numtide/nixos-facter/pkg/build.System=${stdenv.hostPlatform.system}"
];
+ passthru.tests = {
+ inherit (nixosTests) facter;
+ };
+
meta = {
description = "Declarative hardware configuration for NixOS";
homepage = "https://github.com/numtide/nixos-facter";