NixOS-WSL
NixOS-WSL copied to clipboard
Rancher desktop support
Problem
Rancher desktop integration don't work with nixos distro
Solution
Add support for rancher-desktop integration optional feature flag
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.sockto 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.
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