Create a common install script

This commit is contained in:
Manuel Thalmann 2024-07-13 15:12:35 +02:00
parent b43c8ae947
commit 84f0e8e1c5
5 changed files with 52 additions and 1 deletions

View file

@ -0,0 +1,5 @@
#!/bin/env fish
begin
set -l dir (status dirname)
source "$dir/../../../scripts/Arch/OS/install.fish"
end

View file

@ -8,7 +8,7 @@ begin
end end
function getInstallerScript -V dir -S function getInstallerScript -V dir -S
echo "$dir/install.sh" echo "$dir/install.fish"
end end
CONFIG_MODULE="$(status dirname)/config.nix" \ CONFIG_MODULE="$(status dirname)/config.nix" \

View file

@ -0,0 +1,3 @@
#!/bin/env fish
set -l dir (status dirname)
source "$dir/../../Common/OS/install.fish"

View file

@ -0,0 +1,36 @@
#!/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 ]
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 \
--groups wheel \
--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"
else
end

View file

@ -22,6 +22,13 @@ begin
and runHook setupOS || true and runHook setupOS || true
and runHook autologin || true and runHook autologin || true
# Copy `nixpkgs` channel
and begin
set -l channelDir /nix/var/nix/profiles/per-user/root/channels/nixpkgs
mkdir -p (dirname "$mountDir/$channelDir")
cp -r "$channelDir" "$mountDir/$channelDir"
end
and begin and begin
set -l script (string escape (getCloneFile (getInstallerScript))) set -l script (string escape (getCloneFile (getInstallerScript)))
printf %s\n \ printf %s\n \