Skip to content

Instantly share code, notes, and snippets.

@johnrichardrinehart
Created January 19, 2021 15:28
Show Gist options
  • Save johnrichardrinehart/82ecfec652e11e630de4cee077761cca to your computer and use it in GitHub Desktop.
Save johnrichardrinehart/82ecfec652e11e630de4cee077761cca to your computer and use it in GitHub Desktop.
make-iso.nix
# build an ISO image that will auto install NixOS and reboot
# $ nix-build make-iso.nix
let
config = (import <nixpkgs/nixos/lib/eval-config.nix> {
system = "x86_64-linux";
modules = [
<nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix>
({ pkgs, lib, ... }:
let
cfg = pkgs.writeText "configuration.nix" ''
{ config, pkgs, lib, ... }:
{
boot.loader.grub.enable = true;
boot.loader.grub.devices = [ "/dev/sda" ];
boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "ehci_pci" "usbhid" "usb_storage" "sd_mod" "sr_mod" ];
users.mutableUsers = false;
fileSystems = [
{ mountPoint = "/"; fsType = "ext4"; label = "root"; }
];
networking.wireless.enable = true;
networking.wireless.userControlled.enable = true;
networking.wireless.networks.AstroNet.psk = "N0Pa$$w0rd";
}
'';
partitions = pkgs.writeText "partitions" ''
clearpart --all --initlabel --drives=sda
part swap --size=512 --ondisk=sda
part / --fstype=ext4 --label=root --grow --ondisk=sda
'';
in {
services.openssh.permitRootLogin = "yes";
users.extraUsers.root.initialPassword = "some_password";
})
];
}).config;
in
config.system.build.isoImage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment