Skip to content

NixOS Configuration

Taking the facter.json file generated in the previous step, we can construct a NixOS configuration:

flake.nix
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    nixos-facter-modules.url = "github:numtide/nixos-facter-modules";
  };

  outputs =
    inputs@{ nixpkgs, ... }:
    let
        inherit (nixpkgs) lib;
    in
    {
      nixosConfigurations.basic = lib.nixosSystem {
        modules = [

          # enable the NixOS Facter module
          inputs.nixos-facter-modules.nixosModules.facter

          # configure the facter report
          { config.facter.reportPath = ./facter.json; }

          # Additional modules and configuration, for example:
          #
          # {
          #   users.users.root.initialPassword = "fnord23";
          #   boot.loader.grub.devices = lib.mkForce [ "/dev/sda" ];
          #   fileSystems."/".device = lib.mkDefault "/dev/sda";
          # }
          # ...
          # Define your bootloader if you are not using grub
          # { boot.loader.systemd-boot.enable = true; }
        ];
      };
    };
}
configuration.nix
{ lib, ... }:
{
  imports = [
    "${
      (builtins.fetchTarball { url = "https://github.com/numtide/nixos-facter-modules/"; })
    }/modules/nixos/facter.nix"
  ];

  # configure the facter report
  config.facter.reportPath = ./facter.json;

  # Additional modules and configuration, for example:
  #
  # config.users.users.root.initialPassword = "fnord23";
  # config.boot.loader.grub.devices = lib.mkForce [ "/dev/sda" ];
  # config.fileSystems."/".device = lib.mkDefault "/dev/sda";
  #
  # ...
  # Define your bootloader if you are not using grub
  # config.boot.loader.systemd-boot.enable = true;
}

The NixOS Facter module will attempt to do the following:

Roadmap

We continue to add to and improve nixos-facter-modules. Our eventual goal is to replace much if not all of the functionality currently provided by nixos-hardware and nixos-generate-config.