Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documentation on how to generate NixOS ISO #21840

Closed
ck3d opened this issue Jan 12, 2017 · 8 comments
Closed

Improve documentation on how to generate NixOS ISO #21840

ck3d opened this issue Jan 12, 2017 · 8 comments

Comments

@ck3d
Copy link
Contributor

ck3d commented Jan 12, 2017

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
@vcunat
Copy link
Member

vcunat commented Jan 13, 2017

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 = [ ...]).

@ck3d
Copy link
Contributor Author

ck3d commented Jan 16, 2017

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

@globin
Copy link
Member

globin commented Jan 16, 2017

If I understand correctly this works and can be closed?

@vcunat
Copy link
Member

vcunat commented Jan 16, 2017

I think that manual section would deserve to get clearer.

@jpotier
Copy link
Contributor

jpotier commented May 19, 2017

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

@bjornfor
Copy link
Contributor

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

@jpotier
Copy link
Contributor

jpotier commented May 19, 2017

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

emmanuelrosa added a commit to emmanuelrosa/nixpkgs that referenced this issue Jun 3, 2017
This change updates the instructions for building a NixOS ISO so that it's clear how to do it.

Previously, the instructions stated to set NIXOS_CONFIG prior to running `nix-build`, yet the example provided by-passed NIXOS_CONFIG anyway. But the *really* important missing piece is the need for nixos/default.nix. See NixOS#21840.

This change removes the NIXOS_CONFIG verbiage, and adds steps to clone nixpkgs and (most importantly) cd'ing into nixpkgs/nixos. That way, the reader may think: *Oh, so I need a default.nix and a configuration.nix. Ahhh, OK.*

I purposely added the redundant default.nix argument.
grahamc pushed a commit that referenced this issue Jun 3, 2017
This change updates the instructions for building a NixOS ISO so that it's clear how to do it.

Previously, the instructions stated to set NIXOS_CONFIG prior to running `nix-build`, yet the example provided by-passed NIXOS_CONFIG anyway. But the *really* important missing piece is the need for nixos/default.nix. See #21840.

This change removes the NIXOS_CONFIG verbiage, and adds steps to clone nixpkgs and (most importantly) cd'ing into nixpkgs/nixos. That way, the reader may think: *Oh, so I need a default.nix and a configuration.nix. Ahhh, OK.*

I purposely added the redundant default.nix argument.

(cherry picked from commit 4bee34d)
grahamc pushed a commit that referenced this issue Jun 3, 2017
This change updates the instructions for building a NixOS ISO so that it's clear how to do it.

Previously, the instructions stated to set NIXOS_CONFIG prior to running `nix-build`, yet the example provided by-passed NIXOS_CONFIG anyway. But the *really* important missing piece is the need for nixos/default.nix. See #21840.

This change removes the NIXOS_CONFIG verbiage, and adds steps to clone nixpkgs and (most importantly) cd'ing into nixpkgs/nixos. That way, the reader may think: *Oh, so I need a default.nix and a configuration.nix. Ahhh, OK.*

I purposely added the redundant default.nix argument.
@lukateras lukateras changed the title Failed to generate own NixOS CD Improve documentation on how to generate NixOS ISO Dec 23, 2017
@lukateras
Copy link
Member

Fixed in 4bee34d.

adrianpk added a commit to adrianpk/nixpkgs that referenced this issue May 31, 2024
This change updates the instructions for building a NixOS ISO so that it's clear how to do it.

Previously, the instructions stated to set NIXOS_CONFIG prior to running `nix-build`, yet the example provided by-passed NIXOS_CONFIG anyway. But the *really* important missing piece is the need for nixos/default.nix. See NixOS#21840.

This change removes the NIXOS_CONFIG verbiage, and adds steps to clone nixpkgs and (most importantly) cd'ing into nixpkgs/nixos. That way, the reader may think: *Oh, so I need a default.nix and a configuration.nix. Ahhh, OK.*

I purposely added the redundant default.nix argument.

(cherry picked from commit 4bee34d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants