nix-community / nix-vscode-extensions

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

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

Open j4t1nd3r opened 2 months ago

j4t1nd3r commented 2 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 2 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 2 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 2 months ago

@AmeerTaweel, could you please have a look?

jensmeindertsma commented 3 weeks ago

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

deemp commented 2 weeks ago

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