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

jetbrains: add plugin support #223593

Merged

Conversation

GenericNerdyUsername
Copy link
Contributor

@GenericNerdyUsername GenericNerdyUsername commented Mar 28, 2023

Description of changes

This commit adds support for declarative plugins (including ones which need patching). Untested on darwin. Closes #189183. Overhaul of #191341. Merged in #240521.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Copy link
Member

@edwtjo edwtjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Letting this sit a week for comments. LGTM, good job! Minor nitpick; run nixfmt on nix files.

@GenericNerdyUsername
Copy link
Contributor Author

Is the formatter for nixpkgs nix fmt or nixpkgs-fmt?

@GenericNerdyUsername
Copy link
Contributor Author

@edwtjo reminder

"8182" = {
# Rust
nativeBuildInputs = [ autoPatchelfHook ];
commands = ''
Copy link

@Staff-d Staff-d Apr 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @GenericNerdyUsername,

first of all: thanks for this great PR!

While trying to get the Github Copilot plugin to work with your changes I noticed that the contents of the commands attribute are never evaluated as these values are folded into the mkDerivation parameters in mkPlugin. It seems to be a leftover from your old, closed PR where you used this in attribute to construct a custom buildPhase. Am I missing something or should buildPhase be used here instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, youre absolutely right, ill fix this straight away

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be done, I built all the IDEs with the rust plugin but I might've missed something, lmk if the change breaks your copilot setup

@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/clion-github-copilot-fails-to-login/22197/11

@pbek pbek self-requested a review April 23, 2023 05:32
@pbek
Copy link
Contributor

pbek commented Apr 23, 2023

I pulled nixpkgs, checked out the PR and built it with NIXPKGS_ALLOW_UNFREE=1 nix-build -A jetbrains.clion. I ran the resulted binary.

For a short time the github copilot icon was showing, but then it was crossed out again.
I got theses errors:

Exception in thread "DefaultDispatcher-worker-21" com.intellij.openapi.progress.ProcessCanceledException
        at com.intellij.openapi.progress.EmptyProgressIndicatorBase.checkCanceled(EmptyProgressIndicatorBase.java:57)
        at com.jetbrains.cidr.lang.parser.OCParser.computeSyncWithEDTPriority(OCParser.java:369)
        at com.jetbrains.cidr.lang.parser.OCParser.parse(OCParser.java:214)
        at com.jetbrains.cidr.lang.parser.OCFileElementType.parseContents(OCFileElementType.java:23)
        at com.intellij.psi.impl.source.tree.LazyParseableElement.lambda$ensureParsed$2(LazyParseableElement.java:185)
        at com.intellij.psi.impl.DebugUtil.performPsiModification(DebugUtil.java:481)
        at com.intellij.psi.impl.source.tree.LazyParseableElement.ensureParsed(LazyParseableElement.java:184)
        at com.intellij.psi.impl.source.tree.LazyParseableElement.getFirstChildNode(LazyParseableElement.java:236)
        at com.intellij.psi.impl.source.tree.CompositeElement.findLeafElementAt(CompositeElement.java:126)
        at com.intellij.psi.impl.source.tree.CompositeElement.findLeafElementAt(CompositeElement.java:33)
        at com.intellij.psi.AbstractFileViewProvider.findElementAt(AbstractFileViewProvider.java:242)
        at com.intellij.psi.AbstractFileViewProvider.findElementAt(AbstractFileViewProvider.java:212)
        at com.jetbrains.cidr.lang.psi.impl.OCFileImpl.findElementAt(OCFileImpl.java:79)
        at com.intellij.ide.navigationToolbar.StructureAwareNavBarModelExtension.getLeafElement(StructureAwareNavBarModelExtension.kt:37)
        at com.intellij.ide.navbar.actions.DefaultNavBarItemDataRule$getData$1.invoke(DefaultNavBarItemDataRule.kt:24)
        at com.intellij.ide.navbar.actions.DefaultNavBarItemDataRule$getData$1.invoke(DefaultNavBarItemDataRule.kt:24)
        at com.intellij.ide.navbar.impl.DefaultNavBarItemProviderKt.fromOldExtensions(DefaultNavBarItemProvider.kt:135)
        at com.intellij.ide.navbar.actions.DefaultNavBarItemDataRule.getData(DefaultNavBarItemDataRule.kt:24)
        at com.intellij.ide.navbar.actions.DefaultNavBarItemDataRule.getData(DefaultNavBarItemDataRule.kt:17)
        at com.intellij.ide.impl.DataManagerImpl.getRulesData(DataManagerImpl.java:210)
        at com.intellij.ide.impl.DataManagerImpl.lambda$getDataRuleInner$8(DataManagerImpl.java:183)
        at com.intellij.ide.impl.DataManagerImpl.getDataFromRuleInner(DataManagerImpl.java:112)
        at com.intellij.ide.impl.DataManagerImpl.getDataFromRulesInner(DataManagerImpl.java:99)
        at com.intellij.ide.impl.DataManagerImpl.getDataFromRules(DataManagerImpl.java:67)
        at com.intellij.openapi.actionSystem.impl.PreCachedDataContext.getData(PreCachedDataContext.java:172)
        at com.intellij.openapi.actionSystem.impl.PreCachedDataContext$InjectedDataContext.getData(PreCachedDataContext.java:382)
        at com.intellij.openapi.actionSystem.DataKey.getData(DataKey.java:63)
        at com.intellij.ide.navbar.ide.NavBarServiceKt.contextModelInner(NavBarService.kt:152)
        at com.intellij.ide.navbar.ide.NavBarServiceKt.access$contextModelInner(NavBarService.kt:1)
        at com.intellij.ide.navbar.ide.NavBarServiceKt$contextModel$2.invoke(NavBarService.kt:136)
        at com.intellij.ide.navbar.ide.NavBarServiceKt$contextModel$2.invoke(NavBarService.kt:135)
        at com.intellij.openapi.application.rw.InternalReadAction.insideReadAction(InternalReadAction.kt:108)
        at com.intellij.openapi.application.rw.InternalReadAction.access$insideReadAction(InternalReadAction.kt:15)
        at com.intellij.openapi.application.rw.InternalReadAction$tryReadCancellable$1.invoke(InternalReadAction.kt:92)
        at com.intellij.openapi.application.rw.InternalReadAction$tryReadCancellable$1.invoke(InternalReadAction.kt:91)
        at com.intellij.openapi.progress.CancellationKt.withCurrentJob$lambda$0(cancellation.kt:17)
        at com.intellij.openapi.progress.Cancellation.withCurrentJob(Cancellation.java:60)
        at com.intellij.openapi.progress.CancellationKt.withCurrentJob(cancellation.kt:17)
        at com.intellij.openapi.progress.CancellationKt.executeWithJobAndCompleteIt(cancellation.kt:126)
        at com.intellij.openapi.application.rw.CancellableReadActionKt.cancellableReadActionInternal$lambda$1$lambda$0(cancellableReadAction.kt:49)
        at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1102)
        at com.intellij.openapi.application.rw.CancellableReadActionKt.cancellableReadActionInternal$lambda$1(cancellableReadAction.kt:47)
        at com.intellij.openapi.progress.util.ProgressIndicatorUtilService.runActionAndCancelBeforeWrite(ProgressIndicatorUtilService.java:63)
        at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runActionAndCancelBeforeWrite(ProgressIndicatorUtils.java:129)
        at com.intellij.openapi.application.rw.CancellableReadActionKt.cancellableReadActionInternal(cancellableReadAction.kt:45)
        at com.intellij.openapi.application.rw.InternalReadAction.tryReadCancellable(InternalReadAction.kt:91)
        at com.intellij.openapi.application.rw.InternalReadAction.access$tryReadCancellable(InternalReadAction.kt:15)
        at com.intellij.openapi.application.rw.InternalReadAction$tryReadAction$2.invoke(InternalReadAction.kt:77)
        at com.intellij.openapi.application.rw.InternalReadAction$tryReadAction$2.invoke(InternalReadAction.kt:72)
        at com.intellij.openapi.progress.CancellationKt.withCurrentJob$lambda$0(cancellation.kt:17)
        at com.intellij.openapi.progress.Cancellation.withCurrentJob(Cancellation.java:60)
        at com.intellij.openapi.progress.CancellationKt.withCurrentJob(cancellation.kt:17)
        at com.intellij.openapi.progress.CoroutinesKt.blockingContext(coroutines.kt:193)
        at com.intellij.openapi.application.rw.InternalReadAction.tryReadAction(InternalReadAction.kt:72)
        at com.intellij.openapi.application.rw.InternalReadAction.readLoop(InternalReadAction.kt:64)
        at com.intellij.openapi.application.rw.InternalReadAction.access$readLoop(InternalReadAction.kt:15)
        at com.intellij.openapi.application.rw.InternalReadAction$runReadAction$4.invokeSuspend(InternalReadAction.kt:43)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
        Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [CoroutineName(com.intellij.ide.navbar.ide.NavBarService), StandaloneCoroutine{Cancelling}@342edfa7, LimitedDispatcher@43eafa7]

