|
|
| Line 4: |
Line 4: |
|
| |
|
| NixOS provides an easy way to build a custom variant of the installation image. This might be useful to embed your own ssh key or enable additional features like zfs support. It allows to specify a custom <code>configuration.nix</code> which is used to build the image | | NixOS provides an easy way to build a custom variant of the installation image. This might be useful to embed your own ssh key or enable additional features like zfs support. It allows to specify a custom <code>configuration.nix</code> which is used to build the image |
| | | This is explained in [[Creating a NixOS live CD]]. |
| <syntaxhighlight lang="nix">
| |
| # myiso.nix
| |
| { config, lib, pkgs, modulesPath, ... }:
| |
| {
| |
| imports = [
| |
| <nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix>
| |
| ];
| |
| # enable zfs support
| |
| #boot.supportedFilesystems = [ "zfs" ];
| |
| | |
| # enable sshd on boot
| |
| services.openssh = {
| |
| enable = true;
| |
| startWhenNeeded = true;
| |
| };
| |
| # the following allows to embed your own ssh key into the image
| |
| users.extraUsers.root.openssh.authorizedKeys.keys = [
| |
| "ssh-ed25519 AaAeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee username@host"
| |
| ];
| |
| | |
| ## The following snippet is useful, when static ip addresses are required,
| |
| ## e.g. for VPS installation
| |
| #
| |
| #networking = {
| |
| # usePredictableInterfaceNames = false;
| |
| # interfaces.eth0.ip4 = [{
| |
| # address = "64.137.201.46";
| |
| # prefixLength = 24;
| |
| # }];
| |
| # defaultGateway = "64.137.201.1";
| |
| # nameServers = [ "8.8.8.8" ];
| |
| #};
| |
| | |
| }</syntaxhighlight>
| |
| The '''full path''' of the file needs to be passed to <code>nix-build</code>.
| |
| | |
| <syntaxhighlight lang="bash">$ nix-build '<nixpkgs/nixos>' -A config.system.build.isoImage -I nixos-config=/etc/nixos/myiso.nix</syntaxhighlight>
| |
| The resulting image can be found in <code>result</code>:
| |
| | |
| <syntaxhighlight lang="bash">$ ls result/iso/
| |
| nixos-17.09.git.158ec57-x86_64-linux.iso</syntaxhighlight>
| |
|
| |
|
| == Install Nixos on VPS/Cloud-Provider == | | == Install Nixos on VPS/Cloud-Provider == |