Skip to content

fix(nix): make extraPackages actually work via per-user profile - #17047

Merged
alt-glitch merged 2 commits into
mainfrom
fix/extrapackages-per-user-profile
Apr 28, 2026
Merged

fix(nix): make extraPackages actually work via per-user profile#17047
alt-glitch merged 2 commits into
mainfrom
fix/extrapackages-per-user-profile

Conversation

@alt-glitch

Copy link
Copy Markdown
Collaborator

Context

#17030 deprecated extraPackages because packages added to the systemd service PATH weren't visible to terminal commands, skills, or cron jobs — the terminal backend's login-shell snapshot rebuilds PATH from NixOS system profiles, discarding the service PATH.

The deprecation told users to switch to environment.systemPackages, which works but is a sledgehammer — it pollutes every user's shell on the system. If you only need pandoc for the hermes agent, you shouldn't have to put it in the global profile.

The fix

Instead of deprecating, make extraPackages actually work. One line of logic:

(lib.mkIf (cfg.extraPackages != []) {
  users.users.${cfg.user}.packages = cfg.extraPackages;
})

This tells NixOS "the hermes user has these packages," which creates a per-user profile at /etc/profiles/per-user/hermes/bin. That path is already in the PATH that /etc/set-environment constructs:

PATH="$HOME/.nix-profile/bin:…:/etc/profiles/per-user/$USER/bin:…:/run/current-system/sw/bin"

The login-shell snapshot (bash -l -c 'export -p') picks this up, so terminal commands, skills, and cron jobs all see the packages. The systemd path line still includes them too for direct process access.

Why this works for system users

NixOS creates per-user profiles for any user with packages != [] — there's no isNormalUser filter. From nixos/modules/config/users-groups.nix:

environment.etc = mapAttrs' ()
  (filterAttrs (_: u: u.packages != [ ]) cfg.users);

Verification

Tested in a NixOS VM (nixos/lib runTest):

✔ /etc/profiles/per-user/hermes/bin exists
✔ hello and jq binaries present in per-user profile
✔ su - hermes -c 'which hello' → /etc/profiles/per-user/hermes/bin/hello
✔ su - hermes -c 'hello' → "Hello, world!"

Edge cases

  • createUser = false: users.users.<name>.packages is additive — doesn't require the module to own the user definition. Works fine.
  • Container mode: unaffected. extraPackages was always native-only (the systemd path line is inside !cfg.container.enable). The per-user profile lives on the host, not inside the container. No regression.

Changes

nix/nixosModules.nix

  • Replace deprecation warning block with per-user profile wiring
  • Update option description to reflect that it works everywhere now

website/docs/getting-started/nix-setup.md

#17030 deprecated extraPackages because it only set the systemd service
PATH, which the terminal backend's login-shell snapshot discards.

Instead of deprecating, fix it: set users.users.${cfg.user}.packages
so NixOS builds a per-user profile at /etc/profiles/per-user/hermes/bin.
This path is included in PATH by /etc/set-environment, which the login
shell sources, so the terminal backend's snapshot picks it up.

One line of actual logic:
  users.users.${cfg.user}.packages = cfg.extraPackages;

Verified in a NixOS VM test: su - hermes -c 'which hello' resolves
to /etc/profiles/per-user/hermes/bin/hello.

Reverts the deprecation warning and docs changes from #17030, restores
extraPackages as the recommended way to give the agent extra tools.

Container mode is unaffected — extraPackages was always native-only
(the systemd path line is inside !cfg.container.enable).
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists area/nix Nix flake, NixOS module, container packaging labels Apr 28, 2026
@qmx

qmx commented Apr 28, 2026

Copy link
Copy Markdown

❤️ this looks good, my only concern is making sure we're augmenting, not replacing the existing package list

@alt-glitch
alt-glitch marked this pull request as ready for review April 28, 2026 18:20
@alt-glitch
alt-glitch merged commit 4bf0e75 into main Apr 28, 2026
9 of 10 checks passed
@alt-glitch
alt-glitch deleted the fix/extrapackages-per-user-profile branch April 28, 2026 18:20
donald131 pushed a commit to donald131/hermes-agent that referenced this pull request May 2, 2026
…Research#17047)

