Compare commits
No commits in common. "1087715a1b16522b38f601d44e112d77c7261fc3" and "bdbe54a3f83db9503c1941e039bf3920a9576cf7" have entirely different histories.
1087715a1b
...
bdbe54a3f8
@ -1,80 +1,10 @@
|
||||
{ pkgs, lib, modulesPath, ... }:
|
||||
|
||||
let
|
||||
nixfiles-auto-install = pkgs.writeScriptBin "nixfiles-auto-install" ''
|
||||
#!${pkgs.bash}/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
hostname=host''${RANDOM}
|
||||
|
||||
echo "[I] Deploying with hostname ''${hostname}"
|
||||
|
||||
device=""
|
||||
for dev in ("/dev/vda" "/dev/sda"); do
|
||||
if [[ -b $dev ]]; then
|
||||
device=$dev
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--hostname)
|
||||
hostname=$2
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "unknown option: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "[I] Formatting disk"
|
||||
|
||||
if [[ -z $device ]]; then
|
||||
echo "[E] No device to install to"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[I] Using ''${device}"
|
||||
|
||||
parted --script $device mklabel gpt
|
||||
parted --script $device disk_set pmbr_boot on
|
||||
|
||||
parted --script $device mkpart boot 0% 512M
|
||||
parted --script $device set 1 bios_grub on
|
||||
|
||||
parted --script $device mkpart root 512M 100%
|
||||
|
||||
echo "[I] Creating file system"
|
||||
|
||||
mkfs.ext4 -F ''${device}2
|
||||
|
||||
echo "[I] Mount file system"
|
||||
|
||||
mount ''${device}2 /mnt
|
||||
|
||||
echo "[I] Generate NixOS configuration"
|
||||
|
||||
nixfiles-generate-config --root /mnt --hostname ''${hostname}
|
||||
|
||||
sed -i "s/\# boot\.loader\.grub\.device = \"/dev/sda\";/boot\.loader\.grub\.device = \"''${device}\";/g" /mnt/etc/nixos/hosts/''${hostname}/configuration.nix
|
||||
|
||||
echo "[I] Install NixOS"
|
||||
|
||||
nixos-install --flake /mnt/etc/nixos#''${hostname} --root /mnt --no-root-password
|
||||
'';
|
||||
in {
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/installer/cd-dvd/installation-cd-base.nix")
|
||||
];
|
||||
|
||||
networking.hostName = "isowo";
|
||||
isoImage.isoBaseName = "nixos-isowo";
|
||||
|
||||
environment.systemPackages = [
|
||||
nixfiles-auto-install
|
||||
];
|
||||
}
|
||||
|
@ -48,8 +48,16 @@ let
|
||||
fi
|
||||
|
||||
sed -i "s/\%HOSTNAME\%/''${hostname}/g" ''${root}/etc/nixos/hosts/''${hostname}/configuration.nix
|
||||
'';
|
||||
|
||||
git -C ''${root}/etc/nixos add ''${root}/etc/nixos/hosts/''${hostname}
|
||||
nixfiles-install = pkgs.writeScriptBin "nixfiles-install" ''
|
||||
#!${pkgs.bash}/bin/bash
|
||||
nixos-install --flake /etc/nixos $@
|
||||
'';
|
||||
|
||||
nixfiles-rebuild = pkgs.writeScriptBin "nixfiles-rebuild" ''
|
||||
#!${pkgs.bash}/bin/bash
|
||||
nixos-rebuild --flake /etc/nixos $@
|
||||
'';
|
||||
|
||||
in {
|
||||
|
Loading…
Reference in New Issue
Block a user