2024-07-13 13:12:35 +00:00
|
|
|
#!/bin/env fish
|
|
|
|
set -l dir (status dirname)
|
|
|
|
source "$dir/../Scripts/config.fish"
|
|
|
|
source "$dir/../Scripts/hooks.fish"
|
|
|
|
|
|
|
|
function copyNixConfig -V dir
|
|
|
|
set -l configFile ~/.config/nix/nix.conf
|
|
|
|
mkdir -p (dirname "$configFile")
|
|
|
|
cp "$dir/../../../archiso/airootfs/root/.config/nix/nix.conf" "$configFile"
|
|
|
|
end
|
|
|
|
|
|
|
|
if [ (id -u) -eq 0 ]
|
2024-07-15 11:15:57 +00:00
|
|
|
copyNixConfig
|
2024-07-13 13:12:35 +00:00
|
|
|
set -l name (getConfig valhalla.setupUser.name)
|
|
|
|
set -l sudoConfig "/etc/sudoers.d/PortValhalla"
|
|
|
|
|
|
|
|
runHook createUser || \
|
|
|
|
begin
|
|
|
|
useradd \
|
|
|
|
--comment "PortValhalla setup user" \
|
|
|
|
--system \
|
|
|
|
--no-user-group \
|
2024-07-15 11:17:00 +00:00
|
|
|
--groups wheel,nix-users \
|
2024-07-13 13:12:35 +00:00
|
|
|
--create-home \
|
|
|
|
--uid (getConfig valhalla.setupUser.id --json) \
|
|
|
|
"$name"
|
|
|
|
end
|
|
|
|
|
|
|
|
and begin
|
|
|
|
echo "$name ALL=(ALL:ALL) NOPASSWD: ALL"
|
|
|
|
end > "$sudoConfig"
|
|
|
|
|
|
|
|
and sudo --preserve-env="CONFIG_MODULE" --user "$name" "$INSTALLER_SCRIPT"
|
|
|
|
rm "$sudoConfig"
|
2024-07-13 13:49:55 +00:00
|
|
|
userdel -r "$name"
|
2024-07-13 13:12:35 +00:00
|
|
|
else
|
2024-07-15 11:15:57 +00:00
|
|
|
copyNixConfig
|
2024-07-13 13:49:55 +00:00
|
|
|
runHook initialize || true
|
|
|
|
runHook installDrivers || true
|
|
|
|
runHook installOS || true
|
|
|
|
runHook installSoftware || true
|
|
|
|
runHook initializeConfig || true
|
|
|
|
runHook postInstall || true
|
2024-07-13 13:12:35 +00:00
|
|
|
end
|