Nixpkgs: Improve documentation on how to generate NixOS ISO

Created on 12 Jan 2017  Â·  8Comments  Â·  Source: NixOS/nixpkgs

Issue description

Following steps in NixOS Manual chapter 31. failes.

Steps to reproduce

Approach setting NIXOS_CONFIG in read-only nixos/

$ export NIXOS_CONFIG=/etc/nixos/configuration.nix
$ cd ~/.nix-defexpr/channels_root/nixos/nixos
$ nix-build -A config.system.build.isoImage -I nixos-config=modules/installer/cd-dvd/installation-cd-minimal.nix
error: attribute ‘isoImage’ in selection path ‘config.system.build.isoImage’ not found

Analysis: nixos/default.nix includes via ./lib/from-env.nix NIXOS_CONFIG and not nixos-config.

Approach without NIXOS_CONFIG in read-only nixos/

$ cd ~/.nix-defexpr/channels_root/nixos/nixos
$ nix-build -A config.system.build.isoImage -I nixos-config=modules/installer/cd-dvd/installation-cd-minimal.nix
...
error: creating a garbage collector root (/nix/store/933gjnzyi22z4l0qbsnhvm7r7136g144-nixos-17.03pre98682.f673243/nixos/nixos/result) in the Nix store is forbidden (are you running nix-build inside the store?)

It seems, that write access is needed in current working directory.

Approach without NIXOS_CONFIG in writeable nixos/

$ git clone --branch nixos-unstable https://github.com/NixOS/nixpkgs-channels.git nixpkgs
$ cd nixpkgs/nixos
$ nix-build -A config.system.build.isoImage -I nixos-config=modules/installer/cd-dvd/installation-cd-minimal.nix
...
Making image hybrid...
/nix/store/askpf8v8gmy14cwqayn0yx0h88zl8cyz-nixos-17.03.git.f673243-x86_64-linux.iso

It created an image, but without my custom configuration.nix.

Technical details

  • System: 17.03pre98682.f673243 (Gorilla)
  • Nix version: 1.11.5
  • Nixpkgs version: 17.03pre98682.f673243
documentation

Most helpful comment

I think that manual section would deserve to get clearer.

All 8 comments

By specifying -I nixos-config= you set location of your configuration.nix. You want to use your own and import that ISO config into it (via imports = [ ...]).

Thanks, that works.

Outcome

  • the folder of nixpkgs needs to be write-able
  • NIXOS_CONFIG is ignored and not needed for the given command
  • _own_ means your own ISO image of NixOS and has nothing to do with my own configuration.nix
  • passing more than one NixOS module is not possible from command line

If I understand correctly this works and can be closed?

I think that manual section would deserve to get clearer.

Back on the topic, I was attempting to build a minimal-cd with a new user with this file (configuration.nix):

{ pkgs, config, ... }:

{
  # based on cd-minimal
  imports = [
    modules/installer/cd-dvd/installation-cd-minimal.nix
  ];

  services.time.timeZone = "Europe/Paris";
}

I cloned the latest nixpkgs from github in a directory named nixpkgs, and then I moved configuration.nix to nixpkgs/nixos/, then I run:

$ cd nixpkgs/nixos
$ nix-build -A config.system.build.isoImage -I nixos-config=configuration.nix

This fails with:
error: The option services.time defined in dir/nixpkgs/nixos/configuration.nix does not exist.

@vcunat

You want to use your own and import that ISO config into it (via imports = [ ...]).

To me it seems it is not that simple

The option is called "time.timeZone". No "service". See configuration.nix manual page.

You are right of course… I f* up my configuration.nix somehow :)

Fixed in 4bee34dcc5e6886aac8c868410f12a670da03062.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

teto picture teto  Â·  3Comments

rzetterberg picture rzetterberg  Â·  3Comments

ob7 picture ob7  Â·  3Comments

lverns picture lverns  Â·  3Comments

langston-barrett picture langston-barrett  Â·  3Comments