nix-community / nix-vscode-extensions

Nix expressions for VSCode and OpenVSX extensions [maintainers: @deemp, @AmeerTaweel]
MIT License
206 stars 11 forks source link

Is it possible to use this with `home-manager` without using flakes? #30

Closed sylvesterroos closed 1 year ago

sylvesterroos commented 1 year ago

29 mentions home-manager, however only when using flakes. I currently have no interest in using flakes, so I hope it's possible to use it with a traditional config.

Thanks :smile:

DrymarchonShaun commented 1 year ago

I don't have a nixos system available at the moment but I think this might be what you are looking for?

sylvesterroos commented 1 year ago

Does that indeed apply to home-manager? I'm not very knowledgeable on the Nix language so I have no idea how to translate that to something else.

For example, how do I use that piece of code in something like this:

programs.vscode = {
  enable = true;
  package = pkgs.vscodium;
  extensions = with pkgs.vscode-extensions; [
    dracula-theme.theme-dracula
    vscodevim.vim
    yzhang.markdown-all-in-one
  ];
};

Basically, how would I use the extensions from this repo in this extensions list?

deemp commented 1 year ago

Hi, @hyperspace01!

I don't use home manager. I suggest you first explore the extensions attrset in repl.

nix-repl> t = (import (builtins.fetchGit {
            url = "https://github.com/nix-community/nix-vscode-extensions";
            ref = "refs/heads/master";
            rev = "c43d9089df96cf8aca157762ed0e2ddca9fcd71e";
          })).extensions

nix-repl> t.x86_64-linux.<TAB>
t.x86_64-linux.forVSCodeVersion            t.x86_64-linux.open-vsx-release            t.x86_64-linux.vscode-marketplace-release
t.x86_64-linux.open-vsx                    t.x86_64-linux.vscode-marketplace

If you use overlays.default on nixpkgs, you should have a pkgs.vscode-extensions and other attrsets.

nix-repl> t = (import (builtins.fetchGit {                                                            
                      url = "https://github.com/nix-community/nix-vscode-extensions";
                      ref = "refs/heads/master";
                      rev = "c43d9089df96cf8aca157762ed0e2ddca9fcd71e";
                    }))
nix-repl> t.overlays.default 
«lambda @ /nix/store/3n6lyzv4jvpaq34qa5j89c9cjmk38dwi-source/flake.nix:33:19»
nix-repl> pkgs = import <nixpkgs> {system = builtins.currentSystem; overlays = [t.overlays.default];}
nix-repl> pkgs.vscod<TAB>
pkgs.vscode                        pkgs.vscode-langservers-extracted  pkgs.vscode-with-extensions
pkgs.vscode-extensions             pkgs.vscode-marketplace            pkgs.vscodium
pkgs.vscode-fhs                    pkgs.vscode-marketplace-release    pkgs.vscodium-fhs
pkgs.vscode-fhsWithPackages        pkgs.vscode-utils                  pkgs.vscodium-fhsWithPackages

Choose the necessary attrset and use like with pkgs.vscode-marketplace;

sylvesterroos commented 1 year ago

I genuinely don't know what's going on here. Is it a nix thing, or is it more likely to be a home-manager thing? I tried googling but I didn't get helpful results. Can you help me out? :)

programs.vscode = {
      enable = true;
      t = (import (builtins.fetchGit {
        url = "https://github.com/nix-community/nix-vscode-extensions";
        ref = "refs/heads/master";
        rev = "c43d9089df96cf8aca157762ed0e2ddca9fcd71e";
      })).extensions
      extensions = [
        t.x86_64-linux.vscodevim.vim
      ];
    };

Error:

syntax error, unexpected '=', expecting ';'

       at /etc/nixos/configuration.nix:153:18:

          152|       })).extensions
          153|       extensions = [
             |                  ^
          154|         t.x86_64-linux.vscodevim.vim
jcszymansk commented 1 year ago

@hyperspace01 You forgot ; at the end of line 152.

But I'd try something like:

extensions = 
  with (import (builtins.fetchGit {
        url = "https://github.com/nix-community/nix-vscode-extensions";
        ref = "refs/heads/master";
        rev = "c43d9089df96cf8aca157762ed0e2ddca9fcd71e";
  })).extensions.x86_64-linux; [
  vscodevim.vim
 ];
deemp commented 1 year ago

@hyperspace01 , you'll be more productive if you study the Nix language basics https://nixos.org/manual/nix/stable/language/constructs.html#language-constructs

sylvesterroos commented 1 year ago

Alright, thanks a lot everyone!