Skip to content

Commit 7ae85a6

Browse files
committed
remove installer dependency on nixos-install
1 parent 8a2b15c commit 7ae85a6

3 files changed

Lines changed: 22 additions & 11 deletions

File tree

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

os/installer/config.nix

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
RemainAfterExit = true;
3333
};
3434
path = [
35-
pkgs.libuuid
35+
pkgs.util-linuxMinimal
3636
pkgs.jq
3737
pkgs.curl
3838
pkgs.nix
@@ -53,11 +53,7 @@
5353
system.extraDependencies = lib.mkForce [ ];
5454

5555
# # Disable unused nixos tools
56-
system.tools.nixos-version.enable = false;
57-
system.tools.nixos-rebuild.enable = false;
58-
system.tools.nixos-option.enable = false;
59-
system.tools.nixos-generate-config.enable = false;
60-
system.tools.nixos-build-vms.enable = false;
56+
system.disableInstallerTools = true;
6157

6258
# # Disable documentation
6359
documentation.enable = false;

os/installer/install.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,25 @@ if [[ $USER_PASSWD ]]; then
127127
fi
128128

129129
# Build configuration
130-
nix build /mnt/etc/nixos#nixosConfigurations.xnode.config.system.build.toplevel --store /mnt
130+
nix build /mnt/etc/nixos#nixosConfigurations.xnode.config.system.build.toplevel --store /mnt --profile /mnt/nix/var/nix/profiles/system
131131

132132
# Apply configuration
133-
nixos-install --no-root-passwd --no-channel-copy --system ./result
133+
# Based on https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/ni/nixos-install/nixos-install.sh and https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/by-name/ni/nixos-enter/nixos-enter.sh
134+
mkdir -p /mnt/dev /mnt/sys /mnt/proc
135+
chmod 0755 /mnt/dev /mnt/sys /mnt/proc
136+
mount --rbind /dev /mnt/dev
137+
mount --rbind /sys /mnt/sys
138+
mount --rbind /proc /mnt/proc
139+
chroot /mnt /nix/var/nix/profiles/system/sw/bin/bash -c "$(cat << EOL
140+
set -e
141+
/nix/var/nix/profiles/system/activate || true
142+
/nix/var/nix/profiles/system/sw/bin/systemd-tmpfiles --create --remove -E || true
143+
mount --rbind --mkdir / /mnt
144+
mount --make-rslave /mnt
145+
NIXOS_INSTALL_BOOTLOADER=1 /nix/var/nix/profiles/system/bin/switch-to-configuration boot
146+
umount -R /mnt && (rmdir /mnt 2>/dev/null || true)
147+
EOL
148+
)"
134149

135150
# Boot into new OS
136151
reboot

0 commit comments

Comments
 (0)