From 84f0e8e1c5125b4258daec87d5e05f2e50a8786a Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sat, 13 Jul 2024 15:12:35 +0200 Subject: [PATCH] Create a common install script --- profiles/ManuSurface/Arch/install.fish | 5 ++++ profiles/ManuSurface/Arch/setup.fish | 2 +- scripts/Arch/OS/install.fish | 3 +++ scripts/Common/OS/install.fish | 36 ++++++++++++++++++++++++++ scripts/Common/OS/setup.fish | 7 +++++ 5 files changed, 52 insertions(+), 1 deletion(-) create mode 100755 profiles/ManuSurface/Arch/install.fish create mode 100644 scripts/Arch/OS/install.fish create mode 100644 scripts/Common/OS/install.fish 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..76ec845b --- /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 \