Nixpkgs: Package request: nixos-generate-config

Created on 17 Jan 2019  路  2Comments  路  Source: NixOS/nixpkgs

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
stale

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:

{ 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.

All 2 comments

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:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

chris-martin picture chris-martin  路  3Comments

ghost picture ghost  路  3Comments

yawnt picture yawnt  路  3Comments

rzetterberg picture rzetterberg  路  3Comments

spacekitteh picture spacekitteh  路  3Comments