home-manager icon indicating copy to clipboard operation
home-manager copied to clipboard

News cannot be read when using flakes only

Open dschrempf opened this issue 3 years ago • 2 comments

When using flakes, news cannot be read with the following error:

 + home-manager news
No configuration file found. Please create one at /home/dominik/.config/nixpkgs/home.nix

I can link the flake to ~/.config/nixpkgs to work around this issue, but in the long run, a consistent usage like so: home-manager --flake /path/to/directory COMMAND (like it is defined for the command switch already) would be preferrable.

dschrempf avatar May 22 '21 12:05 dschrempf

I was linked here on suspicion that this might be the same bug I'm experiencing (on a pure flake config):

[2022-01-29 12:11:08] 0 x10an14@bits-laptop:~
-> $ home-manager --debug --verbose news
resolved search path element '/nix/var/nix/profiles/per-user/root/channels' to '/nix/var/nix/profiles/per-user/root/channels'
error: file 'home-manager/home-manager/home-manager.nix' was not found in the Nix search path (add it using $NIX_PATH or -I)
/home/x10an14/.nix-profile/bin/home-manager: line 424: /tmp/home-manager-build.8YKn0CUBhO/news-info.sh: No such file or directory
[2022-01-29 12:11:17] 0 x10an14@bits-laptop:~
-> $ home-manager --debug --verbose --flake ~/.config/nixpkgs news
resolved search path element '/nix/var/nix/profiles/per-user/root/channels' to '/nix/var/nix/profiles/per-user/root/channels'
error: file 'home-manager/home-manager/home-manager.nix' was not found in the Nix search path (add it using $NIX_PATH or -I)
/home/x10an14/.nix-profile/bin/home-manager: line 424: /tmp/home-manager-build.Az0e6aKX62/news-info.sh: No such file or directory
[2022-01-29 12:11:35] 0 x10an14@bits-laptop:~
-> $ la ~/.config/nixpkgs/
total 40K
   0 drwxr-xr-x 1 x10an14 x10an14  288 jan.  29 08:33 ./
   0 drwxr-xr-x 1 x10an14 x10an14  112 jan.  29 07:45 ../
4,0K -rw-r--r-- 1 x10an14 x10an14 1,5K jan.  28 10:42 flake.lock
4,0K -rw-r--r-- 1 x10an14 x10an14 1,6K jan.  28 23:51 flake.nix
4,0K -rw-r--r-- 1 x10an14 x10an14   56 jan.  27 20:47 .git
4,0K -rw-r--r-- 1 x10an14 x10an14   37 jan.  27 20:47 .gitignore
4,0K -rw-r--r-- 1 x10an14 x10an14  495 jan.  28 23:51 home.nix
< the rest omitted for brevity>
[2022-01-29 12:12:28] 0 x10an14@bits-laptop:~
-> $

Is this related? If so, what's the status (if there's anything changed since May) on this bug?

If not, I'll make a new issue^^

x10an14 avatar Jan 29 '22 11:01 x10an14

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/depreciate-the-use-of-nix-env-to-install-packages/20139/32

nixos-discourse avatar Jul 16 '22 13:07 nixos-discourse

This seems to be fixed for me in 23.11-pre.

sullyj3 avatar Aug 01 '23 02:08 sullyj3

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/home-manager-news-no-configuration-found/32170/2

nixos-discourse avatar Aug 25 '23 08:08 nixos-discourse

It seems to be not fixed for me, and additional info, if I add --flake $location, I end up with this error instead:

home-manager news --flake github:nobbz/nixos-config
Home Manager not found at /nix/store/4jvg1mvyg9ah4la7wmwg08sifrd2w8ks-source.
error: file 'home-manager/home-manager/build-news.nix' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «none»:0: (source not available)

NobbZ avatar Aug 25 '23 08:08 NobbZ

I would like the option to simply disable news. I don't like the time it takes to evaluate.

news.enable = false

spikespaz avatar Aug 30 '23 02:08 spikespaz

I get an error even when running home-manager switch:

error: file 'home-manager/home-manager/build-news.nix' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «none»:0: (source not available)

jzbor avatar Sep 04 '23 19:09 jzbor

It seems to be not fixed for me, and additional info, if I add --flake $location, I end up with this error instead:

home-manager news --flake github:nobbz/nixos-config
Home Manager not found at /nix/store/4jvg1mvyg9ah4la7wmwg08sifrd2w8ks-source.
error: file 'home-manager/home-manager/build-news.nix' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «none»:0: (source not available)

Could you try again? I don't know if anything has changed, but a couple of hours ago I did:

home-manager news --flake ~/Nix/

And everything worked perfectly.

Dioprz avatar Sep 05 '23 03:09 Dioprz

Yeah, seems to not be an issue right now.

NobbZ avatar Sep 05 '23 11:09 NobbZ

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/how-would-i-open-home-manager-news-in-my-flake-setup/18572/2

nixos-discourse avatar Sep 06 '23 07:09 nixos-discourse

I get an error even when running home-manager switch:

error: file 'home-manager/home-manager/build-news.nix' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «none»:0: (source not available)

I get this fairly frequently, after modifying my config. Immediately running the command again always succeeds. Still, it's annoying to see the error come up, and I don't know what the fix is.

Nairou avatar Oct 13 '23 15:10 Nairou

I got that error recently on the first rebuild after a garbage-collection; I wonder if that's related.

sersorrel avatar Oct 13 '23 20:10 sersorrel

I got that error recently on the first rebuild after a garbage-collection; I wonder if that's related.

Same here

J-Swift avatar Oct 13 '23 20:10 J-Swift

modules = [
  # It doesn't even work out of the box with flakes...
  # <https://github.com/nix-community/home-manager/issues/2033#issuecomment-1698406098>
  {
    # news.display = "silent";
    disabledModules = [ "misc/news.nix" ];
  }
  # ...
};

Unfortunately, this will make the command always exit with 1:

error: flake 'path:.' does not provide attribute 'packages.x86_64-linux.homeConfigurations."jacob".config.news.json.output', 'legacyPackages.x86_64-linux.homeConfigurations."jacob".config.news.json.output' or 'homeConfigurations."jacob".config.news.json.output'

spikespaz avatar Nov 08 '23 10:11 spikespaz

@spikespaz how much does this change the behaviour of regular home-manager switch with and without flakes?

I'm a bit confused by your comment about always having an exit code of 1

NobbZ avatar Nov 11 '23 10:11 NobbZ

@spikespaz how much does this change the behaviour of regular home-manager switch with and without flakes?

I'm a bit confused by your comment about always having an exit code of 1

When the home-manager script tries to evaluate news in presentNews, it exits with code 1.

I tried patching home-manager but was unsuccessful.

spikespaz avatar Nov 11 '23 14:11 spikespaz

I've got the same error right now, using NixOS 23.11 and Flakes

home-manager switch --flake .

luisnquin avatar Dec 09 '23 02:12 luisnquin

I was annoyed enough to look at this closer.

Here's a module that we can use to mitigate this issue (does not cause failure in CI):

# It doesn't even work out of the box with flakes...
# <https://github.com/nix-community/home-manager/issues/2033#issuecomment-1801557851>
#
# Include this in the `modules` passed to
# `inputs.home-manager.lib.homeManagerConfiguration`.
disableHomeManagerNews = {
  # disabledModules = [ "misc/news.nix" ];
  config = {
    news.display = "silent";
    news.json = lib.mkForce { };
    news.entries = lib.mkForce [ ];
  };
};

spikespaz avatar Dec 09 '23 08:12 spikespaz