* fix(nix): make extraPackages actually work — wire into per-user profile

NousResearch#17030 deprecated extraPackages because it only set the systemd service
PATH, which the terminal backend's login-shell snapshot discards.

Instead of deprecating, fix it: set users.users.${cfg.user}.packages
so NixOS builds a per-user profile at /etc/profiles/per-user/hermes/bin.
This path is included in PATH by /etc/set-environment, which the login
shell sources, so the terminal backend's snapshot picks it up.

One line of actual logic:
  users.users.${cfg.user}.packages = cfg.extraPackages;

Verified in a NixOS VM test: su - hermes -c 'which hello' resolves
to /etc/profiles/per-user/hermes/bin/hello.

Reverts the deprecation warning and docs changes from NousResearch#17030, restores
extraPackages as the recommended way to give the agent extra tools.

Container mode is unaffected — extraPackages was always native-only
(the systemd path line is inside !cfg.container.enable).

* nix: clarify additive merge semantics for extraPackages user profile

---------

Co-authored-by: Siddharth Balyan <daimon@noreply.github.com>
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
…Research#17047)

* fix(nix): make extraPackages actually work — wire into per-user profile

NousResearch#17030 deprecated extraPackages because it only set the systemd service
PATH, which the terminal backend's login-shell snapshot discards.

Instead of deprecating, fix it: set users.users.${cfg.user}.packages
so NixOS builds a per-user profile at /etc/profiles/per-user/hermes/bin.
This path is included in PATH by /etc/set-environment, which the login
shell sources, so the terminal backend's snapshot picks it up.

One line of actual logic:
  users.users.${cfg.user}.packages = cfg.extraPackages;

Verified in a NixOS VM test: su - hermes -c 'which hello' resolves
to /etc/profiles/per-user/hermes/bin/hello.

Reverts the deprecation warning and docs changes from NousResearch#17030, restores
extraPackages as the recommended way to give the agent extra tools.

Container mode is unaffected — extraPackages was always native-only
(the systemd path line is inside !cfg.container.enable).

* nix: clarify additive merge semantics for extraPackages user profile

---------

Co-authored-by: Siddharth Balyan <daimon@noreply.github.com>
dannyJ848 pushed a commit to dannyJ848/hermes-agent that referenced this pull request May 17, 2026
…Research#17047)

* fix(nix): make extraPackages actually work — wire into per-user profile

NousResearch#17030 deprecated extraPackages because it only set the systemd service
PATH, which the terminal backend's login-shell snapshot discards.

Instead of deprecating, fix it: set users.users.${cfg.user}.packages
so NixOS builds a per-user profile at /etc/profiles/per-user/hermes/bin.
This path is included in PATH by /etc/set-environment, which the login
shell sources, so the terminal backend's snapshot picks it up.

One line of actual logic:
  users.users.${cfg.user}.packages = cfg.extraPackages;

Verified in a NixOS VM test: su - hermes -c 'which hello' resolves
to /etc/profiles/per-user/hermes/bin/hello.

Reverts the deprecation warning and docs changes from NousResearch#17030, restores
extraPackages as the recommended way to give the agent extra tools.

Container mode is unaffected — extraPackages was always native-only
(the systemd path line is inside !cfg.container.enable).

* nix: clarify additive merge semantics for extraPackages user profile

---------

Co-authored-by: Siddharth Balyan <daimon@noreply.github.com>
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
…Research#17047)

* fix(nix): make extraPackages actually work — wire into per-user profile

NousResearch#17030 deprecated extraPackages because it only set the systemd service
PATH, which the terminal backend's login-shell snapshot discards.

Instead of deprecating, fix it: set users.users.${cfg.user}.packages
so NixOS builds a per-user profile at /etc/profiles/per-user/hermes/bin.
This path is included in PATH by /etc/set-environment, which the login
shell sources, so the terminal backend's snapshot picks it up.

