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

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

Open
j4t1nd3r opened this issue May 5, 2024 · 7 comments

Comments

@j4t1nd3r
Copy link

j4t1nd3r commented May 5, 2024

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 = "[email protected]";
    };
    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
Copy link
Collaborator

deemp commented May 5, 2024

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
Copy link
Author

j4t1nd3r commented May 6, 2024

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
Copy link
Collaborator

deemp commented May 6, 2024

@AmeerTaweel, could you please have a look?

@jensmeindertsma
Copy link

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

@deemp
Copy link
Collaborator

deemp commented Jun 21, 2024

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

@bemyak
Copy link

bemyak commented Aug 1, 2024

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 🤔

@Ryan-Jeziorski
Copy link

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

Screenshot_20240802_191802
image

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

No branches or pull requests

5 participants