From 006d6a6dd58c2e7fa7ddb88ed26b9aa6c1802f29 Mon Sep 17 00:00:00 2001 From: aszlig Date: Fri, 11 Dec 2015 05:21:27 +0100 Subject: profiles/common: Pass tests attribute to modules. This is going to be used in modules or configurations to include tests specific to the module, for example let's say you have a foo.nix module that defines a foo service and you have a test named "foo" in the tests.vuizvui namespace. You can use it like this: { config, tests, lib, ... }: { ... other options of the foo service module ... config = lib.mkIf config.foo.enable { vuizvui.requiresTests = [ tests.vuizvui.foo ]; }; } If a machine config enables the module foo (foo.enable = true) then the "foo" test is also a constituent of the machine channel for the machine. Signed-off-by: aszlig --- modules/profiles/common.nix | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'modules/profiles') diff --git a/modules/profiles/common.nix b/modules/profiles/common.nix index 8621f6ae..b7fad147 100644 --- a/modules/profiles/common.nix +++ b/modules/profiles/common.nix @@ -44,7 +44,11 @@ with lib; }; }; - config = { + config = let + nixpkgs = import ../../nixpkgs-path.nix; + system = config.nixpkgs.system; + + in { nixpkgs.config.packageOverrides = pkgs: { # XXX: REAAAALLLY UGLY hack to force the Headcounter Hydra to rebuild GHC # and all its packages and not use binary substitution. @@ -74,7 +78,6 @@ with lib; in mkIf config.vuizvui.enableGlobalNixpkgsConfig (mkForce nixpkgsCfg); nix.nixPath = let - nixpkgs = import ../../nixpkgs-path.nix; rootChannelsPath = "/nix/var/nix/profiles/per-user/root/channels"; channelPath = "${rootChannelsPath}/${config.vuizvui.channelName}"; nixosConfig = "/etc/nixos/configuration.nix"; @@ -90,5 +93,20 @@ with lib; rootChannelsPath ] ++ optional config.vuizvui.enableGlobalNixpkgsConfig nixpkgsConfig; in mkIf config.vuizvui.modifyNixPath (mkOverride 90 nixPath); + + _module.args.tests = { + nixos = let + upstreamTests = (import "${nixpkgs}/nixos/release.nix" { + inherit nixpkgs; + }).tests; + isTestOrSystems = attr: attr ? test || attr ? ${system}; + cond = attr: !isTestOrSystems attr; + reduce = attr: if attr ? test then attr else attr.${system}; + in mapAttrsRecursiveCond cond (path: reduce) upstreamTests; + + vuizvui = import ../../tests { + inherit system; + }; + }; }; } -- cgit 1.4.1