Creating a NixOS live CD: Difference between revisions
imported>Makefu remove old code |
imported>Makefu remove old howto code |
||
Line 6: | Line 6: | ||
* it is easy to add your own programs to the image | * it is easy to add your own programs to the image | ||
== how to build | == how to build your own image == | ||
Create a file "iso.nix": | |||
# This module defines a small NixOS installation CD. It does not | # This module defines a small NixOS installation CD. It does not | ||
# contain any graphical stuff. | # contain any graphical stuff. | ||
{config, pkgs, ...}: | {config, pkgs, ...}: | ||
{ | { | ||
imports = [ | |||
<nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix> | |||
<nixpkgs/nixos/modules/installer/cd-dvd/channel.nix> | |||
]; | ]; | ||
} | } | ||
Build the image via: | |||
nix-build -A config.system.build.isoImage -I nixos-config=iso.nix /path/to/nixpkgs/nixos | |||
=== Start SSH with your SSH key | === Start SSH with your SSH key | ||
In your | In your iso.nix: | ||
<code> | <code> |
Revision as of 18:35, 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 your own image
Create a file "iso.nix":
# This module defines a small NixOS installation CD. It does not # contain any graphical stuff. {config, pkgs, ...}: { imports = [ <nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix> <nixpkgs/nixos/modules/installer/cd-dvd/channel.nix> ]; }
Build the image via:
nix-build -A config.system.build.isoImage -I nixos-config=iso.nix /path/to/nixpkgs/nixos
=== Start SSH with your SSH key
In your iso.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.