Skip to content

Add service ordering - #3

Open
Prince213 wants to merge 2 commits into
ngi-nix:ngi-patchesfrom
Prince213:push-mupuzxrvwlkp
Open

Add service ordering#3
Prince213 wants to merge 2 commits into
ngi-nix:ngi-patchesfrom
Prince213:push-mupuzxrvwlkp

Conversation

@Prince213

Copy link
Copy Markdown
Member

Related-to: ngi-nix/forge#173

@imincik

imincik commented Apr 13, 2026

Copy link
Copy Markdown

I this implementation complete for both containers and NixOS system ?

@Prince213
Prince213 changed the base branch from master to ngi-patches April 16, 2026 07:14
@imincik

imincik commented Apr 17, 2026

Copy link
Copy Markdown

@Prince213 , are you able to resolve the conflict ? Thanks

@eljamm eljamm left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm testing this in ngi-nix/forge#287, but the ordering doesn't seem to be taking effect.

Comment thread nix/modules/nimi/ordering.nix Outdated
Comment on lines +7 to +11
referencedDeps = lib.pipe config.ordering [
builtins.attrValues
(map (o: o.after))
lib.flatten
];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

not used?

Comment thread nix/modules/nimi/ordering.nix Outdated
let
inherit (lib) mkOption types;

serviceNames = builtins.attrNames config.services;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

prefer lib instead of builtins, since the latter is tied to the Nix implementation, whereas the former is fixed to the current Nixpkgs.

Comment thread src/config.rs
pub struct ServiceOrdering {
/// Services that must have started before this one is spawned
#[serde(default)]
pub after: Vec<String>,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

would adding before complicate things or would it be fine?

Comment thread src/process_manager.rs
self.detect_cycles()
}

/// Detect cycles in the ordering graph via iterative DFS.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe we can explain what this means and does in more details? both in general and how it related to service ordering

@imincik

imincik commented Apr 20, 2026

Copy link
Copy Markdown

@Prince213 , @eljamm is reporting that ordering doesn't work/doesn't have any effect . Are you able to help us ?

Introduce `readyCheck` on services (a polled executable that exits 0
when ready) and a corresponding `afterReady` ordering option that blocks
a service's spawn until all listed dependencies pass their readiness
check.

Adds per-service `ready` watch channels alongside the existing spawn
channels, a configurable timeout (default 30s), and NixOS assertions
ensuring `afterReady` targets always declare a `readyCheck`.
@eljamm
eljamm force-pushed the push-mupuzxrvwlkp branch from 71ee75d to f578468 Compare April 22, 2026 10:59

@imincik imincik left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Concerns regarding consistency of implementation with systemd where raised during our weekly meeting. Let's have a second look and improve this feature where needed.

@imincik

imincik commented Apr 25, 2026

Copy link
Copy Markdown

@eljamm , I think, first design choice we need to make here is whether we want to leave ordering orchestration on nimi on all runtimes OR we delegate it to some other tools if they exist on particular runtime (e.g. systemd on nixos runtime).

Your decision to manage ordering on NixOS with systemd looks correct to me. But in this case, we should implement Nimi's ordering (for containers) as much as consistent with systemd as possible. We don't need to support all systemd features, we should choose only some limited subset.

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.

Nimi: implement services ordering for containers and nixos

3 participants