Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

services.lorri.enable creates a service that doesn't see my channels #1265

Closed
NobbZ opened this issue May 24, 2020 · 17 comments
Closed

services.lorri.enable creates a service that doesn't see my channels #1265

NobbZ opened this issue May 24, 2020 · 17 comments

Comments

@NobbZ
Copy link
Contributor

NobbZ commented May 24, 2020

The lorri daemon started through the created service uses the systems channel (20.03) rather than my users (unstable).

If though I temporarily disable the systemd managed lorri daemon and start one in a shell, this deamon uses the correct channel.

@Kloenk
Copy link
Member

Kloenk commented May 24, 2020

Do you mean nixpkgs channel? Did you see the option home-manager.useGlobalPkgs under nixos? or are you not using nixos?

@NobbZ
Copy link
Contributor Author

NobbZ commented May 24, 2020

I'm on nixOS, though manage my HM "per user" in home.nix, not as a module in my configuration.nix.

@NobbZ
Copy link
Contributor Author

NobbZ commented May 24, 2020

And yes, I'm talking about nixpkgs channel.

Under "normal" circumstances I access the systems channel as nixos, the users channel as nixpkgs. nix-channels --list doesn't even tell me anything about the nixos one:

home-manager https://github.com/rycee/home-manager/archive/master.tar.gz
nixpkgs https://nixos.org/channels/nixos-unstable

@Kloenk
Copy link
Member

Kloenk commented May 24, 2020

Could you please try to exchange your home-manager with this one? https://github.com/kloenk/home-manager/archive/lorri-env.tar.gz. Maybe that will work

@rycee
Copy link
Member

rycee commented May 24, 2020

I imagine this is related to NIX_PATH not being imported into the systemd user session. You can try adding

systemd.user.services.lorri.Service.Environment = [ "NIX_PATH=…" ];

where is the output of echo $NIX_PATH in a shell.

@Kloenk
Copy link
Member

Kloenk commented May 24, 2020

You could of course directly set it in the home.nix file, I forgot. my patched home-manager version does the same.

To make in dynamic (and impure) you can use ${builtins.getEnv "NIX_PATH"} as the NIX_PATH

@NobbZ
Copy link
Contributor Author

NobbZ commented May 25, 2020

Thanks, adding to systemd.user.services.lorri.Service.Environment seems to do the trick.

Perhaps this can be abstracted behind another option?

PS: Feel free to close if you consider that abstraction a "wont-fix".

@Kloenk
Copy link
Member

Kloenk commented May 26, 2020

A own option for this would be great. It would not destroy the current setting of the environment, and also we could default to a sane option like the default path of channels. This would make it all pure, if we don't have to use builtins.readEnv. Will see if a have the time to create a PR.

Are there other services which needs this environment variable? Then we should make it a global option

@rycee
Copy link
Member

rycee commented May 26, 2020

I suspect the best solution would be set NIX_PATH using PAM instead of in the shell, which would avoid the need for a lorri specific solution. The NixOS setup does set it with PAM it omits the ~/.nix-defexpr/channels directory for some reason and only includes the system level ones.

Alternatively, I think one could use environment.d.

@Kloenk
Copy link
Member

Kloenk commented May 27, 2020

Is PAM forwarded into systemd?

@PierreR
Copy link

PierreR commented Jun 3, 2020

To use the systemd.user.services.lorri.service.environment workaround do I need to patch the lorri service module locally (by copy/pasting it) ?

@PierreR
Copy link

PierreR commented Jun 3, 2020

Anyhow, doing so, works for me.
That issue hit me hard ... My overlays defined in NIX_PATH was silently ignored in Lorri ...

@PierreR
Copy link

PierreR commented Jun 3, 2020

@rycee Do you thing a PR to pass the NIX_PATH as a parameter to modules/services/lorri.nix would be useful ?

@Kloenk
Copy link
Member

Kloenk commented Jun 3, 2020

@rycee Do you thing a PR to pass the NIX_PATH as a parameter to modules/services/lorri.nix would be useful ?

I think it is a better approach to run systemctl --user set-environment NIX_PATH=$NIX_PATH somewhere, so this config is not set into the nix store.

@rycee
Copy link
Member

rycee commented Jun 3, 2020

@Kloenk Yeah, I believe PAM sets the environment variables before the systemd user session starts. You should see the values it sets by running

$ systemctl --user show-environment | grep NIX_PATH

So I suspect the best course of action would be to see why NixOS doesn't add the user's channels to NIX_PATH using PAM. And for non-NixOS users to see if it would work to set up NIX_PATH using pam.sessionVariables.

@DamienCassou
Copy link
Contributor

@rycee I tried what you suggest but it fails:

$ systemctl --user show-environment | grep NIX_PATH
NIX_PATH=/home/cassou/.nix-defexpr/channels

$ cat ~/.pam_environment 
NIX_PATH OVERRIDE="/home/cassou/Documents/projects/nix-system"

@stale
Copy link

stale bot commented Apr 28, 2021

Thank you for your contribution! I marked this issue as stale due to inactivity. If this remains inactive for another 7 days, I will close this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

If you have nothing of substance to add, please refrain from commenting and allow the bot close the issue. Also, don't be afraid to manually close an issue, even if it holds valuable information.

Closed issues stay in the system for people to search, read, cross-reference, or even reopen--nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

@stale stale bot added the status: stale label Apr 28, 2021
@stale stale bot closed this as completed May 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants