This repository has been archived on 2024-03-04. You can view files and clone it, but cannot push or open issues or pull requests.
linux/.config/bash/module/Bootstrap.sh

69 lines
1.6 KiB
Bash
Raw Normal View History

2023-12-17 19:44:49 +03:00
# Install Editorconfig file (with tabs) in current directory.
function bootstrap_editorconfig() {
echo "\
[*]
end_of_line = lf
charset = utf-8
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true
" > .editorconfig
}
# Install Editorconfig file (with specified spaces, 8 by default) in current directory.
# Usage: bootstrap_editorconfig_space [AMOUNT]
function bootstrap_editorconfig_space() {
local spaces="${1}"
[[ "${spaces}" = "" ]] && spaces=8
echo "\
[*]
end_of_line = lf
charset = utf-8
indent_style = space
indent_size = ${spaces}
insert_final_newline = true
trim_trailing_whitespace = true
" > .editorconfig
}
2024-02-21 01:42:50 +03:00
# 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%
2024-02-21 02:44:38 +03:00
parted -s "${target}" name 1 NIXBOOT
parted -s "${target}" name 2 NIXROOT
2024-02-21 03:11:58 +03:00
parted -s "${target}" set 1 esp on
2024-02-21 01:42:50 +03:00
# Format.
2024-02-21 04:02:55 +03:00
mkfs.fat -F 32 /dev/disk/by-partlabel/NIXBOOT
mkfs.ext4 -F /dev/disk/by-partlabel/NIXROOT
2024-02-21 01:42:50 +03:00
# Mount.
2024-02-21 04:02:55 +03:00
mount /dev/disk/by-partlabel/NIXROOT /mnt
2024-02-21 01:42:50 +03:00
mkdir /mnt/boot
2024-02-21 04:02:55 +03:00
mount /dev/disk/by-partlabel/NIXBOOT /mnt/boot
2024-02-21 01:42:50 +03:00
# Generate config.
nixos-generate-config --root /mnt
# Install.
cd /mnt
if [[ "${host}" = "" ]]; then
nixos-install
else
nixos-install --no-root-password --flake "${_nix_system_config}#${host}"
2024-02-21 01:42:50 +03:00
fi
}