mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-05 16:26:58 +00:00
home-manager: move tests into new test flake
Having the tests available in the main Nix Flake introduces unnecessary evaluation for non-developer users and, worse, a dependency on the nmt library. Fixes #6354
This commit is contained in:
parent
b93e17c73c
commit
1b9fe46e9f
5 changed files with 62 additions and 22 deletions
3
.github/PULL_REQUEST_TEMPLATE.md
vendored
3
.github/PULL_REQUEST_TEMPLATE.md
vendored
|
@ -23,7 +23,8 @@ Also make sure to read the guidelines found at
|
|||
|
||||
- [ ] Code formatted with `./format`.
|
||||
|
||||
- [ ] Code tested through `nix-shell --pure tests -A run.all` or `nix develop --ignore-environment .#all` using Flakes.
|
||||
- [ ] Code tested through `nix-shell --pure tests -A run.all`
|
||||
or `nix build --reference-lock-file flake.lock ./tests#test-all` using Flakes.
|
||||
|
||||
- [ ] Test cases updated/added. See [example](https://github.com/nix-community/home-manager/commit/f3fbb50b68df20da47f9b0def5607857fcc0d021#diff-b61a6d542f9036550ba9c401c80f00ef).
|
||||
|
||||
|
|
|
@ -29,10 +29,16 @@ through
|
|||
$ nix-shell --pure tests -A run.alacritty-empty-settings
|
||||
```
|
||||
|
||||
However, those invocations will impurely source the system's nixpkgs,
|
||||
and may cause failures. To run against the nixpkgs from the flake.lock,
|
||||
However, those invocations will impurely source the system's Nixpkgs,
|
||||
and may cause failures. To run against the Nixpkgs from the `flake.lock` file,
|
||||
use instead e.g.
|
||||
|
||||
``` shell
|
||||
$ nix develop --ignore-environment .#all
|
||||
$ nix build --reference-lock-file flake.lock ./tests#test-all
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
``` shell
|
||||
$ nix build --reference-lock-file flake.lock ./tests#test-alacritty-empty-settings
|
||||
```
|
||||
|
|
|
@ -17,6 +17,11 @@ This release has the following notable changes:
|
|||
The `"suggest"` alternative will remain for a while longer but may
|
||||
also be deprecated for removal in the future.
|
||||
|
||||
- The Home Manager test suite has been removed from the main Nix Flake
|
||||
since it caused unnecessary evaluations and downloads. Instead the
|
||||
tests are available through a Nix Flake file inside the `tests`
|
||||
directory. See [](#sec-tests) for example commands.
|
||||
|
||||
## State Version Changes {#sec-release-25.05-state-version-changes}
|
||||
|
||||
The state version in this release includes the changes below. These
|
||||
|
|
19
flake.nix
19
flake.nix
|
@ -89,12 +89,6 @@
|
|||
} // (let
|
||||
forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
|
||||
in {
|
||||
devShells = forAllSystems (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
tests = import ./tests { inherit pkgs; };
|
||||
in tests.run);
|
||||
|
||||
formatter = forAllSystems (system:
|
||||
let pkgs = nixpkgs.legacyPackages.${system};
|
||||
in pkgs.linkFarm "format" [{
|
||||
|
@ -105,23 +99,12 @@
|
|||
packages = forAllSystems (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
lib = pkgs.lib;
|
||||
releaseInfo = nixpkgs.lib.importJSON ./release.json;
|
||||
docs = import ./docs {
|
||||
inherit pkgs;
|
||||
inherit (releaseInfo) release isReleaseBranch;
|
||||
};
|
||||
hmPkg = pkgs.callPackage ./home-manager { path = "${./.}"; };
|
||||
|
||||
testPackages = let
|
||||
tests = import ./tests { inherit pkgs; };
|
||||
renameTestPkg = n: lib.nameValuePair "test-${n}";
|
||||
in lib.mapAttrs' renameTestPkg tests.build;
|
||||
|
||||
integrationTestPackages = let
|
||||
tests = import ./tests/integration { inherit pkgs; };
|
||||
renameTestPkg = n: lib.nameValuePair "integration-test-${n}";
|
||||
in lib.mapAttrs' renameTestPkg tests;
|
||||
in {
|
||||
default = hmPkg;
|
||||
home-manager = hmPkg;
|
||||
|
@ -129,7 +112,7 @@
|
|||
docs-html = docs.manual.html;
|
||||
docs-json = docs.options.json;
|
||||
docs-manpages = docs.manPages;
|
||||
} // testPackages // integrationTestPackages);
|
||||
});
|
||||
|
||||
defaultPackage = forAllSystems (system: self.packages.${system}.default);
|
||||
});
|
||||
|
|
45
tests/flake.nix
Normal file
45
tests/flake.nix
Normal file
|
@ -0,0 +1,45 @@
|
|||
# This is an internal Nix Flake intended for use when running tests.
|
||||
#
|
||||
# You can build all tests or specific tests by running
|
||||
#
|
||||
# nix build --reference-lock-file flake.lock ./tests#test-all
|
||||
# nix build --reference-lock-file flake.lock ./tests#test-alacritty-empty-settings
|
||||
#
|
||||
# in the Home Manager project root directory.
|
||||
#
|
||||
# Similarly for integration tests
|
||||
#
|
||||
# nix build --reference-lock-file flake.lock ./tests#integration-test-all
|
||||
# nix build --reference-lock-file flake.lock ./tests#integration-test-standalone-standard-basics
|
||||
|
||||
{
|
||||
description = "Tests of Home Manager for Nix";
|
||||
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
|
||||
outputs = { self, nixpkgs, ... }:
|
||||
let forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
|
||||
in {
|
||||
devShells = forAllSystems (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
tests = import ./. { inherit pkgs; };
|
||||
in tests.run);
|
||||
|
||||
packages = forAllSystems (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
lib = pkgs.lib;
|
||||
|
||||
testPackages = let
|
||||
tests = import ./. { inherit pkgs; };
|
||||
renameTestPkg = n: lib.nameValuePair "test-${n}";
|
||||
in lib.mapAttrs' renameTestPkg tests.build;
|
||||
|
||||
integrationTestPackages = let
|
||||
tests = import ./integration { inherit pkgs; };
|
||||
renameTestPkg = n: lib.nameValuePair "integration-test-${n}";
|
||||
in lib.mapAttrs' renameTestPkg tests;
|
||||
in testPackages // integrationTestPackages);
|
||||
};
|
||||
}
|
Loading…
Add table
Reference in a new issue