Compare commits
No commits in common. "6d0e1c405f9d09181d6dd1547216b415f8456c15" and "85fa80c04fcfc997af5af9b77562486a8ef93c8f" have entirely different histories.
6d0e1c405f
...
85fa80c04f
2 changed files with 33 additions and 43 deletions
|
@ -10,15 +10,14 @@ function runActionSetup -V dir
|
||||||
and runHook prepareNix || installNixPkgs
|
and runHook prepareNix || installNixPkgs
|
||||||
|
|
||||||
and echo "Flagging repository as safe..."
|
and echo "Flagging repository as safe..."
|
||||||
and sudo git config --system --add safe.directory (realpath -m "$(status dirname)/../..")
|
and sudo git config --system --add safe.directory (realpath "$(status dirname)/../..")
|
||||||
and runHook actionPreRun || true
|
and runHook actionPreRun || true
|
||||||
end
|
end
|
||||||
|
|
||||||
function runActionConfigure -V dir
|
function runActionConfigure
|
||||||
and if [ -z "$CONFIG_NAME" ]
|
and if [ -z "$CONFIG_NAME" ]
|
||||||
source "$dir/settings.fish"
|
|
||||||
selectProfile config
|
selectProfile config
|
||||||
set -gx CONFIG_NAME "$config"
|
set -x CONFIG_NAME "$config"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -38,44 +37,39 @@ function runAction -V dir
|
||||||
end
|
end
|
||||||
|
|
||||||
function runSetupUserAction -V dir
|
function runSetupUserAction -V dir
|
||||||
source "$dir/settings.fish"
|
if [ (id -u) -eq 0 ]
|
||||||
runActionSetup
|
|
||||||
runActionConfigure
|
|
||||||
set -l env "CONFIG_NAME=$CONFIG_NAME"
|
|
||||||
set -l name (getOSConfig setupUser.name)
|
|
||||||
|
|
||||||
if [ "$USER" != "$name" ]
|
|
||||||
set -l cmdline (cat /proc/$fish_pid/cmdline | string split0)
|
set -l cmdline (cat /proc/$fish_pid/cmdline | string split0)
|
||||||
|
|
||||||
if [ (id -u) -ne 0 ]
|
if [ -z "$TMUX" ]
|
||||||
sudo --set-home --preserve-env $cmdline
|
runActionSetup
|
||||||
|
tmux new-session -e "CONFIG_NAME=$CONFIG_NAME" $cmdline
|
||||||
else
|
else
|
||||||
if [ -z "$TMUX" ]
|
source "$dir/settings.fish"
|
||||||
tmux new-session -e "$env" $cmdline
|
runActionConfigure
|
||||||
else
|
set -l sudoConfig "/etc/sudoers.d/PortValhalla"
|
||||||
set -l sudoConfig "/etc/sudoers.d/PortValhalla"
|
set -l name (getOSConfig setupUser.name)
|
||||||
|
|
||||||
begin
|
and begin
|
||||||
echo "Creating setup user"
|
echo "Creating setup user"
|
||||||
|
|
||||||
and useradd \
|
and useradd \
|
||||||
--comment "PortValhalla Setup User" \
|
--comment "PortValhalla Setup User" \
|
||||||
--system \
|
--system \
|
||||||
--groups nix-users \
|
--no-user-group \
|
||||||
--create-home \
|
--groups nix-users \
|
||||||
--uid (getOSConfig setupUser.id --json) \
|
--create-home \
|
||||||
"$name"
|
--uid (getOSConfig setupUser.id --json) \
|
||||||
|
"$name"
|
||||||
and begin
|
|
||||||
echo "$name ALL=(ALL:ALL) NOPASSWD: ALL"
|
|
||||||
end >"$sudoConfig"
|
|
||||||
|
|
||||||
and sudo --preserve-env --set-home --user "$name" $cmdline
|
|
||||||
disposeAction
|
|
||||||
rm "$sudoConfig"
|
|
||||||
userdel -rf "$name"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
and begin
|
||||||
|
echo "$name ALL=(ALL:ALL) NOPASSWD: ALL"
|
||||||
|
end >"$sudoConfig"
|
||||||
|
|
||||||
|
and sudo --preserve-env --set-home --user "$name" $cmdline
|
||||||
|
disposeAction
|
||||||
|
rm "$sudoConfig"
|
||||||
|
userdel -rf "$name"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
$argv
|
$argv
|
||||||
|
|
|
@ -3,14 +3,10 @@ begin
|
||||||
set -l config "$dir/config.fish"
|
set -l config "$dir/config.fish"
|
||||||
set nixPkgsDir "/nix/var/nix/profiles/per-user/root/channels/nixpkgs"
|
set nixPkgsDir "/nix/var/nix/profiles/per-user/root/channels/nixpkgs"
|
||||||
|
|
||||||
function __isNixModule -a path
|
|
||||||
nix-instantiate --eval --expr "{ path }: import path" --argstr path "$path" &>/dev/null
|
|
||||||
end
|
|
||||||
|
|
||||||
function downloadNixPkgs -V config
|
function downloadNixPkgs -V config
|
||||||
source "$config"
|
source "$config"
|
||||||
|
|
||||||
if ! __isNixModule "$nixPkgsCache"
|
if [ ! -d "$nixPkgsCache" ]
|
||||||
mkdir -p "$nixPkgsCache"
|
mkdir -p "$nixPkgsCache"
|
||||||
and git clone https://github.com/NixOS/nixpkgs.git --depth=1 -b "$nixPkgsVersion" "$nixPkgsCache"
|
and git clone https://github.com/NixOS/nixpkgs.git --depth=1 -b "$nixPkgsVersion" "$nixPkgsCache"
|
||||||
and rm -rf "$nixPkgsCache/.git"
|
and rm -rf "$nixPkgsCache/.git"
|
||||||
|
@ -20,8 +16,8 @@ begin
|
||||||
function installNixPkgs -V config -V nixPkgsDir
|
function installNixPkgs -V config -V nixPkgsDir
|
||||||
source "$config"
|
source "$config"
|
||||||
|
|
||||||
if ! __isNixModule "$nixPkgsDir"
|
if [ ! -d "$nixPkgsDir" ]
|
||||||
if ! __isNixModule "$nixPkgsCache"
|
if [ ! -d "$nixPkgsCache" ]
|
||||||
downloadNixPkgs
|
downloadNixPkgs
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue