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

Instructions unclear with home-manager managed as a flake #65

Open
golddranks opened this issue Jul 31, 2023 · 4 comments · May be fixed by #83
Open

Instructions unclear with home-manager managed as a flake #65

golddranks opened this issue Jul 31, 2023 · 4 comments · May be fixed by #83

Comments

@golddranks
Copy link

golddranks commented Jul 31, 2023

The README seems to show how to install vscode-server as a system-level module, with flakes or channels. I'm trying to install it to just one user, with home-manager managed as a flake.

I expect that I need to specify vscode-server.url = "github:nix-community/nixos-vscode-server"; as my input in .config/home-manager/flake.nix. The next problem is, how am I supposed to "install" or enable the module to be able to enable the service in ~/.config/nixpkgs/home.nix? I tried to add it to the modules list, but got a "vscode-server is a flake" error. Next, I reasoned that the module is an output of the flake, but this backfires too.

{
  description = "Home Manager configuration of kon";

  inputs = {
    # Specify the source of Home Manager and Nixpkgs.
    nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
    home-manager = {
      url = "github:nix-community/home-manager/release-23.05";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    vscode-server.url = "github:nix-community/nixos-vscode-server";
  };

  outputs = { nixpkgs, home-manager, vscode-server, ... }:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
    in {
      homeConfigurations."kon" = home-manager.lib.homeManagerConfiguration {
        inherit pkgs;

        # Specify your home configuration modules here, for example,
        # the path to your home.nix.
        modules = [
          ./home.nix
          vscode-server.nixosModules.default  # I'm trying to specify the vscode-server "module" here, but this doesn't seem to work.
        ];

        # Optionally use extraSpecialArgs
        # to pass through arguments to home.nix
      };
    };
}

I'm lost how to proceed, please help. (And let's possibly, update the README too, I think that using flakes with home-manager is getting more and more common!)

@msteen
Copy link
Collaborator

msteen commented Jul 31, 2023

Your the second one, so I will have to agree, the README needs updating on that front. Thanks for letting me know! However, in general, you should just check the flake.nix for what it is exporting, then your answer should have been relatively obvious, granted that you have some understanding of Nix (the language) and flakes:

Just replace vscode-server.nixosModules.default with vscode-server.homeModules.default or vscode-server.nixosModules.home.

That does not invalidate that indeed the docs need improving, so I am going to keep the issue open, such that I remember to update the README. And I should probably see if I can make the default for importing modules, not just always be nixos, but maybe I can detect when it is being imported from Home Manager and import the home module(s) instead.

@golddranks
Copy link
Author

Thanks, seems to work now. Oh, I was close! I'm still a bit new both to flakes and home-manager, so I easily get lost.

@msteen
Copy link
Collaborator

msteen commented Aug 1, 2023

Would you be willing to test whether check if the README is sufficiently updated? And test whether your old code would just work as you had it?

The branch that contains the changes is here: https://github.com/nix-community/nixos-vscode-server/tree/hm-module-import

The only change in your old code would need to be: vscode-server.url = "github:nix-community/nixos-vscode-server"; to vscode-server.url = "github:nix-community/nixos-vscode-server/hm-module-import";

That should let you use that branch instead. I have not sufficiently tested the code yet, hence the separate branch, but the intention is that it now should import either the NixOS or HM module depending on whether you import it in a NixOS or HM configuration.

@golddranks
Copy link
Author

Thanks! I tried it, but it says that this gets called with with unexpected argument 'config':

$ home-manager switch
error: anonymous function at /nix/store/15nzw95lskfcl959zhhndq866590q6i7-source/modules/vscode-server/default.nix:1:1 called with unexpected argument 'config'

       at /nix/store/qxgp86sdhxwzj0k89kz2aaw0xw7d8f6i-source/lib/modules.nix:519:8:

          518|       # works.
          519|     in f (args // extraArgs);
             |        ^
          520|
(use '--show-trace' to show detailed location information)

The call site seems to be this: https://github.com/NixOS/nixpkgs/blob/master/lib/modules.nix#L513

@Ten0 Ten0 linked a pull request Jul 3, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants