Skip to content
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

vscode.fhs: add buildFHSUserEnv wrapped version #99968

Merged
merged 3 commits into from May 2, 2021

Conversation

@jonringer
Copy link
Contributor

@jonringer jonringer commented Oct 7, 2020

Motivation for this change

Extensions commonly use pre-compiled binaries which aren't
aware of the nix store. Using buildFHSUserEnv will allow
for a more "natural" usage of vscode.

EDIT:
To not break users due to FHSUser regressions, I'm instead adding this as a passthru to the original vscode/vscodium flavors.

closes: #73810
closes: #91179

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
@buckley310
Copy link
Contributor

@buckley310 buckley310 commented Oct 8, 2020

This opens and mostly works for me, although unfortunately the UserEnv also applies to vscode's integrated terminal, which would basically break that feature for me. Not sure if that can be fixed.

@mebubo
Copy link
Contributor

@mebubo mebubo commented Oct 8, 2020

I'd like to keep using the unwrapped version. Would it be possible to make this overridable?

@jonringer
Copy link
Contributor Author

@jonringer jonringer commented Oct 9, 2020

I'd like to keep using the unwrapped version. Would it be possible to make this overridable?

it's on the passthru vscode.unwrapped

@jonringer
Copy link
Contributor Author

@jonringer jonringer commented Oct 9, 2020

I'm in no hurry to merge this, and it could probably be improved to support the other use cases. Meant for this to be more of a discussion than anything else

@buckley310
Copy link
Contributor

@buckley310 buckley310 commented Oct 9, 2020

Using the unwrapped version seems good enough for me since I already got my plugins working natively.
It does seem desirable to have plugins working out of the box, though. That did cause me some trouble early on.

I wonder if it would be a good idea for discoverability if the unwrapped versions of vscode/vscodium were added to all-packages, so that they would show up on https://search.nixos.org/packages

@jonringer
Copy link
Contributor Author

@jonringer jonringer commented Oct 9, 2020

the other option would be to expose vscode-fhs, but I'm not a big fan of that.

@buckley310 can you give some steps to repro the terminal breaking?

@buckley310
Copy link
Contributor

@buckley310 buckley310 commented Oct 9, 2020

I have gcc in my systemPackages, but when I try and compile a C hello-world from the wrapped vscode terminal gcc returns

ld: cannot find crt1.o: No such file or directory
collect2: error: ld returned 1 exit status

The bash prompt itself is just the bash default bash-4.4$, some hotkeys (ctrl+arrows) and my aliases were not working as well since a lot of the global bashrc stuff doesn't apply to UserEnvs. Some or all of that might be fixable via ~/.bashrc, but I haven't tried.

@jonringer
Copy link
Contributor Author

@jonringer jonringer commented Oct 9, 2020

I'll try to see what I can do, it would be nice for vscode to "just work"

@jonringer jonringer force-pushed the vscode-buildfhsuserenv branch from 41a65db to c31a17d Nov 2, 2020
@jonringer
Copy link
Contributor Author

@jonringer jonringer commented Nov 2, 2020

@buckley310 do you mind trying again. I was able to get my terminal to be similar to my normal terminal

@jonringer
Copy link
Contributor Author

@jonringer jonringer commented Nov 2, 2020

@Atemu @illegalprime do you mind reviewing the bubblewrap changes?

@buckley310
Copy link
Contributor

@buckley310 buckley310 commented Nov 2, 2020

Bash interaction seems all good now.
Gcc issue is still present.
I actually noticed that SSL certificates seem to be problematic now, but maybe that one is just a missing bind in /etc/.

@jonringer
Copy link
Contributor Author

@jonringer jonringer commented Nov 2, 2020

what gcc issues are you having?

@buckley310
Copy link
Contributor

@buckley310 buckley310 commented Nov 2, 2020

echo 'int main(){return 0;}' >a.c ; gcc a.c

fails with

/nix/store/hiwz81i1g3fn3p0acjs042a4h5fri6dh-binutils-2.31.1/bin/ld: cannot find crt1.o: No such file or directory
/nix/store/hiwz81i1g3fn3p0acjs042a4h5fri6dh-binutils-2.31.1/bin/ld: cannot find crti.o: No such file or directory
collect2: error: ld returned 1 exit status

@jonringer
Copy link
Contributor Author

@jonringer jonringer commented Nov 2, 2020

@buckley310 I figured it out, the unwrapped gcc gets put into the environment

@jonringer
Copy link
Contributor Author

@jonringer jonringer commented Nov 2, 2020

the libstdc++.so seems to be present even if I remove any mention of stdenv.

@buckley310 please try again

@jonringer
Copy link
Contributor Author

@jonringer jonringer commented Nov 2, 2020

doing stdenv.cc in targetPkgs does make gcc-wrapped available, but I (for example) don't normally have gcc in my path

@jonringer jonringer force-pushed the vscode-buildfhsuserenv branch from 027eff6 to 803082c Nov 2, 2020
@jonringer
Copy link
Contributor Author

@jonringer jonringer commented Nov 2, 2020

since I have buildFHSUserEnv sourcing your bash terminal. It should be inheriting from your normal shell

@jonringer
Copy link
Contributor Author

@jonringer jonringer commented Nov 2, 2020

pinging vscode extension contributors @eadwu @raboof @mcwitt @austinbutler @oxalica @veprbl

do you all mind testing this?

If you normally track unstable, this should be something like:

home-manager -I nixpkgs=https://github.com/jonringer/nixpkgs/archive/vscode-buildfhsuserenv.tar.gz switch

@jonringer jonringer force-pushed the vscode-buildfhsuserenv branch from 803082c to 51210e7 Nov 2, 2020
@veprbl
Copy link
Member

@veprbl veprbl commented Nov 2, 2020

@jonringer Just in case, I'm not a vscode user. I was only reviewing vscode PR's because it used to be that there was no one else to look at those.

@jonringer
Copy link
Contributor Author

@jonringer jonringer commented Nov 2, 2020

oh, then thank you for your contributions. Sorry for bothering you :)

@ofborg ofborg bot requested a review from Synthetica9 Nov 2, 2020
@austinbutler
Copy link
Contributor

@austinbutler austinbutler commented Nov 6, 2020

Latest commit has resolved the zinputrc error, but still Git is not found. I do have my ZSH aliases though.

how do you have git installed?

I have it configured through home-manager, and it's able to be found

In home manager config in configuration.nix:

programs.git.enable = true;

@nixos-discourse
Copy link

@nixos-discourse nixos-discourse commented Nov 18, 2020

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/new-users-using-nixos-wrong/9973/38

@jonringer
Copy link
Contributor Author

@jonringer jonringer commented Apr 8, 2021

decided to revive this. You can do

vscode.fhs
# or
vscode.fhsWithPackages (pkgs: with pkgs; [ rustup zlib ] )

to either have a minimal environment or one with additional tools that you only care to have a available for vscode.

Been able to use extensions and the terminal fine

@nixos-discourse
Copy link

@nixos-discourse nixos-discourse commented Apr 9, 2021

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/500

pkgs/applications/editors/vscode/generic.nix Outdated Show resolved Hide resolved
@jonringer jonringer force-pushed the vscode-buildfhsuserenv branch 2 times, most recently from 56abf05 to 603bae4 Apr 23, 2021
@jonringer
Copy link
Contributor Author

@jonringer jonringer commented Apr 23, 2021

cc @FRidh @SuperSandro2000

In the current iteration, the existing behavior is preserved. People are able to use the fhs attr to opt-into the fhs environment. I think this is good to merge.

@SuperSandro2000
Copy link
Member

@SuperSandro2000 SuperSandro2000 commented Apr 23, 2021

I can't say anything about this because I don't use vscode in nix or know to much about bubblewrap.

@FRidh
Copy link
Member

@FRidh FRidh commented Apr 23, 2021

I saw you mentioned it as an alternative before but I did not comment that earlier. For discoverability you may want to make it a top-level package instead of a passthru attribute (vscode-fhs?) and extend or replace the description with a note saying how it is different. Both options are fine in my opinion.