One line of actual logic:
  users.users.${cfg.user}.packages = cfg.extraPackages;

Verified in a NixOS VM test: su - hermes -c 'which hello' resolves
to /etc/profiles/per-user/hermes/bin/hello.

Reverts the deprecation warning and docs changes from NousResearch#17030, restores
extraPackages as the recommended way to give the agent extra tools.

Container mode is unaffected — extraPackages was always native-only
(the systemd path line is inside !cfg.container.enable).

* nix: clarify additive merge semantics for extraPackages user profile

---------

Co-authored-by: Siddharth Balyan <daimon@noreply.github.com>
Seven74AI pushed a commit to Seven74AI/hermes-agent that referenced this pull request Jun 13, 2026
…Research#17047)

* fix(nix): make extraPackages actually work — wire into per-user profile

NousResearch#17030 deprecated extraPackages because it only set the systemd service
PATH, which the terminal backend's login-shell snapshot discards.

Instead of deprecating, fix it: set users.users.${cfg.user}.packages
so NixOS builds a per-user profile at /etc/profiles/per-user/hermes/bin.
This path is included in PATH by /etc/set-environment, which the login
shell sources, so the terminal backend's snapshot picks it up.

One line of actual logic:
  users.users.${cfg.user}.packages = cfg.extraPackages;

Verified in a NixOS VM test: su - hermes -c 'which hello' resolves
to /etc/profiles/per-user/hermes/bin/hello.

Reverts the deprecation warning and docs changes from NousResearch#17030, restores
extraPackages as the recommended way to give the agent extra tools.

Container mode is unaffected — extraPackages was always native-only
(the systemd path line is inside !cfg.container.enable).

* nix: clarify additive merge semantics for extraPackages user profile

---------

Co-authored-by: Siddharth Balyan <daimon@noreply.github.com>
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
…Research#17047)

* fix(nix): make extraPackages actually work — wire into per-user profile

NousResearch#17030 deprecated extraPackages because it only set the systemd service
PATH, which the terminal backend's login-shell snapshot discards.

Instead of deprecating, fix it: set users.users.${cfg.user}.packages
so NixOS builds a per-user profile at /etc/profiles/per-user/hermes/bin.
This path is included in PATH by /etc/set-environment, which the login
shell sources, so the terminal backend's snapshot picks it up.

One line of actual logic:
  users.users.${cfg.user}.packages = cfg.extraPackages;

Verified in a NixOS VM test: su - hermes -c 'which hello' resolves
to /etc/profiles/per-user/hermes/bin/hello.

Reverts the deprecation warning and docs changes from NousResearch#17030, restores
extraPackages as the recommended way to give the agent extra tools.

Container mode is unaffected — extraPackages was always native-only
(the systemd path line is inside !cfg.container.enable).

* nix: clarify additive merge semantics for extraPackages user profile

---------

Co-authored-by: Siddharth Balyan <daimon@noreply.github.com>
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
…Research#17047)

* fix(nix): make extraPackages actually work — wire into per-user profile

NousResearch#17030 deprecated extraPackages because it only set the systemd service
PATH, which the terminal backend's login-shell snapshot discards.

Instead of deprecating, fix it: set users.users.${cfg.user}.packages
so NixOS builds a per-user profile at /etc/profiles/per-user/hermes/bin.
This path is included in PATH by /etc/set-environment, which the login
shell sources, so the terminal backend's snapshot picks it up.

One line of actual logic:
  users.users.${cfg.user}.packages = cfg.extraPackages;

Verified in a NixOS VM test: su - hermes -c 'which hello' resolves
to /etc/profiles/per-user/hermes/bin/hello.

Reverts the deprecation warning and docs changes from NousResearch#17030, restores
extraPackages as the recommended way to give the agent extra tools.

Container mode is unaffected — extraPackages was always native-only
(the systemd path line is inside !cfg.container.enable).

* nix: clarify additive merge semantics for extraPackages user profile

---------

Co-authored-by: Siddharth Balyan <daimon@noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/nix Nix flake, NixOS module, container packaging P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants