make nixos module hydra from this repository by default

When people reach out to the git repository they probably want to use
hydra from the same source.
This also removes the need for an overlay with simpler and more
performant direct use of the nixpkgs passed in. Before it was
re-importing nixpkgs.

test
This commit is contained in:
Jörg Thalheim 2024-10-19 18:05:04 +02:00
parent bdeec354c3
commit a9a5b14331
4 changed files with 26 additions and 34 deletions

View file

@ -9,14 +9,6 @@
let let
systems = [ "x86_64-linux" "aarch64-linux" ]; systems = [ "x86_64-linux" "aarch64-linux" ];
forEachSystem = nixpkgs.lib.genAttrs systems; forEachSystem = nixpkgs.lib.genAttrs systems;
overlayList = [ self.overlays.default nix.overlays.default ];
pkgsBySystem = forEachSystem (system: import nixpkgs {
inherit system;
overlays = overlayList;
});
in in
rec { rec {
@ -30,7 +22,6 @@
}; };
hydraJobs = { hydraJobs = {
build = forEachSystem (system: packages.${system}.hydra); build = forEachSystem (system: packages.${system}.hydra);
buildNoTests = forEachSystem (system: buildNoTests = forEachSystem (system:
@ -39,19 +30,21 @@
}) })
); );
manual = forEachSystem (system: manual = forEachSystem (system: let
let pkgs = pkgsBySystem.${system}; in pkgs = nixpkgs.legacyPackages.${system};
pkgs.runCommand "hydra-manual-${pkgs.hydra.version}" { } hydra = self.packages.${pkgs.hostPlatform.system}.hydra;
in
pkgs.runCommand "hydra-manual-${hydra.version}" { }
'' ''
mkdir -p $out/share mkdir -p $out/share
cp -prvd ${pkgs.hydra}/share/doc $out/share/ cp -prvd ${hydra}/share/doc $out/share/
mkdir $out/nix-support mkdir $out/nix-support
echo "doc manual $out/share/doc/hydra" >> $out/nix-support/hydra-build-products echo "doc manual $out/share/doc/hydra" >> $out/nix-support/hydra-build-products
''); '');
tests = import ./nixos-tests.nix { tests = import ./nixos-tests.nix {
inherit forEachSystem nixpkgs pkgsBySystem nixosModules; inherit forEachSystem nixpkgs nixosModules;
}; };
container = nixosConfigurations.container.config.system.build.toplevel; container = nixosConfigurations.container.config.system.build.toplevel;
@ -64,12 +57,17 @@
}); });
packages = forEachSystem (system: { packages = forEachSystem (system: {
hydra = pkgsBySystem.${system}.hydra; hydra = nixpkgs.legacyPackages.${system}.callPackage ./package.nix {
default = pkgsBySystem.${system}.hydra; inherit (nixpkgs.lib) fileset;
rawSrc = self;
nix = nix.packages.${system}.nix;
nix-perl-bindings = nix.hydraJobs.perlBindings.${system};
};
default = self.packages.${system}.hydra;
}); });
nixosModules = import ./nixos-modules { nixosModules = import ./nixos-modules {
overlays = overlayList; inherit self;
}; };
nixosConfigurations.container = nixpkgs.lib.nixosSystem { nixosConfigurations.container = nixpkgs.lib.nixosSystem {
@ -77,7 +75,6 @@
modules = modules =
[ [
self.nixosModules.hydra self.nixosModules.hydra
self.nixosModules.overlayNixpkgsForThisHydra
self.nixosModules.hydraTest self.nixosModules.hydraTest
self.nixosModules.hydraProxy self.nixosModules.hydraProxy
{ {

View file

@ -1,11 +1,10 @@
{ overlays }: { self }:
{ {
hydra = import ./hydra.nix; hydra = { pkgs, lib,... }: {
_file = ./default.nix;
overlayNixpkgsForThisHydra = { pkgs, ... }: { imports = [ ./hydra.nix ];
nixpkgs = { inherit overlays; }; services.hydra-dev.package = lib.mkDefault self.packages.${pkgs.hostPlatform.system}.hydra;
services.hydra.package = pkgs.hydra;
}; };
hydraTest = { pkgs, ... }: { hydraTest = { pkgs, ... }: {

View file

@ -68,8 +68,6 @@ in
package = mkOption { package = mkOption {
type = types.path; type = types.path;
default = pkgs.hydra;
defaultText = literalExpression "pkgs.hydra";
description = "The Hydra package."; description = "The Hydra package.";
}; };

View file

@ -1,13 +1,12 @@
{ forEachSystem, nixpkgs, pkgsBySystem, nixosModules }: { forEachSystem, nixpkgs, nixosModules }:
let let
# NixOS configuration used for VM tests. # NixOS configuration used for VM tests.
hydraServer = hydraServer =
{ config, pkgs, ... }: { pkgs, ... }:
{ {
imports = [ imports = [
nixosModules.hydra nixosModules.hydra
nixosModules.overlayNixpkgsForThisHydra
nixosModules.hydraTest nixosModules.hydraTest
]; ];
@ -44,11 +43,10 @@ in
}); });
notifications = forEachSystem (system: notifications = forEachSystem (system:
let pkgs = pkgsBySystem.${system}; in
with import (nixpkgs + "/nixos/lib/testing-python.nix") { inherit system; }; with import (nixpkgs + "/nixos/lib/testing-python.nix") { inherit system; };
simpleTest { simpleTest {
name = "hydra-notifications"; name = "hydra-notifications";
nodes.machine = { pkgs, ... }: { nodes.machine = {
imports = [ hydraServer ]; imports = [ hydraServer ];
services.hydra-dev.extraConfig = '' services.hydra-dev.extraConfig = ''
<influxdb> <influxdb>
@ -89,7 +87,7 @@ in
# Setup the project and jobset # Setup the project and jobset
machine.succeed( machine.succeed(
"su - hydra -c 'perl -I ${pkgs.hydra.perlDeps}/lib/perl5/site_perl ${./t/setup-notifications-jobset.pl}' >&2" "su - hydra -c 'perl -I ${config.services.hydra-dev.package.perlDeps}/lib/perl5/site_perl ${./t/setup-notifications-jobset.pl}' >&2"
) )
# Wait until hydra has build the job and # Wait until hydra has build the job and
@ -103,7 +101,7 @@ in
}); });
gitea = forEachSystem (system: gitea = forEachSystem (system:
let pkgs = pkgsBySystem.${system}; in let pkgs = nixpkgs.legacyPackages.${system}; in
with import (nixpkgs + "/nixos/lib/testing-python.nix") { inherit system; }; with import (nixpkgs + "/nixos/lib/testing-python.nix") { inherit system; };
makeTest { makeTest {
name = "hydra-gitea"; name = "hydra-gitea";
@ -298,7 +296,7 @@ in
}); });
validate-openapi = forEachSystem (system: validate-openapi = forEachSystem (system:
let pkgs = pkgsBySystem.${system}; in let pkgs = nixpkgs.legacyPackages.${system}; in
pkgs.runCommand "validate-openapi" pkgs.runCommand "validate-openapi"
{ buildInputs = [ pkgs.openapi-generator-cli ]; } { buildInputs = [ pkgs.openapi-generator-cli ]; }
'' ''