mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-11-11 18:23:18 +01:00
This adds foundational functionality for nixos-facter hardware detection: - lib.nix: Internal helper functions for querying facter reports - hasCpu/hasAmdCpu/hasIntelCpu: CPU vendor detection - collectDrivers: Extract driver_modules from hardware entries - toZeroPaddedHex: Format USB device IDs (for fingerprint matching) - system.nix: Auto-detect nixpkgs.hostPlatform from facter report Automatically sets the correct platform (x86_64-linux, aarch64-linux, etc.) based on the hardware report, reducing manual configuration. This builds on the base infrastructure added in PR #450303 and provides the foundation for upcoming hardware detection modules (boot, networking, graphics, etc.). Part of the incremental upstreaming effort from: https://github.com/nix-community/nixos-facter-modules
45 lines
1.1 KiB
Nix
45 lines
1.1 KiB
Nix
{
|
|
lib,
|
|
config,
|
|
...
|
|
}:
|
|
{
|
|
imports = [
|
|
./system.nix
|
|
];
|
|
|
|
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 <https://nix-community.github.io/nixos-facter/> 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 <https://nix-community.github.io/nixos-facter/> for more information.
|
|
'';
|
|
};
|
|
};
|
|
}
|