modified: auto-installer/installer.nix
This commit is contained in:
@@ -29,52 +29,93 @@ environment.etc."git-credentials".text =
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
systemd.services.autoInstall = {
|
||||
description = "Automatic NixOS installation";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
path = [
|
||||
pkgs.parted
|
||||
pkgs.util-linux
|
||||
pkgs.e2fsprogs
|
||||
pkgs.nixos-install
|
||||
pkgs.nix
|
||||
pkgs.git
|
||||
pkgs.bash
|
||||
];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = pkgs.writeShellScript "auto-install.sh" ''
|
||||
# Write auto-install script to /root
|
||||
environment.etc."root/auto-install.sh".text = ''
|
||||
#!/run/current-system/sw/bin/bash
|
||||
set -eux
|
||||
#create MBR table
|
||||
parted /dev/sda -- mklabel msdos
|
||||
#create nixos partition
|
||||
parted /dev/sda -- mkpart primary 1MB -8GB
|
||||
#set nixos partition to bootable
|
||||
parted /dev/sda -- set 1 boot on
|
||||
# create swap partition
|
||||
parted /dev/sda -- mkpart primary linux-swap -8GB 100%
|
||||
|
||||
#format OS partition
|
||||
mkfs.ext4 -L nixos /dev/sda1
|
||||
#format swap
|
||||
mkswap -L swap /dev/sda2
|
||||
|
||||
#activate swap
|
||||
swapon /dev/sda2
|
||||
|
||||
#mount nixos partition
|
||||
mount /dev/disk/by-label/nixos /mnt
|
||||
# Choose a disk-backed temp directory
|
||||
mkdir -p /mnt/install-tmp
|
||||
export TMPDIR=/mnt/install-tmp
|
||||
|
||||
parted /dev/sda -- mklabel msdos
|
||||
parted /dev/sda -- mkpart primary 1MB -8GB
|
||||
parted /dev/sda -- set 1 boot on
|
||||
parted /dev/sda -- mkpart primary linux-swap -8GB 100%
|
||||
mkfs.ext4 -L nixos /dev/sda1
|
||||
mkswap -L swap /dev/sda2
|
||||
swapon /dev/sda2
|
||||
mount /dev/disk/by-label/nixos /mnt
|
||||
|
||||
nixos-install --flake "$(cat /etc/flake-url)" --no-root-password --no-write-lock-file
|
||||
rm -r /mnt/install-tmp
|
||||
rm -rf /mnt/install-tmp
|
||||
sleep 10
|
||||
reboot
|
||||
'';
|
||||
environment.etc."root/auto-install.sh".mode = "0755";
|
||||
|
||||
systemd.services.autoInstallInteractive = {
|
||||
description = "Interactive NixOS installer on tty2";
|
||||
wants = [ "getty@tty2.service" ];
|
||||
after = [ "getty@tty2.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
StandardInput = "tty";
|
||||
StandardOutput = "inherit";
|
||||
TTYPath = "/dev/tty2";
|
||||
TTYReset = true;
|
||||
TTYVHangup = true;
|
||||
};
|
||||
|
||||
# Run script attached to tty2
|
||||
script = "exec /root/auto-install.sh";
|
||||
};
|
||||
# systemd.services.autoInstall = {
|
||||
# description = "Automatic NixOS installation";
|
||||
# wantedBy = [ "multi-user.target" ];
|
||||
# after = [ "network-online.target" ];
|
||||
# path = [
|
||||
# pkgs.parted
|
||||
# pkgs.util-linux
|
||||
# pkgs.e2fsprogs
|
||||
# pkgs.nixos-install
|
||||
# pkgs.nix
|
||||
# pkgs.git
|
||||
# pkgs.bash
|
||||
# ];
|
||||
# serviceConfig = {
|
||||
# Type = "oneshot";
|
||||
# ExecStart = pkgs.writeShellScript "auto-install.sh" ''
|
||||
# set -eux
|
||||
# #create MBR table
|
||||
# parted /dev/sda -- mklabel msdos
|
||||
# #create nixos partition
|
||||
# parted /dev/sda -- mkpart primary 1MB -8GB
|
||||
# #set nixos partition to bootable
|
||||
# parted /dev/sda -- set 1 boot on
|
||||
# # create swap partition
|
||||
# parted /dev/sda -- mkpart primary linux-swap -8GB 100%
|
||||
|
||||
# #format OS partition
|
||||
# mkfs.ext4 -L nixos /dev/sda1
|
||||
# #format swap
|
||||
# mkswap -L swap /dev/sda2
|
||||
|
||||
# #activate swap
|
||||
# swapon /dev/sda2
|
||||
|
||||
# #mount nixos partition
|
||||
# mount /dev/disk/by-label/nixos /mnt
|
||||
# # Choose a disk-backed temp directory
|
||||
# mkdir -p /mnt/install-tmp
|
||||
# export TMPDIR=/mnt/install-tmp
|
||||
|
||||
# nixos-install --flake "$(cat /etc/flake-url)" --no-root-password --no-write-lock-file
|
||||
# rm -r /mnt/install-tmp
|
||||
# sleep 10
|
||||
# reboot
|
||||
# '';
|
||||
# };
|
||||
# };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user