Skip to content

Instantly share code, notes, and snippets.

@whazor
Created November 18, 2023 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whazor/245adec4b4a7bd8248697e60b0001808 to your computer and use it in GitHub Desktop.
Save whazor/245adec4b4a7bd8248697e60b0001808 to your computer and use it in GitHub Desktop.
NixOS Iso with SSH
nix build .#nixosConfigurations.machineIso.config.system.build.isoImage
ls result/iso/
# nixos-23.05.20231106.41de143-x86_64-linux.iso
{
outputs = { self, nixpkgs }: {
nixosConfigurations.machineIso = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
#./machine.nix
(nixpkgs
+ "/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix")
(nixpkgs + "/nixos/modules/installer/cd-dvd/channel.nix")
({ pkgs, ... }: {
# Enable SSH in the boot process.
systemd.services.sshd.wantedBy =
pkgs.lib.mkForce [ "multi-user.target" ];
users.users.root.openssh.authorizedKeys.keys = [
# your ssh key
"ssh-ed25519 AaAeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee username@host"
];
isoImage.squashfsCompression = "gzip -Xcompression-level 1";
networking = {
usePredictableInterfaceNames = false;
useDHCP = true;
nameservers = [ "8.8.8.8" ];
};
})
];
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment