Skip to content

Commit

Permalink
repo: Make nixosTests available to packages
Browse files Browse the repository at this point in the history
This will make it easier to interoperate with and upstream to nixpkgs,
as in nixpkgs it is common to refer to nixosTests.
  • Loading branch information
lorenzleutgeb committed Sep 15, 2023
1 parent 93fbc19 commit e807309
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
7 changes: 5 additions & 2 deletions all-packages.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{newScope, ...}: let
{
newScope,
nixosTests,
}: let
self = rec {
flarum = callPackage ./pkgs/flarum {};
gnunet-messenger-cli = callPackage ./pkgs/gnunet-messenger-cli {};
Expand Down Expand Up @@ -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
12 changes: 8 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
importPackages = pkgs:
import ./all-packages.nix {
inherit (pkgs) newScope;
nixosTests = pkgs.nixosTests // self.nixosTests.${pkgs.system};
};

importNixpkgs = system: overlays:
Expand All @@ -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
// {
Expand Down Expand Up @@ -85,8 +87,10 @@

# To generate a Hydra jobset for CI builds of all packages and tests.
# See <https://hydra.ngi0.nixos.org/jobset/ngipkgs/main>.
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 <https://github.com/ngi-nix/ngipkgs/issues/28>.
Expand All @@ -102,7 +106,7 @@
mapAttrs (
_: config:
nixpkgs.lib.nixosSystem {
modules = [config] ++ nixpkgs.lib.attrValues extendedModules;
modules = [config] ++ attrValues extendedModules;
}
)
importNixosConfigurations;
Expand Down

0 comments on commit e807309

Please sign in to comment.