Last active
June 4, 2021 06:09
-
-
Save jmettes/abc57a018be70efed9876f5529ff8a1c to your computer and use it in GitHub Desktop.
NixOS 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
nix-build --attr system "./nixos.nix" -o result-closure | |
readlink -f result-closure > closure-nix-store-path.txt | |
rm -r system | |
mkdir system | |
nix copy ./result-closure --to file://./system |
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 '<nixpkgs/nixos>' -A config.system.build.isoImage -I nixos-config=iso.nix -o result-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
{ config, pkgs, ... }: | |
{ | |
imports = | |
[ | |
./hardware-configuration.nix | |
]; | |
boot.loader.grub.device = "/dev/sda"; | |
services.openssh = { | |
enable = true; | |
permitRootLogin = "no"; | |
}; | |
networking = { | |
defaultGateway = { | |
address = "192.168.1.1"; | |
interface = "enp3s0"; | |
}; | |
interfaces.enp3s0 = { | |
useDHCP = false; | |
ipv4.addresses = [{ | |
address = "192.168.1.2"; | |
prefixLength = 24; | |
}]; | |
}; | |
nameservers = ["8.8.8.8" "8.8.4.4"]; | |
}; | |
users.users.myuser = { | |
isNormalUser = true; | |
extraGroups = [ "wheel" ]; | |
password = "mypassword"; | |
}; | |
environment.systemPackages = [ | |
pkgs.vim | |
]; | |
system.stateVersion = "19.03"; | |
} |
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
{ config, lib, pkgs, ... }: | |
{ | |
imports = [ ]; | |
boot.initrd.availableKernelModules = [ "ata_piix" "ohci_pci" "sd_mod" "sr_mod" ]; | |
boot.initrd.kernelModules = [ ]; | |
boot.kernelModules = [ ]; | |
boot.extraModulePackages = [ ]; | |
fileSystems."/" = | |
{ device = "/dev/disk/by-label/nixos"; | |
fsType = "ext4"; | |
}; | |
swapDevices = [ ]; | |
nix.maxJobs = lib.mkDefault 1; | |
} |
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
echo "create MBR partition" | |
parted --script /dev/sda -- mklabel msdos | |
echo "create root partition" | |
parted --script -a opt /dev/sda mkpart primary ext4 0% 100% | |
echo "format partition" | |
mkfs.ext4 -L nixos /dev/sda1 -F | |
sleep 1 | |
echo "mount target filesystem" | |
mount /dev/disk/by-label/nixos /mnt | |
echo "copy closure to nix store" | |
nix copy --from file:///etc/system $(cat /etc/closure-nix-store-path.txt) --option binary-caches "" --no-check-sigs | |
echo "install nix" | |
nixos-install --no-root-passwd --option binary-caches "" --system $(cat /etc/closure-nix-store-path.txt) |
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
{ config, pkgs, ... }: | |
{ | |
imports = [ | |
# https://nixos.wiki/wiki/Creating_a_NixOS_live_CD | |
<nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix> | |
<nixpkgs/nixos/modules/installer/cd-dvd/channel.nix> | |
]; | |
# add the automated installation files | |
environment.etc = { | |
"install.sh" = { | |
source = ./install.sh; | |
mode = "0700"; | |
}; | |
"closure-nix-store-path.txt" = { | |
source = ./closure-nix-store-path.txt; | |
}; | |
"system" = { | |
source = ./system; | |
}; | |
}; | |
# automatically run install script | |
environment.etc."profile.local".text = '' | |
/etc/install.sh | |
reboot | |
''; | |
} |
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
# http://www.haskellforall.com/2018/08/nixos-in-production.html | |
let | |
nixpkgs = builtins.fetchTarball { | |
url = "https://github.com/NixOS/nixpkgs/archive/b74b1cdb2fecc31ff7a127c5bc89771f887c93bb.tar.gz"; | |
sha256 = "0ncr4g29220amqm4riaa1xf4jz55v2nmh9fi16f1gzhww1gplk8h"; | |
}; | |
in | |
import "${nixpkgs}/nixos" { | |
configuration = { | |
imports = [ | |
./configuration.nix | |
]; | |
}; | |
system = "x86_64-linux"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It looks like it is possible to install the closure without copying it into the installation CDs nix store first, via: