nixos-manager icon indicating copy to clipboard operation
nixos-manager copied to clipboard

[Feature request] README snippet for usage outside NixOS

Open toonn opened this issue 4 years ago • 4 comments

As many people get started using Nix on other distros, because they're not ready to take the plunge and install NixOS or are intimidated by the install process, it'd be cool if this tool could be used with nix-env or home-manager.

Since packages.nix is supposed to be a flat list of packages I think it could easily be used as the paths for a buildEnv, something like this overlay maybe:

self: super: {
  nixos-manager-packages = pkgs.buildEnv {
      name = "nixos-manage-packagesr";
      paths = import ./packages.nix;  # Expects a list of packages
    };
}

For home-manager I'm sure a similar snippet could be added to the README. Including support for configuring home-manager's services and other configuration would probably require changes to the implementation?

toonn avatar Apr 14 '20 18:04 toonn

Thanks for the issue @toonn. I thought about it, and I think you're right. Currently, I'm not sure how to approach it, but I'll experiment with implementing a home-manager-only version of NixOS manager and see what the challenges are (I suppose supporting both home-manager and NixOS would be a little overkill at this moment). If we were to support home-manager's declarative service configuration, we'd need a JSON file, similar to the one that's downloaded currently, containing the service descriptions and, most importantly, the option types. I don't know if this exists or if it could be created.

pmiddend avatar Apr 17 '20 06:04 pmiddend

That's neat for the long term. How about snippets for just using the packages.nix from a config.nix with nix-env or home-manager configuration though?

toonn avatar Apr 17 '20 10:04 toonn

Okay, you have to help me out a bit here, since I haven't used overlays before. According to the Wiki, you can put your overlay config into ~/.config/nixpkgs/overlays and it’ll be used? And what does packages.nix have to look like, then?

pmiddend avatar Apr 17 '20 11:04 pmiddend

This section of the manual has an example.

For home-manager it should be similar, using the home.packages option:

{pkgs ? <nixpkgs>, ...}:
{ # My HM config
  # ...
  home.packages = (import ./packages.nix)
    ++ [ pkgs.four pkgs.manually pkgs.added pkgs.packages ];
  # ...
}

toonn avatar Apr 17 '20 18:04 toonn