aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChloƩ Vulquin <code@toast.bunkerlabs.net>2026-01-24 13:16:05 +0100
committerChloƩ Vulquin <code@toast.bunkerlabs.net>2026-01-24 13:16:05 +0100
commit001e6495c3529cef0179b0b0cfba626853ebb9e8 (patch)
tree73e84e2be58e2028b88464aa113d038ed59a6a6e
parentinitial import (diff)
nitro@: simplify socket directory handling, run in new process group
Now instead of worrying about SOCKET_PREFIX and SOCKDIR and so on, you just set NITRO_SOCK to where you want it to be. It does need to be in a nitro-specific directory for notify things, but you shouldn't overwriting this most of the time anyway. As for the process group, given the main usage (user services), this seems perfectly reasonable.
-rw-r--r--nitro@/README.md14
-rw-r--r--nitro@/common5
-rwxr-xr-xnitro@/run2
3 files changed, 10 insertions, 11 deletions
diff --git a/nitro@/README.md b/nitro@/README.md
index bf94a96..d042053 100644
--- a/nitro@/README.md
+++ b/nitro@/README.md
@@ -13,14 +13,12 @@ Here are the settings you can set / may want to set:
example. It is also exported, so they may be affected by this.
* `$CONFDIR`: the nitro config dirctory for the user (equivalent of
/etc/nitro). Defaults to `$HOME/.config/nitro`.
-* `$SOCKET_PREFIX`: where to place the user's runtime directory, if
- any. Basically the `/run/user` prefix for default `$SOCKDIR`. Note that this
- is sensitive! `unitroctl` won't know if you change this, so changing this (or
- `$SOCKDIR`) will require that the user manually set `$NITRO_SOCK`.
-* `$SOCKDIR`: the parent directory for nitro's runtime directory. For example,
- if `$NITRO_SOCK` will be `/foo/bar/nitro/nitro.sock`, then this is
- `/foo/bar`. `$NITRO_SOCK` is not configurable (though you can always edit it
- in!). Defaults to `${SOCKET_PREFIX:-/run/user}/$UID`.
+* `$NITRO_SOCK`: where to place nitro's socket. Be very careful
+ setting this. Defaults to `/run/user/$UID/nitro/nitro.sock`, and
+ this is what `unitroctl` uses as well. The setup script will ensure
+ that the parent's parent directory (in this case `/run/user/$UID`
+ exists, if not creating it belonging to the user with 0700
+ permissions (as per `XDG_RUNTIME_DIR`).
* `$CHPSTUSER`: what to pass to chpst's `-u` argument. Defaults to `:$(id -u
$USER):$(id -G $USER)`, so for UID 1000 GID 1000 supplementary groups 1, 2, 3,
this will be `:1000:1000:1:2:3`. Importantly, this is not sanity-checked, so
diff --git a/nitro@/common b/nitro@/common
index bd0e300..8ebe3aa 100644
--- a/nitro@/common
+++ b/nitro@/common
@@ -11,6 +11,7 @@ GID=$(id -g "$USER")
: ${HOME:=$(getent passwd "$USER" | cut -d: -f6)} \
${CONFDIR:="$HOME"/.config/nitro} \
${CHPSTUSER:=:$UID:$(id -G "$USER" | tr ' ' ':')} \
- ${SOCKDIR:=${SOCKET_PREFIX:-/run/user}/$UID}
+ ${NITRO_SOCK:=/run/user/$UID/nitro/nitro.sock}
-export USER HOME NITRO_SOCK="$SOCKDIR"/nitro/nitro.sock
+SOCKDIR=$(dirname "$(dirname "$NITRO_SOCK")")
+export USER HOME NITRO_SOCK
diff --git a/nitro@/run b/nitro@/run
index d368468..09526ce 100755
--- a/nitro@/run
+++ b/nitro@/run
@@ -4,4 +4,4 @@
USER="$1"
. ./common
-exec chpst -u "$CHPSTUSER" nitro "$CONFDIR"
+exec chpst -P -u "$CHPSTUSER" nitro "$CONFDIR"