Skip to content

question: is it possible to reference the home-manager configuration as a standalone flake? #76

@dbkegley

Description

@dbkegley

I'm very new to nix and I'm still trying to learn how the ecosystem fits together so thank you so much for going through the effort to document and share your configuration, it has been an extremely helpful learning tool.

My setup differs from yours a little bit because I have some linux environments where I don't use NixOS (I plan to but would like to start with home-manager initially) so I would like to be able to re-use the shared home-manager configuration as a standalone tool.

I'm hoping you might be able to point me in the right direction, or at least tell me if what I'm trying to accomplish is possible.

I would like to have something like this:

# flake.nix
...
darwinConfigurations = {
  david-mbp = darwin.lib.darwinSystem {
    specialArgs = {
      inherit inputs outputs;
      lib = lib "${systemDarwin}";
    };
    modules = sharedModules ++ darwinModules ++ [ ./machines/darwin/default.nix ];
  };
};

homeConfigurations = {
  <hostname> = home-manager.lib.homeManagerConfiguration {
    pkgs = nixpkgs.legacyPackages.${systemLinux};
    extraSpecialArgs = {
      inherit inputs outputs;
      sharedLib = lib "${systemLinux}";
      imports = [ ./machines/common/default.nix ];
    };
    modules = sharedModules;
  };
};

# nixosConfigurations = {
#   legion = nixpkgs.lib.nixosSystem {
#     specialArgs = {
#       inherit inputs outputs;
#       lib = lib "x86_64-linux";
#     };
#     modules = sharedModules ++ nixosModules ++ [ ./machines/legion/default.nix ];
#   };
...

So that I can install it as a flake anywhere home-manager is installed without requiring nixos/nix-darwin:

home-manager switch --flake .#<hostname>

Is that possible with the way these modules are structured today or do I need to create an intermediate module that serves as a replacement for nixpkgs.lib.nixosSystem / darwin.lib.darwinSystem in order to call home-manager this way?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions