Home-manager: Config with htop fails to build

Created on 16 Jul 2020  路  9Comments  路  Source: nix-community/home-manager

Issue description

If my home.nix contains an htop program configuration, then home-manager build fails with

The databases in [/nix/store/fjsylqd171xcjyk0byj1sw437jyc5ywz-home-manager-path/share/applications] could not be updated.
builder for '/nix/store/q0d1r710280pdfxv09n3avnrqd4x0pbk-home-manager-path.drv' failed with exit code 1
cannot build derivation '/nix/store/flh80b1gdrb3lcma1wk2frsjc855x4rm-home-manager-generation.drv': 1 dependencies couldn't be built
error: build of '/nix/store/flh80b1gdrb3lcma1wk2frsjc855x4rm-home-manager-generation.drv' failed

The aforementioned path contains zero files:

$ tree -a /nix/store/fjsylqd171xcjyk0byj1sw437jyc5ywz-home-manager-path/share/applications
/nix/store/fjsylqd171xcjyk0byj1sw437jyc5ywz-home-manager-path/share/applications

0 directories, 0 files

Removing the programs.htop=... entry results in a successful build.

I am running nixpkgs-unstable with HM from the 20.03 release (although the issue is there for the master branch, too).

Meta

Maintainer CC


@Infinisil

Technical details


Win10-1809 with Ubuntu-18 in WSL1.

 - system: `"x86_64-linux"`
 - host os: `Linux 4.4.0-17763-Microsoft, Ubuntu, 18.04.4 LTS (Bionic Beaver)`
 - multi-user?: `no`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.3.4`
 - channels(user): `"home-manager-20.03, nixpkgs-20.09pre234831.e97fdce4e1b"`
 - nixpkgs: `/home/user/.nix-defexpr/channels/nixpkgs`

Exact htop config:

  programs.htop = {
    enable = true;
    highlightBaseName = true;
    meters.left = [ "LeftCPUs" "Memory" "Swap" ];
    meters.right = [ "RightCPUs" "Tasks" "LoadAverage" "Uptime" ];
    treeView = true;
  };

Most helpful comment

I added the solution proposed by @Infinisil to master with the above commit. Thanks for the report and investigation.

All 9 comments

Under WSL2 with Ubuntu and nixpkgs-unstable, I get the same error message whenever I try to add programs such as:

  • emacs
  • firefox
  • htop
  • vscode

However, I can install small programs just fine, such as:

  • cowsay
  • niv

What are the full logs? I feel like the actual error is missing from what @ShrykeWindgrace posted

@Infinisil no that's actually pretty much all the output you get after the succesful build:

```these derivations will be built:
/nix/store/szsz1lkns6wkhx9vr8p9sx3rrvlhgiqk-home-manager-path.drv
/nix/store/6ddfhydycgl8k4b9xgy9dnafq7hr5m8i-activation-script.drv
/nix/store/m5l94x1k78afaprz3dcamwn9jzn6sffs-home-manager-generation.drv
building '/nix/store/szsz1lkns6wkhx9vr8p9sx3rrvlhgiqk-home-manager-path.drv'...
created 182 symlinks in user environment
The databases in [/nix/store/x1hqwqhjglllh4sf041pg0bx2i5rfr4f-home-manager-path/share/applications] could not be updated.
builder for '/nix/store/szsz1lkns6wkhx9vr8p9sx3rrvlhgiqk-home-manager-path.drv' failed with exit code 1
cannot build derivation '/nix/store/m5l94x1k78afaprz3dcamwn9jzn6sffs-home-manager-generation.drv': 1 dependencies couldn't be built
error: build of '/nix/store/m5l94x1k78afaprz3dcamwn9jzn6sffs-home-manager-generation.drv' failed

Hm I see. I believe this is the command that fails: https://github.com/rycee/home-manager/blob/223e3c38a13fb45726c7a9d97e2612ae53ab4f98/modules/misc/xdg-mime.nix#L40-L43

My suggestion is to add the --verbose flag to that command and see if it prints anything else.

With --verbose:

Search path is now: [/nix/store/2q199wcshhlmgrs2n2wcpngg53yc60qg-home-manager-path/share/applications]
File "/nix/store/2q199wcshhlmgrs2n2wcpngg53yc60qg-home-manager-path/share/applications/htop.desktop" lacks MimeType key
Could not create cache file in "/nix/store/2q199wcshhlmgrs2n2wcpngg53yc60qg-home-manager-path/share/applications": Permission denied
The databases in [/nix/store/2q199wcshhlmgrs2n2wcpngg53yc60qg-home-manager-path/share/applications] could not be updated.

It seems that things are quite messed up in that /nix/store/<HASH>-home-manager-path/share directory:

$ ll /nix/store/xmmp0k04dl5lq4kblqyvh2py3zwj3h0z-home-manager-path/share/
total 0
drwxr-xr-x 1 val val 4096 Aug  9 15:25 ./
drwxr-xr-x 1 val val 4096 Aug  9 15:25 ../
lrwxrwxrwx 1 val val   73 Aug  9 15:25 applications -> /nix/store/kj1klbs38yyr73yhwsbsa105znqg8r4k-htop-2.2.0/share/applications/
lrwxrwxrwx 1 val val   78 Aug  9 15:25 bash-completion -> /nix/store/gid2bxf4rpbw7cl7bm3w7zc29imzdfxq-home-manager/share/bash-completion/
drwxr-xr-x 1 val val 4096 Aug  9 15:25 locale/
drwxr-xr-x 1 val val 4096 Aug  9 15:25 man/
lrwxrwxrwx 1 val val   78 Aug  9 15:25 mime -> /nix/store/yc0xxqhw8y6ixy9f0pzyrj0k6yghhcim-shared-mime-info-1.13.1/share/mime/
lrwxrwxrwx 1 val val   68 Aug  9 15:25 pixmaps -> /nix/store/kj1klbs38yyr73yhwsbsa105znqg8r4k-htop-2.2.0/share/pixmaps/
lrwxrwxrwx 1 val val   83 Aug  9 15:25 pkgconfig -> /nix/store/yc0xxqhw8y6ixy9f0pzyrj0k6yghhcim-shared-mime-info-1.13.1/share/pkgconfig/              

Oh I think I know what's happening: buildEnv, which is used to build the home-manager environment: https://github.com/rycee/home-manager/blob/223e3c38a13fb45726c7a9d97e2612ae53ab4f98/modules/home-environment.nix#L550-L561 just symlinks directories if there's only a single package that defines that directory. In this case, htop is the only package in the environment that defines $out/share/applications, so it just symlinks that to htop for simplicity. But the postBuild that runs the update-desktop-database wants to write to applications, which it can't when it's a symlink to a read-only directory.

A temporary workaround for this is to add an another package with an applications directory, so this should fix it:

{
  home.packages = [
    (pkgs.runCommandNoCC "applications-workaround" {} "mkdir -p $out/share/applications")
  ];
}

I can confirm that this workaround works, and the diagnostic seems on point. Thanks!

I added the solution proposed by @Infinisil to master with the above commit. Thanks for the report and investigation.

I too confirm that with current master of home-manager my config with htop works. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

btomasini picture btomasini  路  4Comments

memberbetty picture memberbetty  路  5Comments

sondr3 picture sondr3  路  7Comments

dermetfan picture dermetfan  路  6Comments

JonathanReeve picture JonathanReeve  路  8Comments