Skip to content

Commit 64a0757

Browse files
committed
flake: build and export SAP cloud-hypervisor
This builds and exports the cloud-hypervisor build from the Cyberus "gardenlinux[-dev]" branch. On-behalf-of: SAP philipp.schuster@sap.com
1 parent 50ad7c1 commit 64a0757

3 files changed

Lines changed: 148 additions & 6 deletions

File tree

chv.nix

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
# from flake inputs
3+
craneLib,
4+
# from nixpkgs
5+
openssl,
6+
pkg-config,
7+
# other
8+
cloud-hypervisor-src,
9+
rustToolchain,
10+
}:
11+
12+
let
13+
craneLib' = craneLib.overrideToolchain rustToolchain;
14+
15+
commonArgs = {
16+
src = craneLib'.cleanCargoSource cloud-hypervisor-src;
17+
nativeBuildInputs = [
18+
pkg-config
19+
];
20+
buildInputs = [
21+
openssl
22+
];
23+
# Fix build. Reference:
24+
# - https://github.com/sfackler/rust-openssl/issues/1430
25+
# - https://docs.rs/openssl/latest/openssl/
26+
OPENSSL_NO_VENDOR = true;
27+
};
28+
29+
# Downloaded and compiled dependencies.
30+
cargoArtifacts = craneLib'.buildDepsOnly (
31+
commonArgs
32+
// {
33+
pname = "cloud-hypervisor-deps";
34+
}
35+
);
36+
37+
cargoPackageKvm = craneLib'.buildPackage (
38+
commonArgs
39+
// {
40+
inherit cargoArtifacts;
41+
pname = "cloud-hypervisor";
42+
# Don't execute tests here. We want this in a dedicated step.
43+
doCheck = false;
44+
cargoExtraArgs = "--features kvm";
45+
}
46+
);
47+
in
48+
{
49+
default = cargoPackageKvm;
50+
chvKvm = cargoPackageKvm;
51+
}

flake.lock

Lines changed: 74 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,32 @@
22
description = "OpenStack Packages and Modules for NixOS";
33

44
inputs = {
5-
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-24.11";
5+
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
6+
nixpkgs-25-05.url = "github:nixos/nixpkgs/nixos-25.05";
67
pre-commit-hooks-nix = {
78
url = "github:cachix/pre-commit-hooks.nix";
89
inputs.nixpkgs.follows = "nixpkgs";
910
};
11+
# Nix tooling to build cloud-hypervisor.
12+
crane.url = "github:ipetkov/crane/master";
13+
cloud-hypervisor-src.url = "github:cyberus-technology/cloud-hypervisor/gardenlinux-dev";
14+
cloud-hypervisor-src.flake = false;
15+
rust-overlay.url = "github:oxalica/rust-overlay";
16+
rust-overlay.inputs.nixpkgs.follows = "nixpkgs-25-05";
1017
};
1118

1219
outputs =
1320
{
1421
self,
1522
nixpkgs,
1623
flake-utils,
17-
pre-commit-hooks-nix,
1824
...
19-
}:
25+
}@inputs:
2026
flake-utils.lib.eachSystem [ "x86_64-linux" ] (
2127
system:
2228
let
2329
pkgs = import nixpkgs { inherit system; };
24-
pre-commit-hooks-run = pre-commit-hooks-nix.lib.${system}.run;
30+
pre-commit-hooks-run = inputs.pre-commit-hooks-nix.lib.${system}.run;
2531
in
2632
rec {
2733
formatter = pkgs.nixfmt-rfc-style;
@@ -44,7 +50,19 @@
4450
};
4551
};
4652

47-
packages = import ./packages { inherit (pkgs) callPackage python3Packages; };
53+
packages = (import ./packages { inherit (pkgs) callPackage python3Packages; }) // {
54+
cloud-hypervisor =
55+
let
56+
pkgs-25-05 = import inputs.nixpkgs-25-05 { inherit (pkgs) system; };
57+
rust-bin = (inputs.rust-overlay.lib.mkRustBin { }) pkgs-25-05;
58+
artifacts = pkgs.callPackage ./chv.nix {
59+
inherit (inputs) cloud-hypervisor-src;
60+
craneLib = inputs.crane.mkLib pkgs-25-05;
61+
rustToolchain = rust-bin.stable.latest.default;
62+
};
63+
in
64+
artifacts.default;
65+
};
4866

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

0 commit comments

Comments
 (0)