FRidh
FRidh approved these changes Apr 23, 2021
jonringer added 2 commits Apr 24, 2021
Allows for processes which fork to not be immediately
killed when the parent process dies.
@jonringer jonringer force-pushed the vscode-buildfhsuserenv branch from 603bae4 to 992844e Apr 24, 2021
@jonringer
Copy link
Contributor Author

@jonringer jonringer commented Apr 24, 2021

I saw you mentioned it as an alternative before but I did not comment that earlier. For discoverability you may want to make it a top-level package instead of a passthru attribute (vscode-fhs?) and extend or replace the description with a note saying how it is different. Both options are fine in my opinion.

did both :)

@ofborg ofborg bot requested a review from turion Apr 24, 2021
Copy link
Contributor

@turion turion left a comment

Package descriptions can be improved

pkgs/applications/editors/vscode/generic.nix Outdated Show resolved Hide resolved
pkgs/applications/editors/vscode/generic.nix Show resolved Hide resolved
@jonringer jonringer force-pushed the vscode-buildfhsuserenv branch from 992844e to 060d025 Apr 25, 2021
@ofborg ofborg bot requested a review from turion Apr 25, 2021
@jonringer
Copy link
Contributor Author

@jonringer jonringer commented May 2, 2021

Well, 7 months later, I think this is a good compromise. The original unwrapped workflow hasn't been altered in any fashion, but users now have the option to use extensions freely within vscode.

Extensions which require additional dependencies can be added with the vscod{e,ium}-fhsWithPackages to create an fhs environment with additional depedencies (e.g. rustup)

@jonringer jonringer merged commit a060b84 into NixOS:master May 2, 2021
19 checks passed
19 checks passed
@github-actions[bot]
tests
Details
@github-actions[bot]
labels
Details
@github-actions[bot]
action
Details
@ofborg[bot]
Evaluation Performance Report Evaluator Performance Report
Details
@github-actions[bot]
Wait for ofborg
Details
@ofborg[bot]
ofborg-eval ^.^!
Details
@ofborg[bot]
ofborg-eval-check-maintainers matching changed paths to changed attrs...
Details
@ofborg[bot]
ofborg-eval-check-meta config.nix: checkMeta = true
Details
@ofborg[bot]
ofborg-eval-darwin nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="060d025"; rev="060d02570254cb4081f0baee4133071d1ddbacab"; } ./pkgs/t
Details
@ofborg[bot]
ofborg-eval-lib-tests nix-build --arg pkgs import ./. {} ./lib/tests/release.nix
Details
@ofborg[bot]
ofborg-eval-nixos nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="060d025"; rev="060d02570254cb4081f0baee4133071d1ddbacab"; } ./nixos/
Details
@ofborg[bot]
ofborg-eval-nixos-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="060d025"; rev="060d02570254cb4081f0baee4133071d1ddbacab"; } ./nixos/
Details
@ofborg[bot]
ofborg-eval-nixos-options nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="060d025"; rev="060d02570254cb4081f0baee4133071d1ddbacab"; } ./nixos/
Details
@ofborg[bot]
ofborg-eval-nixpkgs-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="060d025"; rev="060d02570254cb4081f0baee4133071d1ddbacab"; } ./pkgs/t
Details
@ofborg[bot]
ofborg-eval-nixpkgs-tarball nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="060d025"; rev="060d02570254cb4081f0baee4133071d1ddbacab"; } ./pkgs/t
Details
@ofborg[bot]
ofborg-eval-nixpkgs-unstable-jobset nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="060d025"; rev="060d02570254cb4081f0baee4133071d1ddbacab"; } ./pkgs/t
Details
@ofborg[bot]
ofborg-eval-package-list nix-env -qa --json --file .
Details
@ofborg[bot]
ofborg-eval-package-list-no-aliases nix-env -qa --json --file . --arg config { allowAliases = false; }
Details
@ofborg[bot]
ofborg-eval-started Evaluation started
Details
@jonringer jonringer deleted the vscode-buildfhsuserenv branch May 2, 2021
@nixos-discourse
Copy link

@nixos-discourse nixos-discourse commented May 3, 2021

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/vscod-e-ium-users-you-can-now-use-extensions-without-explicitly-packaging-them-in-nixpkgs/12846/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment