I would like to run nixos-generate-config outside the installer environment on non-NixOS distributions, to get the hardware configuration, particularly the list of kernel modules that should go into boot.initrd.availableKernelModules. (I am installing these machines with something similar to nixos-infect rather than nixos-install.)
nixos-generate-config is currently generated only in a module.
The workaround I'm using on Debian because I can't nix-env -iA it:
apt-get install file-slurp
perl /nix/store/h3j6xqbzxl6wasxm0s61n5q3683ypfkp-nixpkgs-19.03pre166583.872502aa56b/nixpkgs/nixos/modules/installer/tools/nixos-generate-config.pl --show-hardware-config
update: now
apt-get install libfile-slurp-perl git
git clone --depth=1 https://github.com/NixOS/nixpkgs
perl nixpkgs/nixos/modules/installer/tools/nixos-generate-config.pl --show-hardware-config
This was previously done in https://github.com/NixOS/nixpkgs/pull/48122 but it was reverted.
As a hack, you can create the following nixos-tools.nix:
{ pkgs ? import <nixpkgs> {} }:
let
config.nix.package = pkgs.nix;
config.system.nixos = {
release = "Koi";
version = "19.03";
codeName = "Koi";
revision = "foo";
};
inherit (pkgs) lib;
tools = import <nixpkgs/nixos/modules/installer/tools/tools.nix> { inherit pkgs lib config; };
in tools.config.system.build
and then run nix-env -f nixos-tools.nix -iA nixos-generate-config.
Thank you for your contributions.
This has been automatically marked as stale because it has had no activity for 180 days.
If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.
Here are suggestions that might help resolve this more quickly:
Most helpful comment
This was previously done in https://github.com/NixOS/nixpkgs/pull/48122 but it was reverted.
As a hack, you can create the following
nixos-tools.nix:and then run
nix-env -f nixos-tools.nix -iA nixos-generate-config.