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

fix: symlink creation of per-user apps/icons folder #368

Conversation

mprasil
Copy link
Contributor

@mprasil mprasil commented Dec 18, 2023

Closes #362

The code relied on defaultUser attribute name in config.users.users to be the same as the username. This is not always the case as the username can be set by name attribute inside the user configuration

So for following user

users.users.foo.name = "bar";

the wsl.defaultUser = "foo" works, but the wsl.startMenuLaunchers = true won't work because it tries to find applications folder at /etc/profiles/per-user/foo/share rather than
/etc/profiles/per-user/bar/share that is actually created.

This PR uses the name attribute of that user instead which should fix the issue. (tested locally, it seems to be working correctly)

The code relied on `defaultUser` attribute name in `config.users.users`
to be the same as the username. This is not always the case as the
username can be set by `name` attribute inside the user configuration

So for following user

```
users.users.foo.name = "bar"
```

the `wsl.defaultUser = "foo"` works, but the `wsl.startMenuLaunchers =
true` won't work because it tries to find applications folder at
`/etc/profiles/per-user/foo/share` rather than
`/etc/profiles/per-user/bar/share` that is actually created.

This uses the `name` attribute of that user instead.
@terlar
Copy link
Contributor

terlar commented Jan 3, 2024

This looks good. I just tried to figure out why my icons were not working and just found the solution:

diff --git a/modules/wsl-distro.nix b/modules/wsl-distro.nix
index 50b81ea..39aae15 100644
--- a/modules/wsl-distro.nix
+++ b/modules/wsl-distro.nix
@@ -125,7 +125,7 @@ in

             if (( ''${#targets[@]} != 0 )); then
               mkdir -p "/usr/share/$x"
-              ${pkgs.rsync}/bin/rsync -ar --delete-after "''${targets[@]}" "/usr/share/$x"
+              ${pkgs.rsync}/bin/rsync -ar --copy-dirlinks --delete-after "''${targets[@]}" "/usr/share/$x"
             else
               rm -rf "/usr/share/$x"
             fi

Since the hicolor icons folder was a symlink in the derivation rsync couldn't merge the sources and hence just copied one of them. This change ensures it copies directory links instead to avoid such issues. Tested and working with icons for me now. I'll wait with PR until this is merged.

@SuperSandro2000 SuperSandro2000 merged commit c81bc3f into nix-community:main Jan 3, 2024
20 checks passed
SuperSandro2000 added a commit to SuperSandro2000/NixOS-WSL that referenced this pull request Jan 3, 2024
@SuperSandro2000
Copy link
Member

I've created #381 with your suggestion

@nzbr nzbr changed the title Fix symlink creation of per-user apps/icons folder fix: symlink creation of per-user apps/icons folder Jul 7, 2024
@nzbr nzbr added the bug Something isn't working label Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WSLg desktop integration does not show apps in Start menu and correct icons for GUI apps
4 participants