!apXxbtexmNGJaAryzM:nixos.org

NixOS on WSL

345 Members
https://github.com/nix-community/NixOS-WSL61 Servers

Load older messages


SenderMessageTime
8 Mar 2023
@k900:0upti.meK900To change all of them09:54:21
@i97henka:matrix.orghenrik-ch Yes, ran like this: sudo chown -R i97henka:users /home/i97henka/
Seems better now.
10:00:44
@i97henka:matrix.orghenrik-ch Thank you again for your help K900 . 10:02:12
@sandro:supersandro.deSandro 🐧What do I need to set for nix-ld to work vscode-remote-server? see https://github.com/nix-community/NixOS-WSL/issues/222#issuecomment-146102225823:21:49
@nzbr:nzbr.deArson Copperflame

For me, it was just this:

https://nixos.wiki/wiki/Visual_Studio_Code#nix-ld

23:26:06
9 Mar 2023
@sandro:supersandro.deSandro 🐧trying that in the next days, thanks00:26:43
@sandro:supersandro.deSandro 🐧 setting "remote.WSL2.connectionMethod": "wsl2VMAddress" did the trick. Probably some variable loading issue, again 10:55:21
@melito:matrix.orgmelito joined the room.17:45:33
@sandro:supersandro.deSandro 🐧 but I don't have environment.variables set 10:55:58
@sandro:supersandro.deSandro 🐧 though the nix-ld option already sets it to NIX_LD = "/nix/store/axkalfklvygxjlmc9vivkyb4xy18v30f-ld.so"; NIX_LD_LIBRARY_PATH = "/run/current-system/sw/share/nix-ld/lib"; 10:58:53
10 Mar 2023
@nzbr:nzbr.deArson Copperflame

When you run a perl program (or just perl), does it complain about not being able to load the locale? I mean something like this:

ZSH C:\Users\nzbr> perl
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LANG = "de_DE.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
^C
ZSH C:\Users\nzbr> nixos-wsl-version
NixOS-WSL DEV_BUILD 4640199aeafcbb63cfbe8318bdf06f4402134f66 syschdemd

It does not happen on my server, which is built from the same flake and I've checked that config.i18n.defaultLocale is set correctly. So I assume that it's a problem with NixOS-WSL. I already tried using nativeSystemd, but that has the same behavior

18:01:26
@k900:0upti.meK900What shell is that?18:54:10
@nzbr:nzbr.deArson CopperflameZSH with a prompt that makes it look like powershell when I'm on a windows drive18:54:53
@k900:0upti.meK900I wonder if you're missing /etc/set-environment somehow18:56:30
@k900:0upti.meK900 What if you source /etc/set-environment manually? 18:56:41
@nzbr:nzbr.deArson Copperflame

That doesn't change anything unfortunately

ZSH C:\Users\nzbr> echo $LANG
de_DE.UTF-8
ZSH C:\Users\nzbr> echo $LOCALE_ARCHIVE
/run/current-system/sw/lib/locale/locale-archive
ZSH C:\Users\nzbr> file /run/current-system/sw/lib/locale/locale-archive
/run/current-system/sw/lib/locale/locale-archive: locale archive 11 strings

On a bare-metal NixOS server is says 22 strings. Maybe that's got something to do with it

root@earthquake:~# echo $LANG
de_DE.UTF-8
root@earthquake:~# echo $LOCALE_ARCHIVE
/run/current-system/sw/lib/locale/locale-archive
root@earthquake:~# file /run/current-system/sw/lib/locale/locale-archive
/run/current-system/sw/lib/locale/locale-archive: locale archive 22 strings
19:39:54
@nzbr:nzbr.deArson Copperflame *

That doesn't change anything unfortunately

ZSH C:\Users\nzbr> echo $LANG
de_DE.UTF-8
ZSH C:\Users\nzbr> echo $LOCALE_ARCHIVE
/run/current-system/sw/lib/locale/locale-archive
ZSH C:\Users\nzbr> file /run/current-system/sw/lib/locale/locale-archive
/run/current-system/sw/lib/locale/locale-archive: locale archive 11 strings

On a bare-metal NixOS server is says 22 strings. Maybe that's got something to do with it?

