nix-community / nix-vscode-extensions

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

uninstall/ rebuild switch flake does not install extensions consistently #66

Open j4t1nd3r opened 6 months ago

j4t1nd3r commented 6 months ago

Link to my github repo

Original config (on main branch)

I was initially using in home.nix:

    vscode = {
      enable = true;
      extensions = with pkgs.vscode-extensions; [
        jdinhlife.gruvbox
        bbenoist.nix

My issue

Running sudo nixos-rebuild switch --flake nix-fwk-system/#fwk-nixos runs without error. Sometimes rarely an extension installs. If I uninstall the vscode to test reproducibility, rerun the sudo nixos rebuild switch flake... the extension(s) are not reinstalled.

rm ~/.vscode/extensions/extensions.json before rerunning the rebuild switch flake makes no difference. I raised an issue on home-manager github here I also seeked help from a dedicated NixOS discord. Link to my initial message The response was to switch to nix-vscode-extensions.

New config on (side branch)

flake.nix

{
  description = "nixos flake config";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    nixos-hardware.url = "github:NixOS/nixos-hardware/master";
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    plasma-manager = {
      url = "github:pjones/plasma-manager";
      inputs = {
        home-manager.follows = "home-manager";
        nixpkgs.follows = "nixpkgs";
      };
    };
    nix-vscode-extensions.url = "github:nix-community/nix-vscode-extensions";
  };

  outputs = { 
    self,
    nixpkgs,
    nixos-hardware,
    plasma-manager,
    nix-vscode-extensions, 
    ... 
  }@inputs:

  let
    system = "x86-64-linux";

    pkgs = import nixpkgs {
      inherit system; 
      config.allowUnfree = true;
    };

    extensions = inputs.nix-vscode-extensions.extensions.${system};

    in

    {
    nixosConfigurations = {
      fwk-nixos = nixpkgs.lib.nixosSystem {
        specialArgs = { inherit inputs system; };

        modules = [
        ./nixos/configuration.nix
        nixos-hardware.nixosModules.framework-16-7040-amd
        inputs.home-manager.nixosModules.default
          {
            home-manager.extraSpecialArgs = { inherit nix-vscode-extensions; };
          }
        ];
      };
    };
  };
}

home.nix

{ config, pkgs, plasma-manager, nix-vscode-extensions, ... }:

{
  imports = [
    plasma-manager.homeManagerModules.plasma-manager
  ];

  home = {
    username = "jat";
    homeDirectory = "/home/jat";
    stateVersion = "23.11";

    packages = with pkgs; [
      starship
      git
      warp-terminal
      jq
      xclip
      flameshot
      neofetch
      vscode
      google-chrome
      firefox
      discord
      spotify
      signal-desktop
      libsForQt5.polonium
    ];

    file = {
      ".config/warp-terminal/user_preferences.json".source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/nix-fwk-system//configs/warp-terminal.json"; # warp terminal
      ".config/Code/User/settings.json".source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/nix-fwk-system/configs/vscode-settings.json"; # vscode settings.json
    };

    sessionVariables = {
      EDITOR = "code";
    };
  };

  nixpkgs.config.allowUnfree = true;

  programs = {
    home-manager.enable = true;
    plasma = {
      enable = true;
      workspace = {
        lookAndFeel = "org.kde.breezedark.desktop";
      };
    };
    bash.enable = true;
    git = {
      enable = true;
      userName  = "Jatinder Randhawa";
      userEmail = "j4t1nd3r@gmail.com";
    };
    starship = {
      enable = true;
      enableBashIntegration = true; 
    };
    vscode = {
      enable = true;
      extensions = with nix-vscode-extensions.extensions.${pkgs.system}.vscode-marketplace; [
        bbenoist.nix
        jdinhlife.gruvbox
        bbenoist.nix
        github.vscode-pull-request-github
      ];
    };
  };

}

Regarding this new config. I struggled with its config and the discord get it working for me. On the first error free run of sudo nixos rebuild flake..., it installed bbenoist.nix extension.

Once again to test reproducibility. I uninstalled the extension within vscode then reran sudo nixos rebuild flake... the same issue persists.

I now suspect that I have a fundamental misunderstanding here or there is an issue with my general config. Suggestions?

deemp commented 6 months ago

How do you know an extension is not installed?

What does code --list-extensions output?

Please provide a screenshot of your list of installed extensions.

j4t1nd3r commented 6 months ago

on issues/vscode-extensions branch. I initially installed my extensions manually, so I have uninstalled them to test the sudo nixos rebuild flake..

with the following vscode config in home.nix:

  vscode = {
      enable = true;
      extensions = with nix-vscode-extensions.extensions.${pkgs.system}.vscode-marketplace; [
        bbenoist.nix
        jdinhlife.gruvbox
        bbenoist.nix
        github.vscode-pull-request-github
      ];
    };

terminal: image

vscode: image

deemp commented 6 months ago

@AmeerTaweel, could you please have a look?

jensmeindertsma commented 5 months ago

I am running into this too, is there anything I can do to help this issue move forward?

deemp commented 4 months ago

@j4t1nd3r @jensmeindertsma, this repo provides only extension derivations. Please report Home Manager problems in the home-manager repo.

bemyak commented 3 months ago

One (non-optimal) way to fix this is to set programs.vscode.mutableExtensionsDir = false;. This will force home-manager to generate extensions.json, but you will not be able to install extensions from the vscode's interface.

The issue is indeed needs to be fixed in home-manager. In case of mutableExtensionsDir = true it should still patch extensions.json to add all listed extensions there.

Edit: I should probably post it to the home-manager issue as well :thinking:

Ryan-Jeziorski commented 3 months ago

@j4t1nd3r are you still having this issue? I had something similar happen, it was a result of using profiles.

Screenshot_20240802_191802 image