Created
November 18, 2023 17:20
-
-
Save whazor/245adec4b4a7bd8248697e60b0001808 to your computer and use it in GitHub Desktop.
NixOS Iso with SSH
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nix build .#nixosConfigurations.machineIso.config.system.build.isoImage | |
ls result/iso/ | |
# nixos-23.05.20231106.41de143-x86_64-linux.iso |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
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