84 lines
1.8 KiB
Bash
84 lines
1.8 KiB
Bash
# 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
|
|
}
|
|
|
|
# Setup all the flatpak apps on the machine.
|
|
function bootstrap_flatpak() {
|
|
# Add Flathub repo.
|
|
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
|
|
|
|
# Reinstall apps.
|
|
local IFS=$'\n'
|
|
local targets="$(cat ~/.config/linux/Flatpak.txt | cut -f2)"
|
|
|
|
process() {
|
|
flatpak install -y --system "${target}"
|
|
}
|
|
|
|
_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%
|
|
parted -s "${target}" name NIXBOOT
|
|
parted -s "${target}" name NIXROOT
|
|
|
|
# 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
|
|
}
|