From e8073096c7f5b3232ac6ac458f64e76ecd4a3f55 Mon Sep 17 00:00:00 2001 From: Lorenz Leutgeb Date: Fri, 15 Sep 2023 17:09:41 +0200 Subject: [PATCH] repo: Make nixosTests available to packages This will make it easier to interoperate with and upstream to nixpkgs, as in nixpkgs it is common to refer to nixosTests. --- all-packages.nix | 7 +++++-- flake.nix | 12 ++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/all-packages.nix b/all-packages.nix index 7f6d724b2..928663eb0 100644 --- a/all-packages.nix +++ b/all-packages.nix @@ -1,4 +1,7 @@ -{newScope, ...}: let +{ + newScope, + nixosTests, +}: let self = rec { flarum = callPackage ./pkgs/flarum {}; gnunet-messenger-cli = callPackage ./pkgs/gnunet-messenger-cli {}; @@ -42,6 +45,6 @@ euclid3 = callPackage ./nixpkgs-candidates/euclid3 {}; }; - callPackage = newScope (self // nixpkgs-candidates // {inherit callPackage;}); + callPackage = newScope (self // nixpkgs-candidates // {inherit callPackage nixosTests;}); in self diff --git a/flake.nix b/flake.nix index d1263915b..684f6718d 100644 --- a/flake.nix +++ b/flake.nix @@ -27,6 +27,7 @@ importPackages = pkgs: import ./all-packages.nix { inherit (pkgs) newScope; + nixosTests = pkgs.nixosTests // self.nixosTests.${pkgs.system}; }; importNixpkgs = system: overlays: @@ -38,7 +39,8 @@ loadTreefmt = pkgs: treefmt-nix.lib.evalModule pkgs ./treefmt.nix; - # Attribute set containing all modules obtained via `inputs` and defined in this flake towards definition of `nixosConfigurations` and `nixosTests`. + # Attribute set containing all modules obtained via `inputs` and defined + # in this flake towards definition of `nixosConfigurations` and `nixosTests`. extendedModules = self.nixosModules // { @@ -85,8 +87,10 @@ # To generate a Hydra jobset for CI builds of all packages and tests. # See . - hydraJobs.packages.${linuxSystem} = self.packages.${linuxSystem}; - hydraJobs.nixosTests.${linuxSystem} = self.nixosTests.${linuxSystem}; + hydraJobs = { + packages.${linuxSystem} = self.packages.${linuxSystem}; + nixosTests.${linuxSystem} = self.nixosTests.${linuxSystem}; + }; # `nixosTests` is a non-standard name for a flake output. # See . @@ -102,7 +106,7 @@ mapAttrs ( _: config: nixpkgs.lib.nixosSystem { - modules = [config] ++ nixpkgs.lib.attrValues extendedModules; + modules = [config] ++ attrValues extendedModules; } ) importNixosConfigurations;