Skip to content

services/turnstiled: init#22

Open
xZecora wants to merge 5 commits into
finix-community:mainfrom
xZecora:turnstiled
Open

services/turnstiled: init#22
xZecora wants to merge 5 commits into
finix-community:mainfrom
xZecora:turnstiled

Conversation

@xZecora

@xZecora xZecora commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

initial commit for the turnstiled service. currently very barebones

@aanderse

Copy link
Copy Markdown
Member

awesome! please hold off merging for a few days, i would like to share some related dinit work i have been doing so we can potentially integrate

@aanderse aanderse left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very cool! this will work so well with the dinit.services and dinit.user.services options i have written!

Comment thread modules/services/turnstile/package.nix Outdated
];

patches = [
./patch.diff

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/run/current-system/sw/bin/dinit-monitor is less than ideal, especially if we're already linking against dinit - how about:

postPatch = ''
  substituteInPlace backend/dinit \
    --replace-fail '/usr/bin/dinit-monitor' '${lib.getExe' dinit "dinit-monitor"}'
'';

and if we're doing that we could inline the patch to meson.build to simplify (ie. drop patch.diff):

  substituteInPlace meson.build \
    --replace-fail "get_option('prefix'), get_option('sysconfdir'), 'turnstile'" "'/etc', 'turnstile'"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, didn't think of this while I was writing it. Changed in latest commit.

"-Ddefault_backend=dinit"
"-Ddinit=enabled"
"-Dstatedir=/var/lib/turnstiled"
"-Dpam_moddir=./pam"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that right? 🤔

mesonFlags = [
"-Ddefault_backend=dinit"
"-Ddinit=enabled"
"-Dstatedir=/var/lib/turnstiled"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't that already the value? if not, sounds like we need to modify localstatedir instead?

Comment thread modules/services/turnstile/package.nix
Comment thread modules/services/turnstile/package.nix Outdated

stdenv.mkDerivation {
pname = "turnstile";
version = "0-unstable-2025-12-15";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worth pinning to version 0.1.11, only one irrelevant commit off this... makes it easier to upstream into nixpkgs, which should definitely be a goal of ours

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, pinned it in latest commit.

Comment thread modules/services/turnstile/default.nix Outdated
Comment on lines +151 to +155
enableGraphicalMonitor = mkOption {
type = bool;
default = false;
description = "Whether or not to monitor environment changes to DISPLAY and WAYLAND_DISPLAY variables. Currently requires manually adding `dinitctl setenv VAR=$VAR`to any startup scripts for your graphical environment to function.";
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure we should actually have this as an option at all... and if we should, then it should be configured via services.turnstiled.package = pkgs.turnstiled.override { enableGraphicalMonitor = false; }; or something along those lines

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm relatively neutral on the idea, the main purpose of the option was to allow an immediately obvious way to disable them for people looking at the options from a non-source code position. Like I said though, no strong opinion, happy to remove if you think its best to make it transparent.

Decision might also depend on how we resolve this comment so I figured I'd leave it unchanged for now.

Comment thread modules/services/turnstile/default.nix Outdated
Comment on lines +133 to +149
service_dir = mkOption {
type = str;
default = "$HOME/.config/dinit.d";
description = "Users service dir for `turnstile`'s `dinit` backend. This should include a way to differentiate per user unless all users have identical services.";
};

boot_dir = mkOption {
type = str;
default = "${cfg.dinit.service_dir}/boot.d";
description = "Users service boot dir for `turnstile`'s `dinit` backend. This should include a way to differentiate per user unless all users have identical services.";
};

system_boot_dir = mkOption {
type = path;
default = "/usr/lib/dinit.d/user/boot.d";
description = "Systems service boot dir for `turnstile`'s `dinit` backend.";
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we please put these under a settings key (key, not option)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure, makes a lot of sense.

Comment on lines +184 to +191
"turnstile/backend/dinit.conf".text = ''
boot_dir="${cfg.dinit.boot_dir}"
system_boot_dir="${cfg.dinit.system_boot_dir}"
services_dir1="${cfg.dinit.service_dir}"
services_dir2="/etc/dinit.d/user"
services_dir3="/usr/local/lib/dinit.d/user"
services_dir4="/usr/lib/dinit.d/user"
'';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"turnstile/backend/dinit.conf".text = ''
boot_dir="${cfg.dinit.boot_dir}"
system_boot_dir="${cfg.dinit.system_boot_dir}"
services_dir1="${cfg.dinit.service_dir}"
services_dir2="/etc/dinit.d/user"
services_dir3="/usr/local/lib/dinit.d/user"
services_dir4="/usr/lib/dinit.d/user"
'';
"turnstile/backend/dinit.conf".text = (pkgs.formats.keyValue { }).generate "dinit.conf" cfg.dinit.settings;

see comments above about adding services.turnstiled.dinit.settings option

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving unresolved because I think I want to change the services.turnstiled.dinit.settings.service_dir option to allow a list so users can change services_dir 2-4 and beyond. Makes the conversion a bit more complicated but I will definitely look into this

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as much as i don't like opinionated modules... yes, that is so so so much better 😅

please 🙇‍♂️

Comment thread modules/services/turnstile/default.nix Outdated
Comment on lines +42 to +48
settings =
with lib;
mkOption {
type =
with types;
submodule {
options = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
settings =
with lib;
mkOption {
type =
with types;
submodule {
options = {
settings = {

not everything needs to be an option - in this case there is no actual advantage, and an extra submodule evaluation has to occur, so i would drop the mkOption and go with a raw attribute set for settings in this case

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unoptioned settings

Comment thread modules/services/turnstile/default.nix Outdated
Comment on lines +29 to +34

configFile = lib.mkOption {
type = lib.types.path;
default = "/etc/turnstiled.conf";
description = "Configuration file location for tunrstiled";
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
configFile = lib.mkOption {
type = lib.types.path;
default = "/etc/turnstiled.conf";
description = "Configuration file location for tunrstiled";
};

unused, drop it 👍

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dropped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants