Bootstrap : Add nixos install.

This commit is contained in:
Dmitry Voronin 2024-02-21 01:42:50 +03:00
parent 2bdf37d892
commit 5978d1e3d1
2 changed files with 38 additions and 0 deletions

View file

@ -42,3 +42,40 @@ function bootstrap_flatpak() {
_iterate_targets process ${targets[@]} _iterate_targets process ${targets[@]}
} }
# Install nixos to specified drive. To be run from Live ISO.
# Usage: bootstrap_nixos <DRIVE> [HOST]
function bootstrap_nixos() {
local target="${1}"
local host="${2}"
if [[ "${target}" = "" ]]; then
help bootstrap_nixos
return 2
fi
# Create partitions.
parted -s "${target}" mktable gpt
parted -s "${target}" mkpart primary 0% 512MB
parted -s "${target}" mkpart primary 512MB 100%
# Format.
mkfs.fat -F 32 "${target}1"
mkfs.ext4 -F "${target}2"
# Mount.
mount "${target}2" /mnt
mkdir /mnt/boot
mount "${target}1" /mnt/boot
# Generate config.
nixos-generate-config --root /mnt
# Install.
cd /mnt
if [[ "${host}" = "" ]]; then
nixos-install
else
nixos-install --flake "${_nix_system_config}#${host}"
fi
}

View file

@ -116,6 +116,7 @@
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules = [
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix" "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
"${nixpkgs}/nixos/modules/installer/cd-dvd/channel.nix"
{ networking.wireless.enable = nixpkgs.lib.mkForce false; } { networking.wireless.enable = nixpkgs.lib.mkForce false; }
({ pkgs, ... }: { boot.kernelPackages = nixpkgs.lib.mkForce pkgs.linuxPackages; }) ({ pkgs, ... }: { boot.kernelPackages = nixpkgs.lib.mkForce pkgs.linuxPackages; })
./module/Gnome.nix ./module/Gnome.nix