Creating a NixOS live CD: Difference between revisions
imported>Fadenb Created page with "== motivation == creating a modified NIXOS live CD out of a working nixos installation gives you the benefits: * verify what is included * no need to download it * it is easy..." |
imported>Makefu remove old code |
||
Line 1: | Line 1: | ||
== motivation == | == motivation == | ||
creating a modified NIXOS live CD out of a working nixos installation gives you the benefits: | creating a modified NIXOS live CD out of a working nixos installation gives you the benefits: | ||
Line 37: | Line 38: | ||
} | } | ||
=== | === Start SSH with your SSH key | ||
In your configuration.nix: | |||
<code> | |||
services.openssh = { | |||
enable = true; | |||
hostKeys = [ | |||
{ bits = 8192; type = "ed25519"; path = "/etc/ssh/ssh_host_ed25519_key"; } | |||
]; | |||
}; | |||
# enable ssh in the iso boot process | |||
systemd.services.sshd.wantedBy = lib.mkForce [ "multi-user.target" ]; | |||
users.users.root.openssh.authorizedKeys.keys [ | |||
"ssh-rsa AAAAB3NzaC1y...== me@my-laptop" | |||
]; | |||
</code> | |||
== software installation inside the 'once' deployed and booted image == | == software installation inside the 'once' deployed and booted image == | ||
in case you have booted from your image you can add software as described here: | in case you have booted from your image you can add software as described here: | ||
* [[install/remove software]] | * [[install/remove software]] | ||
== references == | == references == | ||
Line 68: | Line 67: | ||
[[Category:Installation]] | [[Category:Installation]] | ||
[[Category:Deployment]] | [[Category:Deployment]] | ||
[[Category:HOW-TO]] |
Revision as of 18:28, 21 August 2017
motivation
creating a modified NIXOS live CD out of a working nixos installation gives you the benefits:
- verify what is included
- no need to download it
- it is easy to add your own programs to the image
how to build such an image
we will use the NIXREPOS variable, which points to the nixpkgs/nixos checkouts, see Create and debug nix packages
just run this command (for 64 bit):
export NIX_PATH=$NIXREPOS nix-build -A iso_graphical.x86_64-linux $NIXREPOS/nixos/release.nix
for 32 bit:
export NIX_PATH=$NIXREPOS nix-build -A iso_graphical.i686-linux $NIXREPOS/nixos/release.nix
once the building process is over, you should see multiple nix distributions built (for multiple archs). See contents to find iso image path:
$ cat /nix/store/2y4bivmrzg4d2dgby2b7prvfj7445088-nixos-iso-0.1pre1234/nix-support/hydra-build-products file iso /nix/store/94rrfklbk2hcqhkr4627vsrlprlyva50-iso9660-image/iso/nixos-minimal-0.1pre1234-i686-linux-test.iso
and copy the new image from there to your USB drive (or use unetbootin).
adding additional software to the image
the basic script /etc/nixos/nixos/release.nix contains several entry points for custom images. as we are using -A iso_minimal have a look at: iso_minimal which will redirect us to:
- ./modules/installer/cd-dvd/installation-cd-minimal.nix -> /etc/nixos/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix
# This module defines a small NixOS installation CD. It does not # contain any graphical stuff. {config, pkgs, ...}: { require = [ ./installation-cd-base.nix ../../profiles/minimal.nix ]; }
=== Start SSH with your SSH key
In your configuration.nix:
services.openssh = {
enable = true;
hostKeys = [
{ bits = 8192; type = "ed25519"; path = "/etc/ssh/ssh_host_ed25519_key"; }
];
};
# enable ssh in the iso boot process
systemd.services.sshd.wantedBy = lib.mkForce [ "multi-user.target" ];
users.users.root.openssh.authorizedKeys.keys [
"ssh-rsa AAAAB3NzaC1y...== me@my-laptop"
];
software installation inside the 'once' deployed and booted image
in case you have booted from your image you can add software as described here:
references
- See also section "Building your own NixOS CD" of the NixOS manual.