!apXxbtexmNGJaAryzM:nixos.org

NixOS on WSL

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

Load older messages


SenderMessageTime
11 Mar 2023
@i97henka:matrix.orghenrik-ch

I think that improved things:

[i97henka@nixos:~/github/vscode-remote-wsl-nixos]$ code .
Installing VS Code Server for x64 (5e805b79fcb6ba4c2d23712967df89a089da575b)
Downloading: 100%
Unpacking: 100%
Unpacked 2399 files and folders to /home/i97henka/.vscode-server/bin/5e805b79fcb6ba4c2d23712967df89a089da575b.
cannot execute /home/i97henka/.vscode-server/bin/5e805b79fcb6ba4c2d23712967df89a089da575b/node: NIX_LD or NIX_LD_x86_64-linux is not set

Do you know about that setting NIX_LD or NIX_LD_x86_64-linux?

13:30:04
@k900:0upti.meK900 Are you on 22.11 or unstable? 13:30:48
@k900:0upti.meK900Those should be set by default on unstable13:30:56
@i97henka:matrix.orghenrik-ch
[i97henka@nixos:~/github/vscode-remote-wsl-nixos]$ nixos-version
22.11.2630.e6d5772f351 (Raccoon)

[i97henka@nixos:~/github/vscode-remote-wsl-nixos]$ sudo nix-channel --list
home-manager https://github.com/nix-community/home-manager/archive/master.tar.gz
nixos https://nixos.org/channels/nixos-22.11
13:32:40
@i97henka:matrix.orghenrik-chso I need to change that.13:32:59
@k900:0upti.meK900 You could also set them manually, but generally it might be a better idea to run unstable, as that's what nixos-wsl is mostly tested afaisnt 13:33:28
@k900:0upti.meK900* You could also set them manually, but generally it might be a better idea to run unstable, as that's what nixos-wsl is mostly tested against 13:33:40
@i97henka:matrix.orghenrik-chbetter to change the channel, or do it over configuration.nix somehow?13:33:44
@k900:0upti.meK900You have to change the channel if you want to run unstable 13:34:20
@k900:0upti.meK900Unless you use niv or flakes or some other way of tracking your inputs that's not channels13:34:37
@i97henka:matrix.orghenrik-ch

I have flakes activated by default in the nixos-wsl, but I think that I only use them in specific folders with direnv, and not for the whole system management?
How can I check?

This is my channel setup now:

[i97henka@nixos:~]$ sudo nix-channel --list
home-manager https://github.com/nix-community/home-manager/archive/master.tar.gz
nixos https://nixos.org/channels/nixos-22.11
nixpkgs https://nixos.org/channels/nixpkgs-unstable

Does that look right?

13:38:04
@k900:0upti.meK900 If you have /etc/nixos/configuration.nix and no /etc/nixos/flake.nix, you're using channels 13:39:30
@k900:0upti.meK900 And no, you want to replace the nixos channel 13:39:38
@k900:0upti.meK900And you probably want to use nixos-unstable, not nixpkgs-unstable13:39:52
@i97henka:matrix.orghenrik-ch

I think that the replace of the nixos channel is done now:

[i97henka@nixos:~/github/vscode-remote-wsl-nixos]$ sudo nix-channel --list
home-manager https://github.com/nix-community/home-manager/archive/master.tar.gz
nixos https://nixos.org/channels/nixos-unstable
nixpkgs https://nixos.org/channels/nixpkgs-unstable

[i97henka@nixos:~/github/vscode-remote-wsl-nixos]$ sudo nixos-rebuild switch --u
pgrade
unpacking channels...
building Nix...
building the system configuration...
activating the configuration...
setting up /usr/share/applications...
setting up /usr/share/icons...
setting up /etc...
setting up /bin...
setting up /bin/login...
setting up /sbin/init shim...
reloading user units for i97henka...
setting up tmpfiles

[i97henka@nixos:~/github/vscode-remote-wsl-nixos]$ cd ~

[i97henka@nixos:~]$ rm -rf .vscode-server/

[i97henka@nixos:~]$ cd github/vscode-remote-wsl-nixos/

[i97henka@nixos:~/github/vscode-remote-wsl-nixos]$ code .
Installing VS Code Server for x64 (5e805b79fcb6ba4c2d23712967df89a089da575b)
Downloading: 100%
Unpacking: 100%
Unpacked 2399 files and folders to /home/i97henka/.vscode-server/bin/5e805b79fcb6ba4c2d23712967df89a089da575b.

[i97henka@nixos:~/github/vscode-remote-wsl-nixos]$

