NixOS-WSL icon indicating copy to clipboard operation
NixOS-WSL copied to clipboard

Rancher desktop support

Open x-0D opened this issue 1 year ago • 2 comments

Problem

Rancher desktop integration don't work with nixos distro

Solution

Add support for rancher-desktop integration optional feature flag

x-0D avatar Mar 14 '24 20:03 x-0D

I tried this after seeing you post. If you have Rancher Desktop installed the docker cli is available at /mnt/c/Program Files/Rancher Desktop/resources/resources/linux/bin/ and the docker socket is at /mnt/wsl/rancher-desktop/run/docker.sock.

You can connect by

  • adding /mnt/c/Program Files/Rancher Desktop/resources/resources/linux/bin/ to your PATH
  • setting the DOCKER_HOST env to unix:///mnt/wsl/rancher-desktop/run/docker.sock
  • chowning the permissions on /mnt/wsl/rancher-desktop/run/docker.sock to your user

Everytime rancher restart the permissions on /mnt/wsl/rancher-desktop/run/docker.sock will reset.

I am using home-manager so I put this in my configuration

  home.sessionVariables = {
    DOCKER_HOST = "unix:///mnt/wsl/rancher-desktop/run/docker.sock";
  };
  home.sessionPath = [
    "/mnt/c/Program Files/Rancher Desktop/resources/resources/linux/bin/"
  ];

 home.packages = [
    (pkgs.writeShellScriptBin "rancher-desktop" ''
      echo "starting rancher.."
      /mnt/c/Program\ Files/Rancher\ Desktop/Rancher\ Desktop.exe&
      echo "setting permissions.."
      sudo chown nixos:users /mnt/wsl/rancher-desktop/run/docker.sock
      echo "done!"
    '') 
]

It's a little clunky, but it seems to work. I haven't tested it thoroughly.

jDmacD avatar Apr 12 '24 18:04 jDmacD

Another workaround is to add PATH=$PATH:/run/current-system/sw/bin/

at the beginning of:

C:\Program Files\Rancher Desktop\resources\resources\setup-spin

The write protection needs to be removed before the file can be edited. Afterwards enabling the integration should work the same as with other distros. This should probably be reported to the Rancher Desktop repo and fixed there.

Credit: https://github.com/sonowz/vscode-remote-wsl-nixos/blob/master/server-env-setup

phma4 avatar Jun 11 '24 14:06 phma4