feat: add remote-installer package and silence dk1-iso warnings

This commit is contained in:
Bladesy 2025-05-01 16:11:21 +01:00
parent e2d298ad67
commit 47571c2535
6 changed files with 90 additions and 1 deletions

View File

@ -1,3 +1,4 @@
{pkgs}: { {pkgs}: {
write-iso = pkgs.callPackage ./write-iso.nix {}; write-iso = pkgs.callPackage ./write-iso.nix {};
install-remote = pkgs.callPackage ./install-remote.nix {};
} }

View File

@ -0,0 +1,4 @@
{remote-installer}: {
type = "app";
program = "${remote-installer}/bin/remote-installer";
}

View File

@ -79,6 +79,7 @@
users = { users = {
root = { root = {
isSystemUser = true; isSystemUser = true;
hashedPassword = null;
hashedPasswordFile = config.sops.secrets.root-password.path; hashedPasswordFile = config.sops.secrets.root-password.path;
openssh.authorizedKeys.keys = with lib.sshKeys; [ openssh.authorizedKeys.keys = with lib.sshKeys; [
lp1.user lp1.user
@ -88,13 +89,17 @@
user = { user = {
isNormalUser = true; isNormalUser = true;
extraGroups = ["wheel"]; extraGroups = ["wheel"];
hashedPassword = null;
hashedPasswordFile = config.sops.secrets.user-password.path; hashedPasswordFile = config.sops.secrets.user-password.path;
openssh.authorizedKeys.keys = with lib.sshKeys; [ openssh.authorizedKeys.keys = with lib.sshKeys; [
lp1.user lp1.user
lp2.user lp2.user
]; ];
}; };
nixos.hashedPasswordFile = config.sops.secrets.user-password.path; nixos = {
hashedPassword = null;
hashedPasswordFile = config.sops.secrets.user-password.path;
};
}; };
}; };

View File

@ -3,4 +3,5 @@
my-site = pkgs.callPackage ./my-site {}; my-site = pkgs.callPackage ./my-site {};
iso-writer = pkgs.callPackage ./iso-writer {}; iso-writer = pkgs.callPackage ./iso-writer {};
dk1-iso = pkgs.callPackage ./dk1-iso {}; dk1-iso = pkgs.callPackage ./dk1-iso {};
remote-installer = pkgs.callPackage ./remote-installer {};
} }

View File

@ -0,0 +1,28 @@
{
lib,
stdenvNoCC,
makeWrapper,
coreutils,
nixos-anywhere,
}: let
inherit (lib) makeBinPath;
runtimeInputs = [
coreutils
nixos-anywhere
];
in
stdenvNoCC.mkDerivation {
name = "remote-installer";
src = ./src;
nativeBuildInputs = [makeWrapper];
buildInputs = runtimeInputs;
installPhase = ''
mkdir -p $out/bin
cp $src/remote-installer.sh $out/bin/remote-installer
chmod +x $out/bin/remote-installer
'';
postFixup = ''
wrapProgram $out/bin/remote-installer \
--set PATH ${makeBinPath runtimeInputs}
'';
}

View File

@ -0,0 +1,50 @@
#!/usr/bin/env bash
read -a arguments <<< "$@"
number_of_arguments="${#arguments[@]}"
arguments_last_index="$(expr $number_of_arguments - 1)"
for argument_index in $(seq 0 "$arguments_last_index")
do
argument="${arguments[argument_index]}"
next_argument_index="$(expr $argument_index + 1)"
next_argument="${arguments[next_argument_index]}"
case "$argument" in
--*)
name="${argument/--/}"
[ "$argument_index" -eq "$arguments_last_index" \
-o "${next_argument:0:2}" = "--" ] \
&& declare "$name=$name"
;;
*)
value="$argument"
[ -n "$name" ] \
&& declare "$name=$value"
name=""
;;
esac
done
[ -n "$help" ] \
&& printf "Usage: remote-installer" \
&& printf " [--help]" \
&& printf "\n" \
&& printf "Install a NixOS configuration remotely." \
&& printf "\n" \
&& exit
[ -z "$flake_address" ] \
&& protocol="git+https" \
&& gitea="gitea.dylanblades.com" \
&& repository="Bladesy/nixos-config" \
&& flake_address="$protocol://$gitea/$repository"
[ -z "$host_name" ] \
&& printf "host_name not provided.\n" \
&& exit
[ -z "$host_address" ] \
&& printf "host_address not provided.\n" \
&& exit
nixos-anywhere \
--disko-mode disko \
--flake "$flake_address#$host_name" \
--target-host "root@$host_address"