It's no errors in the command line now, but unfortunately still the same in the vscode terminal:

[2023-03-11 14:04:01.455] Windows build: 22621. Multi distro support: available. WSL path support: enabled
[2023-03-11 14:04:01.849] Using shell environment from invoking shell: /tmp/vscode-distro-env.SGB9gH
[2023-03-11 14:04:02.003] WSL daemon log file: 
[2023-03-11 14:04:02.004] 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 14:04:02.403] 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 14:04:02.403] /nix/store/7xf4f4d9jip5rjkzwvxwxqgmyhzzvyqk-bash-interactive-5.2-p15/bin/sh: line 1: uname: command not found
[2023-03-11 14:04:02.403] 
[2023-03-11 14:04:02.403] 湩瑳污⵬潦湵⁤
[2023-03-11 14:04:02.403] 港硩猯潴敲㜯晸昴搴樹灩爵歪睺硶硷東祭穨発煹⵫慢桳椭瑮牥捡楴敶㔭㈮瀭㔱戯湩猯㩨氠湩⁥㨱甠慮敭›潣浭湡⁤潮⁴潦湵੤
[2023-03-11 14:04:02.404] Launching C:\WINDOWS\System32\wsl.exe -d NixOS sh -c '"$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh" 5e805b79fcb6ba4c2d23712967df89a089da575b stable code-server .vscode-server --host=:: --print-ip-address --port=0 --connection-token=1574352636-3755954077-1501434474-266153846 --use-host-proxy --without-browser-env-var --disable-websocket-compression --accept-server-license-terms --telemetry-level=all'
[2023-03-11 14:04:03.015] Setting up server environment: Looking for /home/i97henka/.vscode-server/server-env-setup. Not found.
[2023-03-11 14:04:03.015] WSL version:  NixOS
[2023-03-11 14:04:03.016] /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 14:04:03.016] /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 14:04:03.033] /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 14:04:03.033] VS Code Server for WSL closed unexpectedly.
[2023-03-11 14:04:03.033] For help with startup problems, go to https://code.visualstudio.com/docs/remote/troubleshooting#_wsl-tips
[2023-03-11 14:04:03.050] WSL Daemon exited with code 0
[2023-03-11 14:05:24.901] Download in background is enabled
14:05:56
@fallenbagel:matrix.orgFallenbagel changed their display name from fallenbagel to Fallenbagel.18:19:10
14 Mar 2023
@ylliu:matrix.scnu.runYilong Liu joined the room.01:35:53
@purewaterisme:matrix.orgpurewaterisme joined the room.05:49:57
@purewaterisme:matrix.orgpurewaterisme
In reply to @i97henka:matrix.org

I think that the replace of the nixos channel is done now:

[i97henka@nixos:~/github/vscode-remote-wsl-nixos]$ sudo nix-channel --list
home-manager https://github.com/nix-community/home-manager/archive/master.tar.gz
nixos https://nixos.org/channels/nixos-unstable
nixpkgs https://nixos.org/channels/nixpkgs-unstable

[i97henka@nixos:~/github/vscode-remote-wsl-nixos]$ sudo nixos-rebuild switch --u
pgrade
unpacking channels...
building Nix...
building the system configuration...
activating the configuration...
setting up /usr/share/applications...
setting up /usr/share/icons...
setting up /etc...
setting up /bin...
setting up /bin/login...
setting up /sbin/init shim...
reloading user units for i97henka...
setting up tmpfiles

[i97henka@nixos:~/github/vscode-remote-wsl-nixos]$ cd ~

[i97henka@nixos:~]$ rm -rf .vscode-server/

[i97henka@nixos:~]$ cd github/vscode-remote-wsl-nixos/

[i97henka@nixos:~/github/vscode-remote-wsl-nixos]$ code .
Installing VS Code Server for x64 (5e805b79fcb6ba4c2d23712967df89a089da575b)
Downloading: 100%
Unpacking: 100%
Unpacked 2399 files and folders to /home/i97henka/.vscode-server/bin/5e805b79fcb6ba4c2d23712967df89a089da575b.

[i97henka@nixos:~/github/vscode-remote-wsl-nixos]$

It's no errors in the command line now, but unfortunately still the same in the vscode terminal:

