建置可開機的 ISO 映像

目錄

建置可開機的 ISO 映像#

備註

If you need to build images for a different platform, see Cross compiling.

You may find that an official installation image lacks some hardware support.

The solution is to create myimage.nix to point to the latest kernel using the minimal installation ISO:

 1{ pkgs, modulesPath, lib, ... }: {
 2  imports = [
 3    "${modulesPath}/installer/cd-dvd/installation-cd-minimal.nix"
 4  ];
 5
 6  # use the latest Linux kernel
 7  boot.kernelPackages = pkgs.linuxPackages_latest;
 8
 9  # Needed for https://github.com/NixOS/nixpkgs/issues/58959
10  boot.supportedFilesystems = lib.mkForce [ "btrfs" "reiserfs" "vfat" "f2fs" "xfs" "ntfs" "cifs" ];
11}

Generate an ISO with the above configuration:

$ NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/74e2faf5965a12e8fa5cff799b1b19c6cd26b0e3.tar.gz nix-shell -p nixos-generators --run "nixos-generate --format iso --configuration ./myimage.nix -o result"

Copy the new image to your USB stick by replacing sdX with the name of your device:

$ dd if=result/iso/*.iso of=/dev/sdX status=progress
$ sync

下一步#