Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make nixos module hydra from this repository by default #1419

Merged
merged 2 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 9 additions & 106 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 26 additions & 19 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@
description = "A Nix-based continuous build system";

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05-small";

inputs.libgit2 = { url = "github:libgit2/libgit2/v1.8.1"; flake = false; };
inputs.nix.url = "github:NixOS/nix/2.24-maintenance";
inputs.nix.inputs.nixpkgs.follows = "nixpkgs";
inputs.nix.inputs.libgit2.follows = "libgit2";

# hide nix dev tooling from our lock file
inputs.nix.inputs.flake-parts.follows = "";
inputs.nix.inputs.git-hooks-nix.follows = "";
inputs.nix.inputs.nixpkgs-regression.follows = "";
inputs.nix.inputs.nixpkgs-23-11.follows = "";
inputs.nix.inputs.flake-compat.follows = "";

outputs = { self, nixpkgs, nix }:
outputs = { self, nixpkgs, nix, ... }:
let
systems = [ "x86_64-linux" "aarch64-linux" ];
forEachSystem = nixpkgs.lib.genAttrs systems;

overlayList = [ self.overlays.default nix.overlays.default ];

pkgsBySystem = forEachSystem (system: import nixpkgs {
inherit system;
overlays = overlayList;
});

in
rec {

Expand All @@ -30,7 +32,6 @@
};

hydraJobs = {

build = forEachSystem (system: packages.${system}.hydra);

buildNoTests = forEachSystem (system:
Expand All @@ -39,19 +40,21 @@
})
);

manual = forEachSystem (system:
let pkgs = pkgsBySystem.${system}; in
pkgs.runCommand "hydra-manual-${pkgs.hydra.version}" { }
manual = forEachSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
hydra = self.packages.${pkgs.hostPlatform.system}.hydra;
in
pkgs.runCommand "hydra-manual-${hydra.version}" { }
''
mkdir -p $out/share
cp -prvd ${pkgs.hydra}/share/doc $out/share/
cp -prvd ${hydra}/share/doc $out/share/

mkdir $out/nix-support
echo "doc manual $out/share/doc/hydra" >> $out/nix-support/hydra-build-products
'');

tests = import ./nixos-tests.nix {
inherit forEachSystem nixpkgs pkgsBySystem nixosModules;
inherit forEachSystem nixpkgs nixosModules;
};

container = nixosConfigurations.container.config.system.build.toplevel;
Expand All @@ -64,20 +67,24 @@
});

packages = forEachSystem (system: {
hydra = pkgsBySystem.${system}.hydra;
default = pkgsBySystem.${system}.hydra;
hydra = nixpkgs.legacyPackages.${system}.callPackage ./package.nix {
inherit (nixpkgs.lib) fileset;
rawSrc = self;
nix = nix.packages.${system}.nix;
nix-perl-bindings = nix.hydraJobs.perlBindings.${system};
};
Comment on lines +70 to +75
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The duplicating of the overlay also tripped me up, forgot to add nix-eval-jobs in both places.

default = self.packages.${system}.hydra;
});

nixosModules = import ./nixos-modules {
overlays = overlayList;
inherit self;
};

nixosConfigurations.container = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules =
[
self.nixosModules.hydra
self.nixosModules.overlayNixpkgsForThisHydra
self.nixosModules.hydraTest
self.nixosModules.hydraProxy
{
Expand Down
11 changes: 5 additions & 6 deletions nixos-modules/default.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{ overlays }:
{ self }:

{
hydra = import ./hydra.nix;

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

hydraTest = { pkgs, ... }: {
Expand Down
2 changes: 0 additions & 2 deletions nixos-modules/hydra.nix
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ in

package = mkOption {
type = types.path;
default = pkgs.hydra;
defaultText = literalExpression "pkgs.hydra";
description = "The Hydra package.";
};

Expand Down
14 changes: 6 additions & 8 deletions nixos-tests.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{ forEachSystem, nixpkgs, pkgsBySystem, nixosModules }:
{ forEachSystem, nixpkgs, nixosModules }:

let
# NixOS configuration used for VM tests.
hydraServer =
{ config, pkgs, ... }:
{ pkgs, ... }:
{
imports = [
nixosModules.hydra
nixosModules.overlayNixpkgsForThisHydra
nixosModules.hydraTest
];

Expand Down Expand Up @@ -44,11 +43,10 @@ in
});

notifications = forEachSystem (system:
let pkgs = pkgsBySystem.${system}; in
with import (nixpkgs + "/nixos/lib/testing-python.nix") { inherit system; };
simpleTest {
name = "hydra-notifications";
nodes.machine = { pkgs, ... }: {
nodes.machine = {
imports = [ hydraServer ];
services.hydra-dev.extraConfig = ''
<influxdb>
Expand Down Expand Up @@ -89,7 +87,7 @@ in

# Setup the project and jobset
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
Expand All @@ -103,7 +101,7 @@ in
});

gitea = forEachSystem (system:
let pkgs = pkgsBySystem.${system}; in
let pkgs = nixpkgs.legacyPackages.${system}; in
with import (nixpkgs + "/nixos/lib/testing-python.nix") { inherit system; };
makeTest {
name = "hydra-gitea";
Expand Down Expand Up @@ -298,7 +296,7 @@ in
});

validate-openapi = forEachSystem (system:
let pkgs = pkgsBySystem.${system}; in
let pkgs = nixpkgs.legacyPackages.${system}; in
pkgs.runCommand "validate-openapi"
{ buildInputs = [ pkgs.openapi-generator-cli ]; }
''
Expand Down
Loading