-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Nix doesn't work in Github Codespaces #6680
Comments
If I found this issue first, I wouldn't bother to try nix in codespaces but since I have spent few hours trying to get nix working in codespaces, I will share here what I have got so far. This is my Dockerfile:-
For some reason, |
Ughh, building indeed failed. Mine above is working because I'm using cachix so all our packages already built. Try running without cachix and I got similar error:-
|
@k4ml have you found a workaround yet? |
This is the failing check: nix/src/libstore/build/local-derivation-goal.cc Lines 2178 to 2188 in 3c57db1
What do the permissions of that build |
How do I check the permissions for that
I try setting the build user in /etc/nix/nix.conf but also no use:-
|
Can you use |
@k4ml tried same. also tried to set chown vscode:root (like on my wsl ubuntu). no help. tried variations of I think check is broken. Because it allows to install but fails then to build. But if install was suspicions and security issue, than any check later is useless - it was hacked on install. So these checks should be made on par - i.e. same level of security. NixOS/nixpkgs#82357 (comment) |
|
UPDATE: https://gist.github.com/dzmitry-lahoda/4c9b5f4a04a855efa6fc8f5449aadede |
|
Did not help
Tried to read C++ code - no comprehend. 🦀 |
|
will donate 10 DOT Polkadot for fix |
This would be very interesting to build codespace based dev containers. Any chance someone experienced with the low-level issue check this out? |
It's also a big blocker for our team. We really want to use |
@cor @hussein-aitlahcen does this devcontainer image work for you https://github.com/xtruder/nix-devcontainer? I have tested in github codespaces and it seems to work without issues. Here is example project: https://github.com/xtruder/nix-devcontainer-python-jupyter |
It’s broken the same way for me (builds fail, but cached results are fine). Same config works locally in VSCode - only codespaces seems broken. |
That error is very clear: The ownership of the nix store path is not what nix expects.
which is confirmed by this.
The file nix tried to download has no executable bit set. What is / in codespaces? Is this some mounted filesystem which enforces permissions and/or has noexec set? What is the output of mount? |
I bake container with nix https://github.com/ComposableFi/composable/blob/dz/byog-container/Dockerfile . Hey there is no error about mutli user. I run it with https://github.com/ComposableFi/composable/blob/dz/byog-container/.devcontainer/devcontainer.json . In local VS Code -> Remote-Containers : Rebuild and Reopen. It opens. I can:
If I open GitHub page and click Codespace. And run same configuraiton remotely.
So problem is you can build container, but cannot use nix in it. You may look into my report. I tried many kinds of permissions and owners, did not helped. Why remote differs from local? I do not know. |
@SuperSandro2000 what exactly nix expects? If I would know, I would chown/chmod. |
As per line, nix/src/libstore/build/local-derivation-goal.cc Line 2207 in ddb82ff
need this
tied. possible nix itself produced new files which are g+w? |
this tells nix/src/libstore/build/local-derivation-goal.cc Line 2208 in ddb82ff
there is current build user who and the files was not produced by she. Line 32 in 2fef24f
so take build group from config, and find all users in that group and take some free user. -L --show-trace to not show debug level info. would be nice is this case. or there is more flags? |
i have ideas how to debug futher, but bad I cannot have low level logs. |
PS It would be nice if you could edit previous comments to append new information. |
@SuperSandro2000 nix is running in single user mode here, |
So it turns out default file permissions are set on $ getfacl /tmp
getfacl: Removing leading '/' from absolute path names
# file: tmp
# owner: root
# group: root
# flags: --t
user::rwx
group::rwx
other::rwx
default:user::rwx
default:group::r-x
default:other::rw- This will set invalid permissions in temporary build files created inside $ ls -la /tmp/nix-build-a.drv-0
total 20
drwxrwxr-x+ 2 vscode vscode 4096 Aug 29 21:23 .
drwxrwxrwt 12 root root 4096 Aug 29 21:31 ..
-rw-rwxrw- 1 vscode vscode 215 Aug 29 21:23 .attr-0l2nkwhif96f51f4amnlf414lhl4rv9vh8iffyp431v6s28gsr90
-rw-rwxrw- 1 vscode vscode 4410 Aug 29 21:23 env-vars To fix this you we have to remove default permissions by running setfacl -k /tmp This will indeed remove default permissions $ getfacl /tmp
getfacl: Removing leading '/' from absolute path names
# file: tmp
# owner: root
# group: root
# flags: --t
user::rwx
group::rwx
other::rwx This also requires RUN sudo apt install -y acl && sudo setfacl -k /tmp Of course we want to put this into base image. Now we can successfully run nix-build --keep-failed -E 'with import <nixpkgs> {}; writeText "a" "test1234"'
this derivation will be built:
/nix/store/ijwhizywnj2z9ihw6fks35kza7v13all-a.drv
building '/nix/store/ijwhizywnj2z9ihw6fks35kza7v13all-a.drv'...
/nix/store/fkh5gjh1f76686l0zjyv482zv8874l7r-a
ls -la /nix/store/fkh5gjh1f76686l0zjyv482zv8874l7r-a
-r--r--r-- 1 vscode vscode 4 Jan 1 1970 /nix/store/fkh5gjh1f76686l0zjyv482zv8874l7r-a |
@offlinehacker we are on flake and used home-manager. so, i see:
|
@Chuxel this workaround (using |
by the way. devenv seems work well. |
also try zero to nix installer |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/github-codespace-support/27152/2 |
I had issue with the official Nix installer on Amazon Workspace... I reported the issue here and here... and it has been fixed in DeterminateSystem installer. I would give it a try on Github Codespaces and see if it works: https://github.com/DeterminateSystems/nix-installer |
side note - We've brought this up with the github team today and they will be taking a look at this |
It's still broken in Codespaces as far as I can tell. I tried with "jammy" and "bullseye" variants of the universal image. |
you can check attached discord comment. it works with home manager in docker build approach. the only thing i still not done, source env vars into codespace session. i need some libs to be in env. local docker seems worked too. i was able to make vscode to consume nix installed tools, docker in docker feature works, nix run and nix build work, can bake anything into home manager for caching, code space super close to flake develop so codespace is close to local develop, sure profile install and home switch. lacking only session variables(why it is so hard?) and generator of codespace definion from nix(super easy). nix codespace feature miles behind this. likely new nix installer will simplify docker setup. also, i would perfer MS to allow to run VM images. so i can run same image in codespace or in cloud or local vm created via nixos generator with modules. docker sucks. just give me good azure and hyperv image builder) |
for some reason home manager inject into session variables glibc and some locales, but does not sources this into profiles. if i source it along with my variables, vscode fails (seems like conflict of libs). so I source only i know needed
|
It works okay for me with this in my
There might be a more minimal version that works but I didn't care to try to minimize. |
you say that when vscode on remote codespace popups, its plugins catch up whatever tooling and environment variables you have put for people into nix shell? the need is nix, and nix to install exact versions of all compilers, lsps, renders, optimizers, etc for users on start fast |
Never mind, it isn't working for me after all, sorry. |
So I've been experimenting with this starting with @aryairani's config above. My setup now is:
|
See also [GitHub Codespace Support - NixOS Discourse](https://discourse.nixos.org/t/github-codespace-support/27152/3) [Nix doesn't work in Github Codespaces · Issue #6680 · NixOS/nix · GitHub](NixOS/nix#6680 (comment))
See also [GitHub Codespace Support - NixOS Discourse](https://discourse.nixos.org/t/github-codespace-support/27152/3) [Nix doesn't work in Github Codespaces · Issue #6680 · NixOS/nix · GitHub](NixOS/nix#6680 (comment))
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/nixos-in-github-codespaces/36065/2 |
This comment was marked as outdated.
This comment was marked as outdated.
So everything works except that I still get this error for packages that use |
Describe the bug
Using the default Codespaces environment/image without any configuration, it is possible to install Nix in single-user mode using the
sh <(curl -L https://nixos.org/nix/install) --no-daemon
command. Then the Nix commands are accessible and appear to work, but building anything fails. For example, runningproduces the enigmatic error
Attempting to install Nix in multi-user mode fails with the error message
Expected behavior
Running Nix in Github Codespaces is probably something that a lot of people will want to do. Even if it is the case that Nix can't support it, it would probably be helpful to have some documentation that states that it is unsupported and/or describes potential workarounds.
Edit: A solution found by @offlinehacker is to first run
sudo apt install -y acl && sudo setfacl -k /tmp
. Then Nix can be installed normally and building things will succeed. See #6680 (comment).The text was updated successfully, but these errors were encountered: