Skip to content

[WIP] add CHV Integration Tests #6

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
51 changes: 51 additions & 0 deletions chv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
# from flake inputs
craneLib,
# from nixpkgs
openssl,
pkg-config,
# other
cloud-hypervisor-src,
rustToolchain,
}:

let
craneLib' = craneLib.overrideToolchain rustToolchain;

commonArgs = {
src = craneLib'.cleanCargoSource cloud-hypervisor-src;
nativeBuildInputs = [
pkg-config
];
buildInputs = [
openssl
];
# Fix build. Reference:
# - https://github.com/sfackler/rust-openssl/issues/1430
# - https://docs.rs/openssl/latest/openssl/
OPENSSL_NO_VENDOR = true;
};

# Downloaded and compiled dependencies.
cargoArtifacts = craneLib'.buildDepsOnly (
commonArgs
// {
pname = "cloud-hypervisor-deps";
}
);

cargoPackageKvm = craneLib'.buildPackage (
commonArgs
// {
inherit cargoArtifacts;
pname = "cloud-hypervisor";
# Don't execute tests here. We want this in a dedicated step.
doCheck = false;
cargoExtraArgs = "--features kvm";
}
);
in
{
default = cargoPackageKvm;
chvKvm = cargoPackageKvm;
}
95 changes: 94 additions & 1 deletion flake.lock

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

48 changes: 42 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,34 @@
description = "OpenStack Packages and Modules for NixOS";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-24.11";
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
nixpkgs-25-05.url = "github:nixos/nixpkgs/nixos-25.05";
pre-commit-hooks-nix = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# Nix tooling to build cloud-hypervisor.
crane.url = "github:ipetkov/crane/master";

Check warning on line 12 in flake.nix

View check run for this annotation

In Solidarity / Inclusive Language

Match Found

Please consider an alternative to `master`. Possibilities include: `primary`, `main`, `leader`, `active`, `writer`
Raw output
/\b(?!masterdata|masterdata\w+\b)master/gi
cloud-hypervisor-src.url = "github:cyberus-technology/cloud-hypervisor/gardenlinux-dev";
cloud-hypervisor-src.flake = false;
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs-25-05";
libvirt-src.url = "git+https://github.com/cyberus-technology/libvirt?ref=gardenlinux&submodules=1";
libvirt-src.flake = false;
};

outputs =
{
self,
nixpkgs,
flake-utils,
pre-commit-hooks-nix,
...
}:
}@inputs:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (
system:
let
pkgs = import nixpkgs { inherit system; };
pre-commit-hooks-run = pre-commit-hooks-nix.lib.${system}.run;
pre-commit-hooks-run = inputs.pre-commit-hooks-nix.lib.${system}.run;
in
rec {
formatter = pkgs.nixfmt-rfc-style;
Expand All @@ -44,11 +52,39 @@
};
};

packages = import ./packages { inherit (pkgs) callPackage python3Packages; };
packages = (import ./packages { inherit (pkgs) callPackage python3Packages; }) // {
cloud-hypervisor =
let
pkgs-25-05 = import inputs.nixpkgs-25-05 { inherit (pkgs) system; };
rust-bin = (inputs.rust-overlay.lib.mkRustBin { }) pkgs-25-05;
artifacts = pkgs.callPackage ./chv.nix {
inherit (inputs) cloud-hypervisor-src;
craneLib = inputs.crane.mkLib pkgs-25-05;
rustToolchain = rust-bin.stable.latest.default;
};
in
artifacts.default;
libvirt = pkgs.libvirt.overrideAttrs ({
src = inputs.libvirt-src;
patches =
let
patchSrc = ./patches/libvirt;
in
(pkgs.lib.pipe patchSrc [
builtins.readDir
builtins.attrNames
# To fully-qualified path.
(map (f: "${patchSrc}/${f}"))
]);
});
};

checks = import ./checks { inherit pkgs pre-commit-hooks-run; };

nixosModules = import ./modules { openstackPkgs = packages; };
nixosModules = import ./modules {
openstackPkgs = packages;
inherit self;
};

tests = import ./tests/default.nix {
inherit pkgs nixosModules;
Expand Down
16 changes: 16 additions & 0 deletions modules/chv-sap.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Ensures libvirt and Cloud Hypervisor are set with the proper sources for SAP
# (for gardenlinux).

# Function returning a NixOS Module
{ self }:

# NixOS Module start
{ pkgs, ... }:
{
virtualisation.libvirtd.package = pkgs.libvirt;
nixpkgs.overlays = [
(prev: final: {
inherit (self.packages.${pkgs.system}) cloud-hypervisor;
})
];
}
4 changes: 3 additions & 1 deletion modules/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ openstackPkgs }:
{ openstackPkgs, self }:
{
controllerModule = import ./controller/openstack-controller.nix {
inherit (openstackPkgs)
Expand All @@ -14,4 +14,6 @@
computeModule = import ./compute/compute.nix { inherit (openstackPkgs) neutron nova; };

testModules = import ./testing { };

chv-sap = import ./chv-sap.nix { inherit self; };
}
Loading
Loading