[2023-03-11 14:04:01.455] Windows build: 22621. Multi distro support: available. WSL path support: enabled
[2023-03-11 14:04:01.849] Using shell environment from invoking shell: /tmp/vscode-distro-env.SGB9gH
[2023-03-11 14:04:02.003] WSL daemon log file: 
[2023-03-11 14:04:02.004] 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 14:04:02.403] 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 14:04:02.403] /nix/store/7xf4f4d9jip5rjkzwvxwxqgmyhzzvyqk-bash-interactive-5.2-p15/bin/sh: line 1: uname: command not found
[2023-03-11 14:04:02.403] 
[2023-03-11 14:04:02.403] 湩瑳污⵬潦湵⁤
[2023-03-11 14:04:02.403] 港硩猯潴敲㜯晸昴搴樹灩爵歪睺硶硷東祭穨発煹⵫慢桳椭瑮牥捡楴敶㔭㈮瀭㔱戯湩猯㩨氠湩⁥㨱甠慮敭›潣浭湡⁤潮⁴潦湵੤
[2023-03-11 14:04:02.404] Launching C:\WINDOWS\System32\wsl.exe -d NixOS sh -c '"$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh" 5e805b79fcb6ba4c2d23712967df89a089da575b stable code-server .vscode-server --host=:: --print-ip-address --port=0 --connection-token=1574352636-3755954077-1501434474-266153846 --use-host-proxy --without-browser-env-var --disable-websocket-compression --accept-server-license-terms --telemetry-level=all'
[2023-03-11 14:04:03.015] Setting up server environment: Looking for /home/i97henka/.vscode-server/server-env-setup. Not found.
[2023-03-11 14:04:03.015] WSL version:  NixOS
[2023-03-11 14:04:03.016] /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 14:04:03.016] /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 14:04:03.033] /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 14:04:03.033] VS Code Server for WSL closed unexpectedly.
[2023-03-11 14:04:03.033] For help with startup problems, go to https://code.visualstudio.com/docs/remote/troubleshooting#_wsl-tips
[2023-03-11 14:04:03.050] WSL Daemon exited with code 0
[2023-03-11 14:05:24.901] Download in background is enabled
Hello. I also just ran into this issue. Are you running nativeSystemd? Disabling that fixed the issue for me(though obviously this is not an ideal solution)
05:50:51
@i97henka:matrix.orghenrik-ch
In reply to @purewaterisme:matrix.org
Hello. I also just ran into this issue. Are you running nativeSystemd? Disabling that fixed the issue for me(though obviously this is not an ideal solution)

Thank you very much for sharing 🙏 purewaterisme.
I managed to get something working now, but it feels like a bad case of cargo-culting, as I don't understand why many of the steps that I took were needed 🤣.

Here my latest configuration.nix:

{ pkgs, config, modulesPath, ... }:

let
  #nixvim = import (builtins.fetchGit {
  #  url = "https://github.com/pta2002/nixvim";
  #});
  nixos-wsl = import ./nixos-wsl;
in
{
  imports = [
    #nixvim.nixosModules.nixvim
    nixos-wsl.nixosModules.wsl
    <home-manager/nixos>
  ];

  wsl = {
    enable = true;
    nativeSystemd = false;
    wslConf.automount.root = "/mnt";
    defaultUser = "i97henka";
    startMenuLaunchers = true;

  };

  # Enable nix flakes
  nix.package = pkgs.nixFlakes;
  nix.extraOptions = ''
    experimental-features = nix-command flakes
  '';

  users.users.i97henka = {
    isNormalUser = true;
    extraGroups = [ "wheel"];
  };


  home-manager.users.i97henka = { pkgs, ... }: {
    home.stateVersion = "22.11";
    home.packages = [ pkgs.jq pkgs.ripgrep pkgs.gh ];
 
    nixpkgs.config.allowUnfree = true;

    programs.bash = {
      enable = true;
      shellAliases = {
        ll = "ls -l";
        ".." = "cd ..";
        gst = "git status";
        glo = "git log --oneline";
        gfa = "git fetch --all";
        ggfl = "git push --force-with-lease";
      };
    };

    programs.git.enable = true;
    programs.direnv.enable = true;
    programs.direnv.nix-direnv.enable = true;
    programs.fzf.enable = true;
    programs.bat.enable = true;

    programs.vscode.enable = true;

    programs.neovim = {
      enable = true;
      defaultEditor = true;
      viAlias = true;
      vimAlias = true;
      vimdiffAlias = true;
    };
  };


  environment.systemPackages = with pkgs; [
    bat
    git
    vim
    wget
  ];

  programs.nix-ld.enable = true;

  programs.gnupg.agent = {
    enable = true;
    enableSSHSupport = true;
    pinentryFlavor = "curses";
  };

  system.stateVersion = "22.11";
}

