nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
7.07k stars 1.82k forks source link

bug: synapse-admin causes nixos module build to fail, needs improved error message #2889

Open h7x4 opened 2 years ago

h7x4 commented 2 years ago

Is there an existing issue for this?

Issue description

My configuration is set up with a nix flake outputting all NixOS configurations, and home-manager embedded into the configurations through the home-manager NixOS module.

Upon adding some new packages to home.packages, I encountered this problem:

Error output ``` warning: the following units failed: home-manager-h7x4.service × home-manager-h7x4.service - Home Manager environment for h7x4 Loaded: loaded (/etc/systemd/system/home-manager-h7x4.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Tue 2022-04-12 01:59:36 CEST; 17ms ago Process: 992009 ExecStart=/nix/store/kcqdnwk2lhg4mgbg5jcr1mjqwrnr4cpl-hm-setup-env /nix/store/70aqrydgrq2k7ksxv9nf7ai7izaz00dd-home-manager-generation (code=exited, status=1/FAILURE) Main PID: 992009 (code=exited, status=1/FAILURE) IP: 534B in, 309B out CPU: 149ms Apr 12 01:59:36 kasei hm-activate-h7x4[992200]: Perhaps there is a conflict with a package that was installed using Apr 12 01:59:36 kasei hm-activate-h7x4[992200]: 'nix-env -i'? Try running Apr 12 01:59:36 kasei hm-activate-h7x4[992200]: nix-env -q Apr 12 01:59:36 kasei hm-activate-h7x4[992200]: and if there is a conflicting package you can remove it with Apr 12 01:59:36 kasei hm-activate-h7x4[992200]: nix-env -e {package name} Apr 12 01:59:36 kasei hm-activate-h7x4[992200]: Then try activating your Home Manager configuration again. Apr 12 01:59:36 kasei systemd[1]: home-manager-h7x4.service: Main process exited, code=exited, status=1/FAILURE Apr 12 01:59:36 kasei systemd[1]: home-manager-h7x4.service: Failed with result 'exit-code'. Apr 12 01:59:36 kasei systemd[1]: Failed to start Home Manager environment for h7x4. Apr 12 01:59:36 kasei systemd[1]: home-manager-h7x4.service: Consumed 149ms CPU time, received 534B IP traffic, sent 309B IP traffic. warning: error(s) occurred while switching to the new configuration ```

After messing around with nix-env and nix profile, i found the offending package to be synapse-admin. It exports a file called manifest.json directly into the nix-profile root, which makes the nix profile command crash with this error:

error: profile manifest '/nix/var/nix/profiles/per-user/h7x4/profile/manifest.json' has unsupported version 0

I assume it confused manifest.json with manifest.nix.

I was also unable to remove the package directly from the config and do a rebuild. I had to rollback to a generation without the package, and then do a rebuild.

Admittedly, I've found out that this is not the way to use the synapse-admin package, and its output should rather be mounted as the contents of a webserver. However, I think the error message should be improved. Or maybe it could be noted in some troubleshooting manual? I don't really know if this is the responsibility of home-manager or the nix tool, but I'm posting it here since it was the home-manager systemd service that failed.

Maintainer CC

@rycee

System information

- system: `"x86_64-linux"`
 - host os: `Linux 5.10.106, NixOS, 21.11 (Porcupine)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.4`
 - channels(h7x4): `"home-manager-21.11"`
 - nixpkgs: `/nix/var/nix/profiles/peruser/root/channels/nixos`
berbiche commented 2 years ago

Hi,

As far as I know, the path /manifest.json is not copied to Home Manager's generated environment (a link farm of binaries, libraries, etc.) by default.

If we need to add restrictions to the content of the generated environment, then we would become dependent on the implementation details of nix profile 🙁.

Should the nix profile cli check for the existence of this file before linking or should it be done by the users of nix profile? I think the first behavior makes more sense.

I recommend crosslinking this issue on the Nix tracker and providing a reproduction case.

dit7ya commented 2 years ago

@h7x4ABk3g Did you find a workaround to this?

stale[bot] commented 2 years ago

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve 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

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.