Creating a NixOS live CD: Difference between revisions
m Improvements for translations |
export iso as package output, build with path:$PWD instead of git init |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
<translate> | <translate> | ||
<!--T:19--> | == Motivation == <!--T:19--> | ||
<!--T:33--> | |||
Creating a modified NixOS LiveCD out of an existing working NixOS installation has a number of benefits: | Creating a modified NixOS LiveCD out of an existing working NixOS installation has a number of benefits: | ||
<!--T:34--> | |||
* Ensures authenticity. | * Ensures authenticity. | ||
<!--T:35--> | |||
* No need for internet access. | * No need for internet access. | ||
<!--T:36--> | |||
* It is easy to add your own packages and configuration changes to the image. | * It is easy to add your own packages and configuration changes to the image. | ||
<!--T:20--> | == Building == <!--T:20--> | ||
<!--T:37--> | |||
Building minimal NixOS installation CD with the <code>nix-build</code> command by creating this <code>iso.nix</code>-file. In this example with [[Neovim]] preinstalled. | Building minimal NixOS installation CD with the <code>nix-build</code> command by creating this <code>iso.nix</code>-file. In this example with [[Neovim]] preinstalled. | ||
| Line 50: | Line 53: | ||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; | inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; | ||
outputs = { self, nixpkgs }: { | outputs = { self, nixpkgs }: { | ||
packages.x86_64-linux.default = self.nixosConfigurations.exampleIso.config.system.build.isoImage; | |||
nixosConfigurations = { | nixosConfigurations = { | ||
exampleIso = nixpkgs.lib.nixosSystem { | exampleIso = nixpkgs.lib.nixosSystem { | ||
| Line 71: | Line 75: | ||
</translate> | </translate> | ||
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
# nix build path:$PWD | |||
# nix build | |||
</syntaxhighlight> | </syntaxhighlight> | ||
<translate> | <translate> | ||
| Line 87: | Line 90: | ||
<translate> | <translate> | ||
<!--T:7--> | === Testing the image === <!--T:7--> | ||
<!--T:38--> | |||
To inspect the contents of the ISO image: | To inspect the contents of the ISO image: | ||
| Line 112: | Line 115: | ||
<translate> | <translate> | ||
<!--T:26--> | ===SSH=== <!--T:26--> | ||
<!--T:39--> | |||
In your <tt>iso.nix</tt>: | In your <tt>iso.nix</tt>: | ||
| Line 131: | Line 134: | ||
<translate> | <translate> | ||
<!--T:11--> | ===Static IP Address=== <!--T:11--> | ||
<!--T:40--> | |||
Static IP addresses can be set in the image itself. This can be useful for VPS installation. | Static IP addresses can be set in the image itself. This can be useful for VPS installation. | ||
</translate> | </translate> | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix" line="1"> | ||
{ | { | ||
... | ... | ||
networking = { | networking = { | ||
usePredictableInterfaceNames = false; | usePredictableInterfaceNames = false; | ||
interfaces.eth0. | interfaces.eth0.ipv4.addresses = [{ | ||
address = "64.137.201.46"; | address = "64.137.201.46"; | ||
prefixLength = 24; | prefixLength = 24; | ||
| Line 154: | Line 157: | ||
<translate> | <translate> | ||
<!--T:27--> | === Building faster === <!--T:27--> | ||
<!--T:41--> | |||
The build process is slow because of compression. | The build process is slow because of compression. | ||
| Line 192: | Line 195: | ||
<translate> | <translate> | ||
<!--T:32--> | ==See also== <!--T:32--> | ||
<!--T:42--> | |||
* [https://nixos.org/manual/nixos/stable/index.html#sec-building-image NixOS Manual: Building a NixOS (Live) ISO]. | * [https://nixos.org/manual/nixos/stable/index.html#sec-building-image NixOS Manual: Building a NixOS (Live) ISO]. | ||
</translate> | </translate> | ||