What is very interesting and unexpected about this for me - it's running the linux version of vscode, so "pure wsl", rather than running a server and hosting the gui in the windows.
I hope that it gets clearer what I mean when I post a screenshot in the next step.

09:02:53
@i97henka:matrix.orghenrik-chIt's the first wsl gui app that I ever have run, I don't have a unix windows manager installed afaik. 09:05:23
@i97henka:matrix.orghenrik-chwsl_vscode_gui.png
Download wsl_vscode_gui.png
09:05:33
@i97henka:matrix.orghenrik-ch
In reply to @purewaterisme:matrix.org
Hello. I also just ran into this issue. Are you running nativeSystemd? Disabling that fixed the issue for me(though obviously this is not an ideal solution)
*

Thank you very much for sharing 🙏 purewaterisme.
I managed to get something working now, but it feels like a bad case of cargo-culting, as I don't understand why many of the steps that I took were needed 🤣.

Here my latest configuration.nix:

{ pkgs, config, modulesPath, ... }:

let
  #nixvim = import (builtins.fetchGit {
  #  url = "https://github.com/pta2002/nixvim";
  #});
  nixos-wsl = import ./nixos-wsl;
in
{
  imports = [
    #nixvim.nixosModules.nixvim
    nixos-wsl.nixosModules.wsl
    <home-manager/nixos>
  ];

  wsl = {
    enable = true;
    nativeSystemd = false;
    wslConf.automount.root = "/mnt";
    defaultUser = "i97henka";
    startMenuLaunchers = true;

  };

  # Enable nix flakes
  nix.package = pkgs.nixFlakes;
  nix.extraOptions = ''
    experimental-features = nix-command flakes
  '';

  users.users.i97henka = {
    isNormalUser = true;
    extraGroups = [ "wheel"];
  };


  home-manager.users.i97henka = { pkgs, ... }: {
    home.stateVersion = "22.11";
    home.packages = [ pkgs.jq pkgs.ripgrep pkgs.gh ];
 
    nixpkgs.config.allowUnfree = true;

    programs.bash = {
      enable = true;
      shellAliases = {
        ll = "ls -l";
        ".." = "cd ..";
        gst = "git status";
        glo = "git log --oneline";
        gfa = "git fetch --all";
        ggfl = "git push --force-with-lease";
      };
    };

    programs.git.enable = true;
    programs.direnv.enable = true;
    programs.direnv.nix-direnv.enable = true;
    programs.fzf.enable = true;
    programs.bat.enable = true;

    programs.vscode.enable = true;

    programs.neovim = {
      enable = true;
      defaultEditor = true;
      viAlias = true;
      vimAlias = true;
      vimdiffAlias = true;
    };
  };


  environment.systemPackages = with pkgs; [
    bat
    git
    vim
    wget
  ];

  programs.nix-ld.enable = true;

  programs.gnupg.agent = {
    enable = true;
    enableSSHSupport = true;
    pinentryFlavor = "curses";
  };

  system.stateVersion = "22.11";
}

What is very interesting and unexpected about this for me - it's running the linux version of vscode, so "pure wsl", rather than running a server and hosting the gui in the windows instance.
I hope that it gets clearer what I mean when I post a screenshot in the next step.

09:06:17
@i97henka:matrix.orghenrik-ch

More of a curiousity than a real problem:
After deactivating nativeSystemd, the prompt to launch the shell changed.

Previously, it worked to launch like this:
C:\WINDOWS\system32\wsl.exe -d NixOS -u i97henka

and now the user has to be omitted like this:
C:\WINDOWS\system32\wsl.exe -d NixOS

In both cases I land in a prompt logged in as i97henka, I assume because of the defaultUser = "i97henka"; setting in the configuration file.

09:32:27
@k900:0upti.meK900Yes, that is normal 10:04:39
@k900:0upti.meK900Also, I think I have an idea of why that's happening 10:04:55
@k900:0upti.meK900Though I'm not sure how to fix that automatically 10:05:01
@pederbs:pvv.ntnu.nopbsds joined the room.13:10:23
@nzbr:nzbr.deArson Copperflame
In reply to @k900:0upti.me
You could also set them manually, but generally it might be a better idea to run unstable, as that's what nixos-wsl is mostly tested against
Is it? All the tests run against stable and that's what I'm running as well. It's probably true for anything related to nativeSystemd though, because we can't run the tests against that (yet)
16:26:50
@sandro:supersandro.deSandro 🐧We should disable udev again. It draws in a lot https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/services/hardware/udev.nix#L355-L45516:27:18

Show newer messages


Back to Room ListRoom Version: 9