* flake: Expose tests to allow running purely
The existing way to run tests with `nix-shell` relies on impure usage of
`<nixpkgs>`. This can lead to failures when the local nixpkgs is
incompatible with the locked one. I.e., where CI is passing but a
contributor may experience a failure.
So, expose tests as `devShells.tests` to use the locked nixpkgs and
allow easy invocation via `nix develop`.
* tests: Remove impure path
With Nix 2.10+ and pure evaluation mode e.g.
```
nix run nixpkgs/nixos-unstable#nixVersions.nix_2_10 -- develop -i .#tests.zplug-modules
```
this test would fail with:
> error: the path '~/.customZplugHome' can not be resolved in pure mode
Since the test only cares that it is a path, rather than anything about
its contents, use a dummy empty directory.
This simplifies the code a bit and avoids using experimental Flake
functionality. If Flakes become stable before NixOS 22.11 then we can
consider having nmd and nmt as Flake inputs. Maybe could then also
avoid the need for flake-compat.
Remove `stateVersion`, `username`, and `homeDirectory` as they can be
set in the configuration directly. Together with the previous commit,
this makes setting `stateVersion` explicitly mandatory.
Also replace `configuration` by `modules`, which expects a list of
Home Manager modules.
Also remove `system` which was made useless by #3028.
* Add flake.lock and clean up flake.nix
Add a lockfile to work around https://github.com/NixOS/nix/issues/6541
(and because it's a good idea anyway).
Also use flake-utils, and restrict ourselves to the five platforms
supported by nixpkgs. Otherwise, the IFD for nmd fails on weird
platforms. This fixes `nix flake check`.
Remove the redundant `apps` output, see https://github.com/nix-community/home-manager/pull/2442#issuecomment-1133670487
* nixos,nix-darwin: factor out into a common module
* nixos,nix-darwin: make `home-managers.users` shallowly visible
Make sure the option is included in the NixOS/nix-darwin manual (but the
HM submodule options aren't).
Also add a static description to the HM submodule type so that we don't need to
evaluate the submodules just to build the option manual. This makes
nixos-search able to index the home-manager flake.
Also clean up some TODOs.
* flake: add nmd and nmt
This avoids having to use `pkgs.fetchFromGitLab` in an IFD, which causes
issues when indexing packages with nixos-search because `pkgs` is
instantiated with every platform.
Home Manager can be ran with
`nix run --no-write-lock-file github:nix-community/home-manager`.
This is useful for people who want to try out Home Manager or,
want to bootstrap their home-environment.
* flake: ensure passed pkgs with overlays and config is used
In the pkgsModule inside modules/modules.nix it will try to use the
<nixpkgs> from NIX_PATH if home.stateVersion is not set. This is not
available when using flakes so we need to require at least 20.09 and we
might as well default to that.
Also if you have added overlays and config to your pkgs it will be lost
so we need to transfer those as well.
This is an alternative to passing pkgs to extraSpecialArgs which will
break the usage of things like nixpkgs.config.packageOverrides.
* flake: add extraModules
If you want to add some extra home-manager modules, you have to mix them
with the configuration as such:
configuration = {
imports = [
emacs-config.homeManagerModules.emacsConfig
./home.nix
];
};
Instead of:
configuration = ./home.nix;
extraModules = [ emacs-config.homeManagerModules.emacsConfig ];
Which separates these two concerns.
No flake.lock is added because the only input (nixpkgs) will almost
always be overridden, and currently Home Manager's testing and
verification is not flake based.
PR #1455