root@earthquake:~# echo $LANG
de_DE.UTF-8
root@earthquake:~# echo $LOCALE_ARCHIVE
/run/current-system/sw/lib/locale/locale-archive
root@earthquake:~# file /run/current-system/sw/lib/locale/locale-archive
/run/current-system/sw/lib/locale/locale-archive: locale archive 22 strings
19:40:04
@nzbr:nzbr.deArson Copperflame Hmm, I copied the locale-archive from the server to my local maching and when I run LOCALE_ARCHIVE=$PWD/locale-archive perl it works 19:41:56
@k900:0upti.meK900Sus19:42:23
@nzbr:nzbr.deArson Copperflame

Just found this in wsl.nix in my flake 🤦

        i18n.supportedLocales = [
          "en_US.UTF-8/UTF-8"
        ];
19:44:19
@k900:0upti.meK900RIP19:45:37
@nzbr:nzbr.deArson Copperflame I removed it and it works now what a miracle 🙄 19:46:16
11 Mar 2023
@i97henka:matrix.orghenrik-ch

Hi, I am trying to get vscode running remotely on my nixos wsl instance.
What I have in mind is running the vscode server on the nixos wsl instance and attaching with the
vscode gui in the Windows Instance - just like it's done with Ubuntu - it's possible to type code .
in the ubuntu wsl command line and it launches a vscode gui in the windows instance.

I have cloned https://github.com/sonowz/vscode-remote-wsl-nixos and copied the server-env-setup file to
~/.vscode-server/server-env-setup.

Then I make the file executable and run it. It seems to work fine.

Then I try in the nixos wsl instance command line: code .

I get the following error in the vscode windows gui:
(see upcoming attachment)

and there I press ignore to view the wsl terminal content which is:

[2023-03-11 12:12:28.705] Resolving wsl+NixOS, resolveAttempt: 1
[2023-03-11 12:12:29.072] Starting VS Code Server inside WSL (wsl2)
[2023-03-11 12:12:29.072] Extension version: 0.76.1
[2023-03-11 12:12:29.072] Windows build: 22621. Multi distro support: available. WSL path support: enabled
[2023-03-11 12:12:29.446] Using shell environment from invoking shell: /tmp/vscode-distro-env.j9GrQZ
[2023-03-11 12:12:29.615] WSL daemon log file: 
[2023-03-11 12:12:29.616] Probing if server is already installed: C:\WINDOWS\System32\wsl.exe -d NixOS -e sh -c "if [ -d ~/.vscode-server/bin/5e805b79fcb6ba4c2d23712967df89a089da575b ]; then printf 'install-found '; fi; if [ -f /etc/alpine-release ]; then printf alpine-; fi; uname -m"
[2023-03-11 12:12:30.023] Unable to detect if server is already installed: Error: Command failed: C:\WINDOWS\System32\wsl.exe -d NixOS -e sh -c "if [ -d ~/.vscode-server/bin/5e805b79fcb6ba4c2d23712967df89a089da575b ]; then printf 'install-found '; fi; if [ -f /etc/alpine-release ]; then printf alpine-; fi; uname -m"
[2023-03-11 12:12:30.023] /nix/store/k90dlx0yw3463kxbfvyi9hf3q64bm5rj-bash-interactive-5.1-p16/bin/sh: line 1: uname: command not found
[2023-03-11 12:12:30.023] 
[2023-03-11 12:12:30.023] 湩瑳污⵬潦湵⁤
[2023-03-11 12:12:30.023] 港硩猯潴敲欯〹汤へ睹㐳㌶硫晢祶㥩晨焳㐶浢爵⵪慢桳椭瑮牥捡楴敶㔭ㄮ瀭㘱戯湩猯㩨氠湩⁥㨱甠慮敭›潣浭湡⁤潮⁴潦湵੤
[2023-03-11 12:12:30.024] Launching C:\WINDOWS\System32\wsl.exe -d NixOS sh -c '"$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh" 5e805b79fcb6ba4c2d23712967df89a089da575b stable code-server .vscode-server --host=127.0.0.1 --port=0 --connection-token=2512226551-2811631879-3098200668-4223237764 --use-host-proxy --without-browser-env-var --disable-websocket-compression --accept-server-license-terms --telemetry-level=all'
[2023-03-11 12:12:30.338] Setting up server environment: Looking for /home/i97henka/.vscode-server/server-env-setup. Found, executing...
[2023-03-11 12:12:30.338] == '~/.vscode-server/server-env-setup' SCRIPT START ==
[2023-03-11 12:12:30.641] NIXOS_VERSION detected as ""
[2023-03-11 12:12:30.641] Got vscode directory : /mnt/c/Program Files/Microsoft VS Code
[2023-03-11 12:12:30.641] If the directory is incorrect, you can hardcode it on the script.
[2023-03-11 12:12:30.641] Patching nodejs binaries...
[2023-03-11 12:12:30.641] == '~/.vscode-server/server-env-setup' SCRIPT END ==
[2023-03-11 12:12:30.643] /home/i97henka/.vscode-server/server-env-setup: line 10: nixos-version: command not found
[2023-03-11 12:12:30.643] /home/i97henka/.vscode-server/server-env-setup: line 10: cut: command not found
[2023-03-11 12:12:30.643] /home/i97henka/.vscode-server/server-env-setup: line 17: dirname: command not found
[2023-03-11 12:12:30.643] /home/i97henka/.vscode-server/server-env-setup: line 22: nix: command not found
[2023-03-11 12:12:30.765] WSL version:  NixOS
[2023-03-11 12:12:30.765] /mnt/c/Users/i97he/.vscode/extensions/ms-vscode-remote.remote-wsl-0.76.1/scripts/wslServer.sh: line 28: uname: command not found
[2023-03-11 12:12:30.765] /mnt/c/Users/i97he/.vscode/extensions/ms-vscode-remote.remote-wsl-0.76.1/scripts/wslServer.sh: line 32: dirname: command not found
[2023-03-11 12:12:30.765] /mnt/c/Users/i97he/.vscode/extensions/ms-vscode-remote.remote-wsl-0.76.1/scripts/wslServer.sh: line 32: /wslDownload.sh: No such file or directory
[2023-03-11 12:12:30.766] VS Code Server for WSL closed unexpectedly.
[2023-03-11 12:12:30.766] For help with startup problems, go to https://code.visualstudio.com/docs/remote/troubleshooting#_wsl-tips
[2023-03-11 12:12:30.778] WSL Daemon exited with code 0
[2023-03-11 12:14:06.220] Download in background is enabled
[2023-03-11 12:14:36.230] Update check by another window detected, skipping.

Trying the best I can to understand and work with that log, it seems that the nix-version command, the nix command, the uname command and the dirname command are all available in the nixos wsl instance, which puzzles me a bit.

My own hunch what might be the problem: When I launch wsl from windows terminal, I specify the distribution name and the user, whereas above on this line, only the distro is specified.

[2023-03-11 12:12:30.024] Launching C:\WINDOWS\System32\wsl.exe -d NixOS sh -c '"$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh"

Do you know how I can specify the user in the launch command?
Or if you think that the problem is elsewhere, I'd be happy to hear your thoughts.
Also, if you see an entirely different approach that might be easier, I'd be happy to hear that too.

12:25:03
@i97henka:matrix.orghenrik-chvscodeerror.png
Download vscodeerror.png
12:25:12
@k900:0upti.meK900You probably want to just use nix-ld12:26:06
@k900:0upti.meK900 programs.nix-ld.enable = true 12:26:10
@k900:0upti.meK900Without any of the other stuff12:26:16
@k900:0upti.meK900
In reply to@sandro:supersandro.de
setting "remote.WSL2.connectionMethod": "wsl2VMAddress" did the trick. Probably some variable loading issue, again
You may also need this
12:26:49
@i97henka:matrix.orghenrik-ch Thank you K900 , I don't even know what that nix-ld is yet 😆, but I'll investigate - much appreciated, I would never have found this out myself.
I'll keep you posted on my progress.
12:28:40
@i97henka:matrix.orghenrik-ch

I added nix-ld successfully I think in my configuration.nix.

I kept the vscode-remote-wsl-nixos script in the .vscode-server folder, but I am not sure if that is necessary.
This script still runs without error as far as I can see when I trigger it manually.

running the code . command in the nixos command line now gives the following result.

