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

Rework how desktop files are patched

Open Henry-Hiles opened this issue 9 months ago • 7 comments

error: builder for '/nix/store/l18xarwymyj2c1hgj41qbdypvzdmdwk5-steam.drv' failed with exit code 1;
       last 4 log lines:
       > Wrapping /nix/store/n5flhj17ksb4sh8yk9lljlkv44vlg4cp-steam/bin/steam
       > Detected nested symlink, fixing
       > '/nix/store/n5flhj17ksb4sh8yk9lljlkv44vlg4cp-steam/share/applications/steam.desktop' -> '/build/tmp.9xArYj9Rdb/steam.desktop'
       > rm: cannot remove '/nix/store/n5flhj17ksb4sh8yk9lljlkv44vlg4cp-steam/share/applications': Is a directory
       For full logs, run 'nix log /nix/store/l18xarwymyj2c1hgj41qbdypvzdmdwk5-steam.drv'.
error: 1 dependencies of derivation '/nix/store/k84b38nxhdaflb14iinfmkwn1y8q467l-wrapper-manager.drv' failed to build
error: 1 dependencies of derivation '/nix/store/449gkrshcxb04cij19i97rmlbq4a4gdh-man-paths.drv' failed to build
error: 1 dependencies of derivation '/nix/store/ssd4iqgc6cjrl1jfpp34cgcv2zqm2vyf-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/msdgbvr0rikj7dafl23hpvnbz1y1h70k-wrapper-manager_fish-completions.drv' failed to build
error: 1 dependencies of derivation '/nix/store/p45s5qqq8f10msfag1vh2nwh99f1n7zc-nixos-system-quadraticpc-25.05.20250226.5135c59.drv' failed to build

Henry-Hiles avatar Mar 01 '25 15:03 Henry-Hiles

This happens because WM tries to modify symlinks in-place. To make things simpler, I should probably create a new derivation, create the new destkop files there, and then merge the result with symlinkJoin.

viperML avatar Mar 03 '25 07:03 viperML

Okay! If i can test anything, do let me know.

Henry-Hiles avatar Mar 03 '25 16:03 Henry-Hiles

I have the same problem when wrapping yazi:

wrappers.yazi = {
  basePackage = pkgs.yazi;
};

Log:

::: Wrapping explicit .programs ...
::: Wrapping packages in out/bin ...
:: (ya skipped: no wrapper configuration)
:: (yazi skipped: no wrapper configuration)
Detected nested symlink, fixing
'/nix/store/y2i6xk4x2pi26kc8g49k1zq3wlf059bg-yazi-25.5.28/share/applications/yazi.desktop' -> '/build/tmp.62oEWZDGU4/yazi.desktop'
rm: cannot remove '/nix/store/y2i6xk4x2pi26kc8g49k1zq3wlf059bg-yazi-25.5.28/share/applications': Is a directory

azuwis avatar Jul 14 '25 03:07 azuwis

Now that I look into it, using buildEnv instead of symlinkJoin could solve these issues, as it unrolls all the symlinks...

viperML avatar Jul 14 '25 06:07 viperML

At the point that I'm fighting against symlinkJoin/lndir/buildEnv, I might as well write my own symlinker (#27)

viperML avatar Jul 14 '25 07:07 viperML

Recently I also encountered the same problem when trying to wrap yazi. I managed to work it around using the following code snippet:

{
  wrappers.yazi.basePackage =
    pkgs.runCommand "yazi-without-desktop-item" { nativeBuildInputs = [ pkgs.yazi ]; }
      ''
        mkdir -p $out
        (cd ${pkgs.yazi} && tar -chf - --exclude="share/applications/yazi.desktop" .) \
            | (cd $out && tar -xf -)
      '';

  wrappers.yazi.postBuild = ''
    mkdir -p $out/share/applications
    sed -E -e "s#Exec=((/.*)*/)?yazi#Exec=$out/bin/yazi#" \
        ${pkgs.yazi}/share/applications/yazi.desktop \
        > $out/share/applications/yazi.desktop
  '';

  # ...
}

It simply creates a new derivation by copying anything but the original desktop item to avoid wrapper-manager from deleting the $out/share/applications directory. A patched desktop item is added at the postBuild phase, which will not trigger the above error.

StarryReverie avatar Nov 15 '25 03:11 StarryReverie