diff --git a/profiles/ManuSurface/Arch/install.fish b/profiles/ManuSurface/Arch/install.fish new file mode 100755 index 00000000..365b26ee --- /dev/null +++ b/profiles/ManuSurface/Arch/install.fish @@ -0,0 +1,5 @@ +#!/bin/env fish +begin + set -l dir (status dirname) + source "$dir/../../../scripts/Arch/OS/install.fish" +end diff --git a/profiles/ManuSurface/Arch/setup.fish b/profiles/ManuSurface/Arch/setup.fish index 952603dd..5f5d201d 100755 --- a/profiles/ManuSurface/Arch/setup.fish +++ b/profiles/ManuSurface/Arch/setup.fish @@ -8,7 +8,7 @@ begin end function getInstallerScript -V dir -S - echo "$dir/install.sh" + echo "$dir/install.fish" end CONFIG_MODULE="$(status dirname)/config.nix" \ diff --git a/scripts/Arch/OS/install.fish b/scripts/Arch/OS/install.fish new file mode 100644 index 00000000..314c518d --- /dev/null +++ b/scripts/Arch/OS/install.fish @@ -0,0 +1,3 @@ +#!/bin/env fish +set -l dir (status dirname) +source "$dir/../../Common/OS/install.fish" diff --git a/scripts/Common/OS/install.fish b/scripts/Common/OS/install.fish new file mode 100644 index 00000000..dc9d063b --- /dev/null +++ b/scripts/Common/OS/install.fish @@ -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 diff --git a/scripts/Common/OS/setup.fish b/scripts/Common/OS/setup.fish index 9c64a9cf..c4d53564 100644 --- a/scripts/Common/OS/setup.fish +++ b/scripts/Common/OS/setup.fish @@ -22,6 +22,13 @@ begin and runHook setupOS || 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 set -l script (string escape (getCloneFile (getInstallerScript))) printf %s\n \