and

2023-04-23 07:44:35,164 [  45887]   WARN - #com.github.copilot.lang.agent.AgentGitHubService - error retrieving device code
org.jetbrains.concurrency.MessageError: service is unavailable

Did I miss something? (I'm relatively new to NixOS)

@GenericNerdyUsername
Copy link
Contributor Author

I think the github copilot plugin needs special treatment (patching a binary)

@GenericNerdyUsername
Copy link
Contributor Author

Does that work?

@pbek
Copy link
Contributor

pbek commented Apr 23, 2023

Does that work?

I still get:

2023-04-23 14:01:44,015 [  67236]   WARN - #com.github.copilot.lang.agent.AgentGitHubService - error retrieving device code
org.jetbrains.concurrency.MessageError: service is unavailable

@pbek
Copy link
Contributor

pbek commented Apr 23, 2023

Does that work?

I just checked out your changes to the PR and built again, if that was what you where asking for...

@GenericNerdyUsername
Copy link
Contributor Author

Did this attempt work?

@pbek
Copy link
Contributor

pbek commented Apr 23, 2023

Did this attempt work?

I still get:

2023-04-23 16:32:03,568 [  36310]   WARN - #com.github.copilot.lang.agent.AgentGitHubService - error retrieving device code
org.jetbrains.concurrency.MessageError: service is unavailable

@pbek
Copy link
Contributor

pbek commented Apr 23, 2023

The last commit I see is:

commit 79d6b66afeefb2101dd0493ebf20d14261682a84 (HEAD -> jetbrains-plugins-overhauled)
Author: GenericNerdyUsername <genericnerdyusername@proton.me>
Date:   Tue Mar 28 16:23:01 2023 +0100

    jetbrains: add plugin support

@GenericNerdyUsername
Copy link
Contributor Author

GenericNerdyUsername commented Apr 23, 2023

How are you installing the plugin? it works fine on my end. This PR is for declarative plugin support, not plugin support in general. What you're looking for is probably along the lines of with packages.jetbrains; plugins.addPlugins clion [ "17718" ].

@pbek
Copy link
Contributor

pbek commented Apr 23, 2023

How are you installing the plugin? it works fine on my end

Directly from the jetbrains marketplace in the plugins section of the clion settings. Is there a better way to do it in NixOS?

@GenericNerdyUsername
Copy link
Contributor Author

This PR can't modify plugins fetched through the settings pane. Instead, you specify the plugins you want before installing clion, then it creates a clion install with those plugins bundled.

@pbek
Copy link
Contributor

pbek commented Apr 23, 2023

I see, thank you. Do you maybe have an example on how to implement that in my configuration.nix?

@GenericNerdyUsername
Copy link
Contributor Author

put (jetbrains.plugins.addPlugins jetbrains.clion [ "17718" ]) in the list of entries in environment.systemPackages

@pbek
Copy link
Contributor

pbek commented Apr 23, 2023

After adding the like I tried building my configuration with nixos-rebuild -I nixpkgs=<path-to-nixpgs-with-pr> switch and got the error:

error: Could not resolve plugin 17718

I also tried 17718-github-copilot just to make sure, similar error.

@Janik-Haag Janik-Haag force-pushed the jetbrains-plugins-overhauled branch from c6944a7 to c3c3a9b Compare June 28, 2023 17:23
@Janik-Haag Janik-Haag requested review from pbek and edwtjo June 28, 2023 17:24
@Janik-Haag
Copy link
Member

Janik-Haag commented Jun 28, 2023

I took the liberty of rebasing since @GenericNerdyUsername didn't respond, and re requested review of some people, I will merge this if they say the changes are fine and ci runs through.

@pbek
Copy link
Contributor

pbek commented Jun 28, 2023

On it...

Copy link
Contributor

@pbek pbek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just integrated commit c3c3a9b into my nixcfgs!
Latest clion, phpstorm and goland still work great with GitHub Copilot! 🥳

@Janik-Haag
Copy link
Member

Hm but ofborg is complaining, I'm going to take a look once I'm at my laptop again.

@pbek
Copy link
Contributor

pbek commented Jun 28, 2023

Hm but ofborg is complaining, I'm going to take a look once I'm at my laptop again.

Yes, strange. I got similar errors too when trying to build with nixpkgs-review first, I thought it was an issue on my end. But it worked great directly in my nixcfg...

       … while calling 'mkAttrOverridable'

         at /home/omega/.cache/nixpkgs-review/pr-223593-4/nixpkgs/lib/customisation.nix:185:33:

          184|       pkgs = f origArgs;
          185|       mkAttrOverridable = name: _: makeOverridable (newArgs: (f newArgs).${name}) origArgs;
             |                                 ^
          186|     in

       … from call site

         at /home/omega/.cache/nixpkgs-review/pr-223593-4/nixpkgs/lib/customisation.nix:185:36:

          184|       pkgs = f origArgs;
          185|       mkAttrOverridable = name: _: makeOverridable (newArgs: (f newArgs).${name}) origArgs;
             |                                    ^
          186|     in

       … while calling 'makeOverridable'

         at /home/omega/.cache/nixpkgs-review/pr-223593-4/nixpkgs/lib/customisation.nix:72:24:

           71|   */
           72|   makeOverridable = f: origArgs:
             |                        ^
           73|     let

       … from call site

         at /home/omega/.cache/nixpkgs-review/pr-223593-4/nixpkgs/lib/customisation.nix:74:16:

           73|     let
           74|       result = f origArgs;
             |                ^
           75|

       … while calling anonymous lambda

         at /home/omega/.cache/nixpkgs-review/pr-223593-4/nixpkgs/lib/customisation.nix:185:53:

          184|       pkgs = f origArgs;
          185|       mkAttrOverridable = name: _: makeOverridable (newArgs: (f newArgs).${name}) origArgs;
             |                                                     ^
          186|     in

       … from call site

         at /home/omega/.cache/nixpkgs-review/pr-223593-4/nixpkgs/pkgs/applications/editors/jetbrains/default.nix:344:15:

          343|
          344|   dataspell = buildDataSpell rec {
             |               ^
          345|     pname = "dataspell";

       … while calling 'buildDataSpell'

         at /home/omega/.cache/nixpkgs-review/pr-223593-4/nixpkgs/pkgs/applications/editors/jetbrains/default.nix:102:22:

          101|
          102|     buildDataSpell = { pname, version, src, license, description, wmClass, ... }:
             |                      ^
          103|       (mkJetBrainsProduct {

       error: function 'anonymous lambda' called without required argument 'buildNumber'

       at /home/omega/.cache/nixpkgs-review/pr-223593-4/nixpkgs/pkgs/applications/editors/jetbrains/linux.nix:19:1:

           18|
           19| { pname
             | ^
           20| , product

@SuperSandro2000 SuperSandro2000 merged commit 1ceca71 into NixOS:master Jun 29, 2023
3 of 5 checks passed
@Janik-Haag
Copy link
Member

@SuperSandro2000 why did you merge this?

@GenericNerdyUsername
Copy link
Contributor Author

This isnt ready for merge yet, I made the changes needed, but github is refusing the push bc its too big, so im trying it in chunks

@Janik-Haag
Copy link
Member

GH being very buggy right now
image

@pbek
Copy link
Contributor

pbek commented Jun 29, 2023

Do we need a new PR? 😁

@Janik-Haag
Copy link
Member

Janik-Haag commented Jun 29, 2023

Probably, It doesn't let me revert this one so we can't later merge the currently still in progress changes.

@GenericNerdyUsername
Copy link
Contributor Author

Is anyone else going to make the pr, or should I?

@Janik-Haag
Copy link
Member

Feel free to go ahead and make one, just link this one in the description :D

@wusticality
Copy link

First of all, let me say how grateful I am that I found this PR. Having Github Copilot working again is a total godsend.

Apologies for my naiveté, but is this PR the only place where any of this functionality is documented? I'm just wondering if there are instructions elsewhere, and if the number 17718 is totally arbitrary and whether it's consistent. I'm doing this:

(jetbrains.plugins.addPlugins jetbrains.clion [ "17718" ])

@cpu
Copy link
Contributor

cpu commented Oct 24, 2023

if the number 17718 is totally arbitrary and whether it's consistent. I'm doing this:
(jetbrains.plugins.addPlugins jetbrains.clion [ "17718" ])

@wusticality I'm not sure about the documentation question, but you should be able to avoid the magic number by specifying the plugin by name. I'm using the following in my config:

(jetbrains.plugins.addPlugins jetbrains.clion [ "github-copilot" ])

@pbek
Copy link
Contributor

pbek commented Oct 25, 2023

I also just use "github-copilot".

@GenericNerdyUsername
Copy link
Contributor Author

First of all, let me say how grateful I am that I found this PR. Having Github Copilot working again is a total godsend.

Apologies for my naiveté, but is this PR the only place where any of this functionality is documented? I'm just wondering if there are instructions elsewhere, and if the number 17718 is totally arbitrary and whether it's consistent. I'm doing this:

(jetbrains.plugins.addPlugins jetbrains.clion [ "17718" ])

The number is the plugin ID (the link for the plugin is https://plugins.jetbrains.com/plugin/17718-github-copilot)

I have added some docs (though I really should add them to the manual), but they're waiting to be merged, along with some other stuff, in #259373

@Krutonium
Copy link
Contributor

I can't get this to work with anything other than copilot myself, for example https://plugins.jetbrains.com/plugin/13882-godot-support
I've tried 13882 and com.intellij.rider.godot, as well as
https://plugins.jetbrains.com/plugin/14839-avaloniarider
14839 and avalonia-rider which also didn't work.

@SuperSandro2000
Copy link
Member

Can you post some logs?

@GenericNerdyUsername
Copy link
Contributor Author

@Krutonium the overhaul just got merged, take a look at the readme

@Krutonium
Copy link
Contributor

Just checked back, Let's have a look... Ah that Readme is quite good!

@SuperSandro2000 WRT Logs, it was literally just a notification of the plugin not being found.

@wusticality
Copy link

(jetbrains.plugins.addPlugins jetbrains.clion [ "github-copilot" ])

This for this, much appreciated. :)

@spy4x
Copy link

spy4x commented Mar 23, 2024

For those who tried everything above, but couldn't make it work - I found github-copilot-intellij-agent that patches copilot binary to make it work with NixOS.

Just an additional step needed - symlinking the new binary (change IntelliJIdea2022.2 to your IDE model & version, like WebStorm2023.2):

ln -fs /run/current-system/sw/bin/copilot-agent ~/.local/share/JetBrains/IntelliJIdea2022.2/github-copilot-intellij/copilot-agent/bin/copilot-agent-linux

@vinstonsalim
Copy link

@spy4x i worked !!! on at least on my PhpStorm ver 2023.2

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

Successfully merging this pull request may close these issues.

Jetbrains IDEs with plugins?