Skip to content
Open
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
66 changes: 66 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Nix Build
on: [push, pull_request]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- uses: cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72 # v30
with:
nix_path: nixpkgs=channel:nixos-unstable

- uses: cachix/cachix-action@ad2ddac53f961de1989924296a1f236fcfbaa4fc # v15
with:
name: nix-community
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
continue-on-error: true

- name: Build libfabric
run: nix build .#libfabric -L

- name: Build all packages
run: |
nix build .#cassini-headers -L
nix build .#libcxi -L
nix build .#accel-config -L

- name: Check flake
run: nix flake check

devshell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- uses: cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72 # v30
with:
nix_path: nixpkgs=channel:nixos-unstable

- name: Test devShell
run: |
nix develop .#ci --command bash -c '
./autogen.sh
./configure --prefix=$PWD/install \
--enable-tcp \
--enable-udp \
--enable-rxm \
--enable-shm \
--enable-verbs \
--enable-efa \
--enable-psm3
make -j$(nproc)
make install
./install/bin/fi_info -l
'

- name: Upload build logs
if: failure()
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: nix-devshell-config.log
path: config.log
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,9 @@ prov/efa/docs/doxygen/latex
# Clang's compilation database file and directory.
/.cache
/compile_commands.json

# nix
result
result-man
.envrc
.direnv/
89 changes: 89 additions & 0 deletions contrib/nix/lib/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Reusable library functions for libfabric Nix packaging
{ lib }:

{
# Combine CUDA header packages into a single derivation
# cuda_runtime.h needs headers from cuda_cccl, crt/ from cuda_nvcc, nvml.h from cuda_nvml_dev
mkCudaHeaders = pkgs: pkgs.symlinkJoin {
name = "cuda-headers-combined";
paths = [
pkgs.cudaPackages.cuda_cudart
pkgs.cudaPackages.cuda_cccl
pkgs.cudaPackages.cuda_nvcc
pkgs.cudaPackages.cuda_nvml_dev.include
];
};

# Get ROCm runtime if available on the platform (x86_64-linux only)
getRocmRuntime = pkgs:
if pkgs.stdenv.hostPlatform.isx86_64
then pkgs.rocmPackages.clr
else null;

# Conditionally return a value only on Linux
linuxOnly = pkgs: value:
if pkgs.stdenv.hostPlatform.isLinux then value else null;

# Generate cross-compiled package attributes with a prefix
# packages: attrset of packages
# prefix: string prefix for attribute names (e.g., "cross-aarch64-linux")
# names: list of package names to include
mkCrossPackageAttrs = { packages, prefix, names }:
lib.listToAttrs (map (name: {
name = "${prefix}-${name}";
value = packages.${name};
}) names);

# Create a cross-compilation dev shell
# Note: Linux-only deps (numactl, libnl, rdma-core) come via inputsFrom
mkCrossShell = { crossPkgs, crossPackages, arch }:
crossPkgs.mkShell {
name = "libfabric-cross-${arch}";
packages = with crossPkgs; [
autoconf
automake
libtool
pkg-config
libuuid
curl
];
inputsFrom = [ crossPackages.libfabric ];
shellHook = ''
echo "Cross-compilation shell: ${arch}"
echo "Target: ${crossPkgs.stdenv.hostPlatform.config}"
'';
};

# Dependencies that need native packages when cross-compiling
# Returns an attrset to merge with callPackage args
crossDepsForLibcxi = { nativePkgs, mkCudaHeaders }:
{
lm_sensors = nativePkgs.lm_sensors;
criterion = nativePkgs.criterion;
fuse = nativePkgs.fuse;
cuda_cudart = mkCudaHeaders nativePkgs;
level-zero = nativePkgs.level-zero;
rocm-runtime =
if nativePkgs.stdenv.hostPlatform.isx86_64
then nativePkgs.rocmPackages.clr
else null;
};

crossDepsForLibfabric = { nativePkgs, mkCudaHeaders }:
{
numactl = nativePkgs.numactl;
lttng-ust = nativePkgs.lttng-ust;
rdma-core = nativePkgs.rdma-core;
liburing = nativePkgs.liburing;
libnl = nativePkgs.libnl;
# DSA/idxd is x86-only (uses immintrin.h)
idxd-config = null;
cuda_cudart = mkCudaHeaders nativePkgs;
gdrcopy = nativePkgs.cudaPackages.gdrcopy or null;
rocm-runtime =
if nativePkgs.stdenv.hostPlatform.isx86_64
then nativePkgs.rocmPackages.clr
else null;
level-zero = nativePkgs.level-zero;
};
}
64 changes: 64 additions & 0 deletions contrib/nix/pkgs/accel-config/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
lib,
stdenv,
fetchFromGitHub,
autoreconfHook,
pkg-config,
libuuid,
json_c,
systemdLibs ? null,
kmod,
}:

stdenv.mkDerivation rec {
pname = "accel-config";
version = "4.1.9";

src = fetchFromGitHub {
owner = "intel";
repo = "idxd-config";
rev = "accel-config-v${version}";
hash = "sha256-uV6cOha+g5fZBq+ucrNmfUW+3gQzX9BKGYvYaeCYv40=";
};

nativeBuildInputs = [
autoreconfHook
pkg-config
];

buildInputs = [
libuuid
json_c
kmod
] ++ lib.optionals (systemdLibs != null) [
systemdLibs
];

configureFlags = [
"--disable-test"
"--disable-docs"
] ++ lib.optionals (systemdLibs == null) [
"--disable-systemd"
];

# Create version.m4 which is normally generated from git, and make
# git-version-gen a no-op so it doesn't overwrite during build
postPatch = ''
echo "m4_define([GIT_VERSION], [${version}])" > version.m4
cat > git-version-gen <<'EOF'
#!/bin/sh
exit 0
EOF
chmod +x git-version-gen
'';

enableParallelBuilding = true;

meta = with lib; {
description = "Utility for controlling and configuring Intel DSA and IAA accelerators";
homepage = "https://github.com/intel/idxd-config";
license = licenses.lgpl21Plus;
platforms = platforms.linux;
maintainers = with maintainers; [ ];
};
}
36 changes: 36 additions & 0 deletions contrib/nix/pkgs/cassini-headers/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
lib,
stdenvNoCC,
fetchFromGitHub,
}:

stdenvNoCC.mkDerivation rec {
pname = "cassini-headers";
version = "13.0.0";

src = fetchFromGitHub {
owner = "HewlettPackard";
repo = "shs-cassini-headers";
rev = "release/shs-${version}";
hash = "sha256-Fh8RZFAcqbEcbHCmSFNoIcbHP7uC/CovVdkgAA7SpNQ=";
};

dontBuild = true;

installPhase = ''
runHook preInstall
mkdir -p $out/include $out/share
cp -r include/* $out/include/
# Copy share directory (contains csr_defs.json needed by libcxi build)
cp -r share/* $out/share/
runHook postInstall
'';

meta = with lib; {
description = "Hardware definitions and C headers for HPE Cassini/Slingshot network interconnect";
homepage = "https://github.com/HewlettPackard/shs-cassini-headers";
license = with licenses; [ gpl2 bsd2 ];
platforms = platforms.linux;
maintainers = with maintainers; [ ];
};
}
34 changes: 34 additions & 0 deletions contrib/nix/pkgs/cxi-driver-headers/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
lib,
stdenvNoCC,
fetchFromGitHub,
}:

stdenvNoCC.mkDerivation rec {
pname = "cxi-driver-headers";
version = "13.0.0";

src = fetchFromGitHub {
owner = "HewlettPackard";
repo = "shs-cxi-driver";
rev = "release/shs-${version}";
hash = "sha256-kJNKuvg0x6gGMPlz1y5EiRReSOqx65dmmdwfqGpVptU=";
};

dontBuild = true;

installPhase = ''
runHook preInstall
mkdir -p $out/include
cp -r include/* $out/include/
runHook postInstall
'';

meta = with lib; {
description = "UAPI headers for HPE CXI driver (Slingshot)";
homepage = "https://github.com/HewlettPackard/shs-cxi-driver";
license = licenses.gpl2;
platforms = platforms.linux;
maintainers = with maintainers; [ ];
};
}
Loading