[2023-03-11 12:43:34.519] Resolving wsl+NixOS, resolveAttempt: 1
[2023-03-11 12:43:34.927] Starting VS Code Server inside WSL (wsl2)
[2023-03-11 12:43:34.927] Extension version: 0.76.1
[2023-03-11 12:43:34.927] Windows build: 22621. Multi distro support: available. WSL path support: enabled
[2023-03-11 12:43:35.284] Using shell environment from invoking shell: /tmp/vscode-distro-env.4xitW2
[2023-03-11 12:43:35.444] WSL daemon log file: 
[2023-03-11 12:43:35.445] Probing if server is already installed: C:\WINDOWS\System32\wsl.exe -d NixOS -e sh -c "if [ -d ~/.vscode-server/bin/5e805b79fcb6ba4c2d23712967df89a089da575b ]; then printf 'install-found '; fi; if [ -f /etc/alpine-release ]; then printf alpine-; fi; uname -m"
[2023-03-11 12:43:35.816] Unable to detect if server is already installed: Error: Command failed: C:\WINDOWS\System32\wsl.exe -d NixOS -e sh -c "if [ -d ~/.vscode-server/bin/5e805b79fcb6ba4c2d23712967df89a089da575b ]; then printf 'install-found '; fi; if [ -f /etc/alpine-release ]; then printf alpine-; fi; uname -m"
[2023-03-11 12:43:35.816] /nix/store/k90dlx0yw3463kxbfvyi9hf3q64bm5rj-bash-interactive-5.1-p16/bin/sh: line 1: uname: command not found
[2023-03-11 12:43:35.816] 
[2023-03-11 12:43:35.816] 湩瑳污⵬潦湵⁤
[2023-03-11 12:43:35.816] 港硩猯潴敲欯〹汤へ睹㐳㌶硫晢祶㥩晨焳㐶浢爵⵪慢桳椭瑮牥捡楴敶㔭ㄮ瀭㘱戯湩猯㩨氠湩⁥㨱甠慮敭›潣浭湡⁤潮⁴潦湵੤
[2023-03-11 12:43:35.817] Launching C:\WINDOWS\System32\wsl.exe -d NixOS sh -c '"$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh" 5e805b79fcb6ba4c2d23712967df89a089da575b stable code-server .vscode-server --host=127.0.0.1 --port=0 --connection-token=4156266028-1343363423-1808892915-2055051780 --use-host-proxy --without-browser-env-var --disable-websocket-compression --accept-server-license-terms --telemetry-level=all'
[2023-03-11 12:43:36.127] Setting up server environment: Looking for /home/i97henka/.vscode-server/server-env-setup. Found, executing...
[2023-03-11 12:43:36.127] == '~/.vscode-server/server-env-setup' SCRIPT START ==
[2023-03-11 12:43:36.128] NIXOS_VERSION detected as ""
[2023-03-11 12:43:36.129] /home/i97henka/.vscode-server/server-env-setup: line 10: cut: command not found
[2023-03-11 12:43:36.129] /home/i97henka/.vscode-server/server-env-setup: line 10: nixos-version: command not found
[2023-03-11 12:43:36.369] Got vscode directory : /mnt/c/Program Files/Microsoft VS Code
[2023-03-11 12:43:36.369] If the directory is incorrect, you can hardcode it on the script.
[2023-03-11 12:43:36.369] Patching nodejs binaries...
[2023-03-11 12:43:36.369] == '~/.vscode-server/server-env-setup' SCRIPT END ==
[2023-03-11 12:43:36.369] WSL version:  NixOS
[2023-03-11 12:43:36.370] /home/i97henka/.vscode-server/server-env-setup: line 17: dirname: command not found
[2023-03-11 12:43:36.370] /home/i97henka/.vscode-server/server-env-setup: line 22: nix: command not found
[2023-03-11 12:43:36.370] /mnt/c/Users/i97he/.vscode/extensions/ms-vscode-remote.remote-wsl-0.76.1/scripts/wslServer.sh: line 28: uname: command not found
[2023-03-11 12:43:36.370] /mnt/c/Users/i97he/.vscode/extensions/ms-vscode-remote.remote-wsl-0.76.1/scripts/wslServer.sh: line 32: dirname: command not found
[2023-03-11 12:43:36.370] /mnt/c/Users/i97he/.vscode/extensions/ms-vscode-remote.remote-wsl-0.76.1/scripts/wslServer.sh: line 32: /wslDownload.sh: No such file or directory
[2023-03-11 12:43:36.370] VS Code Server for WSL closed unexpectedly.
[2023-03-11 12:43:36.370] For help with startup problems, go to https://code.visualstudio.com/docs/remote/troubleshooting#_wsl-tips
[2023-03-11 12:43:36.381] WSL Daemon exited with code 0
[2023-03-11 12:43:39.394] Download in background is enabled
[2023-03-11 12:44:09.401] Update check by another window detected, skipping.

I gave it a couple of reruns to make sure that the result is consistent. Was I supposed to keep that server-env-setup script in the .vscode-server?
Error seems a bit similar to previous go with command missing, but I am not sure what to think about that.

What I realise that I haven't done yet is setting the remote.WSL2.connectionMethod to wsl2VMAddress
Is that a vscode setting in the gui on the Windows machine?

12:49:25

Show newer messages


Back to Room ListRoom Version: 9