Makefile: Add install-nixos instead of bootstrap script.

This commit is contained in:
Dmitry Voronin 2025-01-29 17:40:21 +03:00
parent 04eafe31e9
commit f7ec603543
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k
4 changed files with 71 additions and 46 deletions
Bootstrap.shMakefile
host/x86_64-linux/installer
package/ctagslsp

View file

@ -1,42 +0,0 @@
#!/usr/bin/env bash
# Install nixos to specified drive. To be run from Live ISO.
# Usage: ./Bootstrap.sh <DRIVE> [HOST]
cfg="$(realpath .)"
target="${1}"
host="${2}"
if [[ ${target} == "" ]]; then
printf "Usage: ./.Bootstrap.sh <DRIVE> [HOST]\n"
exit 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 1 NIXBOOT
parted -s "${target}" name 2 NIXROOT
parted -s "${target}" set 1 esp on
# Format.
mkfs.fat -F 32 /dev/disk/by-partlabel/NIXBOOT
mkfs.ext4 -F /dev/disk/by-partlabel/NIXROOT
# Mount.
mount /dev/disk/by-partlabel/NIXROOT /mnt
mkdir /mnt/boot
mount /dev/disk/by-partlabel/NIXBOOT /mnt/boot
# Generate config.
nixos-generate-config --root /mnt
# Install.
cd /mnt
if [[ ${host} == "" ]]; then
printf "Warning: Installing basic system.\n"
nixos-install
else
printf "Installing ${host}...\n"
nixos-install --no-root-password --no-channel-copy --flake "${cfg}#${host}"
fi

View file

@ -52,6 +52,55 @@ install-hm:
nix-channel --update
nix-shell '<home-manager>' -A install
# Required env variables set:
# INSTALL_HOST - Host name to install.
# INSTALL_TARGET - Drive to install to.
# Must have Internet connection and running from the live iso.
install-nixos:
@[ "${HOSTNAME}" = "live" ] || { \
_error "Not running from the live iso!"; \
exit 2; \
};
@test -f host/*/"${INSTALL_HOST}"/default.nix || { \
_error "\$$INSTALL_HOST not found or not specified."; \
exit 2; \
};
@test -f "${INSTALL_TARGET}" || { \
_error "\$$INSTALL_TARGET not found or not specified."; \
exit 2; \
};
@[ $$(nmcli networking connectivity check) = "full" ] || { \
_error "No internet connection!"; \
exit 2; \
};
@printf "%s\n%s: %s\n%s: %s\n" \
"Summary" \
"Target" "${INSTALL_TARGET}" \
"Host" "${INSTALL_HOST}"
@printf "%s" "Press Enter to continue, <C-c> to cancel."
@read
# Partition.
parted -s "${INSTALL_TARGET}" mktable gpt
parted -s "${INSTALL_TARGET}" mkpart primary 0% 512MB
parted -s "${INSTALL_TARGET}" mkpart primary 512MB 100%
parted -s "${INSTALL_TARGET}" name 1 NIXBOOT
parted -s "${INSTALL_TARGET}" name 2 NIXROOT
parted -s "${INSTALL_TARGET}" set 1 esp on
# Format
mkfs.fat -F 32 /dev/disk/by-partlabel/NIXBOOT
mkfs.ext4 -F /dev/disk/by-partlabel/NIXROOT
# Mount
mount /dev/disk/by-partlabel/NIXROOT /mnt
mkdir /mnt/boot
mount /dev/disk/by-partlabel/NIXBOOT /mnt/boot
# Install
cd /mnt && nixos-install --no-root-password --no-channel-copy --flake ".#${INSTALL_HOST}" || { \
# Rollback.
umount /mnt/boot
umount /mnt
};
installer:
nix build -o iso/installer $(options) $(flake)#nixosConfigurations.installer.config.system.build.isoImage

View file

@ -11,6 +11,10 @@
"${inputs.nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
];
# Root user config.
home.nixos = true;
user.root = true;
# Required for live iso.
networking.wireless.enable = lib.mkForce false;

View file

@ -3,10 +3,12 @@
fetchFromGitHub,
lib,
makeWrapper,
nix-update-script,
universal-ctags,
versionCheckHook,
}:
buildGoModule rec {
name = "ctags-lsp";
pname = "ctags-lsp";
version = "0.6.1";
vendorHash = null;
@ -19,16 +21,28 @@ buildGoModule rec {
nativeBuildInputs = [ makeWrapper ];
ldflags = [
"-s"
"-w"
"-X main.version=${version}"
];
postInstall = ''
wrapProgram $out/bin/ctags-lsp \
--prefix PATH : ${lib.makeBinPath [ universal-ctags ]}
'';
meta = with lib; {
doInstallCheck = true;
nativeInstallCheckInputs = [ versionCheckHook ];
versionCheckProgramArg = "--version";
passthru.updateScript = nix-update-script { };
meta = {
changelog = "https://github.com/netmute/ctags-lsp/releases/tag/v${version}";
description = "LSP implementation using universal-ctags as backend";
homepage = "https://github.com/netmute/ctags-lsp";
license = licenses.mit;
license = lib.licenses.mit;
mainProgram = "ctags-lsp";
maintainers = with maintainers; [ voronind ];
maintainers = with lib.maintainers; [ voronind ];
};
}