diff --git a/ci.nix b/ci.nix index efec76e32..3fa791f12 100644 --- a/ci.nix +++ b/ci.nix @@ -1,130 +1,72 @@ -{ nospdk ? false, norust ? false, spdk_rel ? false, asan ? false }: +{ rust ? "stable" +, spdk ? "develop" +, spdk-path ? null +} @ args: let sources = import ./nix/sources.nix; + pkgs = import sources.nixpkgs { - overlays = - [ (_: _: { inherit sources; }) (import ./nix/overlay.nix { }) ]; + overlays = [ + (_: _: { inherit sources; }) + (import ./nix/overlay.nix { }) + ]; }; -in -with pkgs; -let - nospdk_moth = - "You have requested environment without SPDK, you should provide it!"; - norust_moth = - "You have requested environment without RUST, you should provide it!"; - norustc_msg = "no rustc, use rustup tool to install it"; - channel = import ./nix/lib/rust.nix { inherit sources; }; + # python environment for test/python - pytest_inputs = python3.withPackages + pytest_inputs = with pkgs; python3.withPackages (ps: with ps; [ virtualenv grpcio grpcio-tools asyncssh black ]); - spdk = if (!spdk_rel) then libspdk-dev else libspdk; -in -mkShell { - name = "io-engine-dev-shell"; - # fortify does not work with -O0 which is used by spdk when --enable-debug - hardeningDisable = [ "fortify" ]; - buildInputs = [ - autoconf - automake - clang - cowsay - docker - docker-compose - e2fsprogs - etcd - fio - gdb - git - gnuplot - kubernetes-helm - libaio - libbsd - libexecinfo - libnvme - libpcap - libunwind - liburing - llvmPackages.bintools - llvmPackages.libclang - meson - ninja - nodejs-16_x - numactl - nvme-cli - openssl - pkg-config - pre-commit - procps - pytest_inputs - python3 - udev - utillinux - xfsprogs - yasm - ] ++ (if (nospdk) then [ spdk.buildInputs ] else [ spdk ]) - ++ pkgs.lib.optional (!norust && asan) channel.asan - ++ pkgs.lib.optional (!norust && !asan) channel.stable - ++ pkgs.lib.optional (!norust) channel.nightly; - RUST_NIGHTLY_PATH = channel.nightly; - LIBCLANG_PATH = io-engine.LIBCLANG_PATH; - PROTOC = io-engine.PROTOC; - PROTOC_INCLUDE = io-engine.PROTOC_INCLUDE; - SPDK_PATH = if nospdk then null else "${spdk}"; - FIO_SPDK = if nospdk then null else "${spdk}/fio/spdk_nvme"; - ETCD_BIN = "${etcd}/bin/etcd"; - LVM_BINS = "${lvm2.bin}/bin"; + shellAttrs = import ./spdk-rs/nix/shell { + inherit rust; + inherit spdk; + inherit spdk-path; + inherit sources; + inherit pkgs; - IO_ENGINE_DIR = if asan then "target/x86_64-unknown-linux-gnu/debug" else "target/debug"; + cfg = { + buildInputs = with pkgs; [ + docker + docker-compose + e2fsprogs + etcd + gdb + git + gnuplot + kubernetes-helm + nodejs-16_x + numactl + pytest_inputs + udev + xfsprogs + ]; - # ASAN-related Cargo settings. - ASAN_ENABLE = if asan then "1" else null; - ASAN_OPTIONS = if asan then "detect_leaks=0" else null; - ASAN_BUILD_ENV = if asan then "shell" else null; - RUSTFLAGS = if asan then "-Zsanitizer=address" else null; - CARGO_BUILD_RUSTFLAGS = if asan then "-Zbuild-std" else null; - CARGO_BUILD_TARGET = if asan then "x86_64-unknown-linux-gnu" else null; - CARGO_PROFILE_DEV_PANIC = if asan then "unwind" else null; - RUST_BACKTRACE = if asan then "full" else null; + shellEnv = with pkgs; { + PROTOC = io-engine.PROTOC; + PROTOC_INCLUDE = io-engine.PROTOC_INCLUDE; + ETCD_BIN = "${etcd}/bin/etcd"; + LVM_BINS = "${lvm2.bin}/bin"; + }; - shellHook = '' - export FIO="$(which fio 2> /dev/null)" - ${pkgs.lib.optionalString (asan) "export LLVM_SYMBOLIZER_DIR=$(dirname $(realpath $(which llvm-symbolizer)))"} + shellHook = '' + # SRCDIR is needed by docker-compose files as it requires absolute paths + export SRCDIR=`pwd` - ${pkgs.lib.optionalString (asan) "echo 'AddressSanitizer is enabled, forcing nightly rustc.'"} - ${pkgs.lib.optionalString (asan) "echo ' ASAN_ENABLE :' $\{ASAN_ENABLE\}"} - ${pkgs.lib.optionalString (asan) "echo ' ASAN_OPTIONS :' $\{ASAN_OPTIONS\}"} - ${pkgs.lib.optionalString (asan) "echo ' RUSTFLAGS :' $\{RUSTFLAGS\}"} - ${pkgs.lib.optionalString (asan) "echo ' CARGO_BUILD_RUSTFLAGS :' $\{CARGO_BUILD_RUSTFLAGS\}"} - ${pkgs.lib.optionalString (asan) "echo ' CARGO_BUILD_TARGET :' $\{CARGO_BUILD_TARGET\}"} - ${pkgs.lib.optionalString (asan) "echo ' CARGO_PROFILE_DEV_PANIC :' $\{CARGO_PROFILE_DEV_PANIC\}"} - ${pkgs.lib.optionalString (asan) "echo ' RUST_BACKTRACE :' $\{RUST_BACKTRACE\}"} - ${pkgs.lib.optionalString (asan) "echo ' LLVM_SYMBOLIZER_DIR :' $\{LLVM_SYMBOLIZER_DIR\}"} - ${pkgs.lib.optionalString (asan) "echo"} + export PATH="$PATH:$(pwd)/scripts/nix-sudo" - echo 'FIO version :' $(fio --version 2> /dev/null) - echo 'FIO path :' $FIO - ${pkgs.lib.optionalString (!nospdk) "echo 'SPDK version :' $(echo $SPDK_PATH | sed 's/.*libspdk-//g')"} - ${pkgs.lib.optionalString (!nospdk) "echo 'SPDK path :' $SPDK_PATH"} - ${pkgs.lib.optionalString (!nospdk) "echo 'SPDK FIO plugin :' $FIO_SPDK"} - echo 'LVM path :' $LVM_BINS - ${pkgs.lib.optionalString (!norust) "echo 'Rust version :' $(rustc --version 2> /dev/null || echo '${norustc_msg}')"} - ${pkgs.lib.optionalString (!norust) "echo 'Rust path :' $(which rustc 2> /dev/null || echo '${norustc_msg}')"} - echo 'I/O engine dir :' $IO_ENGINE_DIR - ${pkgs.lib.optionalString (nospdk) "cowsay ${nospdk_moth}"} - ${pkgs.lib.optionalString (nospdk) "export CFLAGS=-msse4"} - ${pkgs.lib.optionalString (nospdk) "echo"} - ${pkgs.lib.optionalString (norust) "cowsay ${norust_moth}"} - ${pkgs.lib.optionalString (norust) "echo 'Hint: use rustup tool.'"} - ${pkgs.lib.optionalString (norust) "echo"} + export IO_ENGINE_DIR="$RUST_TARGET_DEBUG" + ''; - # SRCDIR is needed by docker-compose files as it requires absolute paths - export SRCDIR=`pwd` - if [ -z "$CI" ]; then - echo - pre-commit install - pre-commit install --hook commit-msg - fi - export PATH=$PATH:$(pwd)/scripts/nix-sudo - ''; -} + shellInfoHook = '' + echo + echo "PROTOC : $PROTOC" + echo "PROTOC_INCLUDE : $PROTOC_INCLUDE" + echo "ETCD_BIN : $ETCD_BIN" + echo "LVM path : $LVM_BINS" + echo "I/O engine dir : $IO_ENGINE_DIR" + ''; + }; + }; +in + pkgs.mkShell shellAttrs // { + name = "io-engine-dev-shell"; + } diff --git a/ide.nix b/ide.nix new file mode 100644 index 000000000..18b89c00c --- /dev/null +++ b/ide.nix @@ -0,0 +1,9 @@ +{ rust ? "none" +, spdk ? "develop" +, spdk-path ? null +} @ args: + import ./ci.nix { + inherit rust; + inherit spdk; + inherit spdk-path; + } diff --git a/nix/lib/rust.nix b/nix/lib/rust.nix deleted file mode 100644 index 4ad077933..000000000 --- a/nix/lib/rust.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ sources ? import ../sources.nix }: -let - pkgs = - import sources.nixpkgs { overlays = [ (import sources.rust-overlay) ]; }; - nightly_version = "2023-08-25"; - stable_version = "1.72.0"; -in -with pkgs; rec { - nightly = rust-bin.nightly.${nightly_version}.default; - stable = rust-bin.stable.${stable_version}.default; - asan = rust-bin.nightly.${nightly_version}.default; -} diff --git a/nix/overlay.nix b/nix/overlay.nix index a23923cdc..2b08b995d 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -4,19 +4,14 @@ let img_prefix = if product_prefix == "" then config.product_prefix else product_prefix; in self: super: rec { - fio = super.callPackage ./pkgs/fio { }; sourcer = super.callPackage ./lib/sourcer.nix { }; images = super.callPackage ./pkgs/images { inherit img_tag img_org img_prefix; }; - libnvme = super.callPackage ./pkgs/libnvme { }; - libspdk = (super.callPackage ./pkgs/libspdk { with-fio = false; }).release; - libspdk-fio = (super.callPackage ./pkgs/libspdk { with-fio = true; multi-outputs = true; }).release; - libspdk-dev = (super.callPackage ./pkgs/libspdk { with-fio = true; }).debug; io-engine = (super.callPackage ./pkgs/io-engine { inherit tag sourcer; }).release; io-engine-adhoc = (super.callPackage ./pkgs/io-engine { inherit tag; }).adhoc; io-engine-dev = (super.callPackage ./pkgs/io-engine { inherit tag; }).debug; mkContainerEnv = super.callPackage ./lib/mkContainerEnv.nix { }; ms-buildenv = super.callPackage ./pkgs/ms-buildenv { }; - nvme-cli = super.callPackage ./pkgs/nvme-cli { }; nvmet-cli = super.callPackage ./pkgs/nvmet-cli { }; units = (super.callPackage ./pkgs/io-engine/units.nix { inherit tag sourcer; }); } +// (import ../spdk-rs/nix/overlay.nix { } self super) diff --git a/nix/pkgs/fio/default.nix b/nix/pkgs/fio/default.nix deleted file mode 100644 index bea485c9e..000000000 --- a/nix/pkgs/fio/default.nix +++ /dev/null @@ -1,58 +0,0 @@ -{ lib -, stdenv -, fetchFromGitHub -, makeWrapper -, libaio -, python3 -, zlib -, withGnuplot ? false -, gnuplot ? null -}: - -stdenv.mkDerivation rec { - pname = "fio"; - version = "3.37"; - - src = fetchFromGitHub { - owner = "axboe"; - repo = "fio"; - rev = "fio-${version}"; - sha256 = "sha256-dKHTxVglH10aV44RuSeIFATn83DVdmCYtuaiS3b0+zo="; - }; - - buildInputs = [ python3 zlib ] - ++ lib.optional (!stdenv.isDarwin) libaio; - - nativeBuildInputs = [ makeWrapper ]; - - strictDeps = true; - - enableParallelBuilding = true; - - postPatch = '' - substituteInPlace Makefile \ - --replace "mandir = /usr/share/man" "mandir = \$(prefix)/man" \ - --replace "sharedir = /usr/share/fio" "sharedir = \$(prefix)/share/fio" - substituteInPlace tools/plot/fio2gnuplot --replace /usr/share/fio $out/share/fio - ''; - - preInstall = '' - mkdir -p $dev/include - cp -p --parents $(find . -name "*.h") $dev/include - ''; - - postInstall = lib.optionalString withGnuplot '' - wrapProgram $out/bin/fio2gnuplot \ - --prefix PATH : ${lib.makeBinPath [ gnuplot ]} - ''; - - outputs = [ "out" "dev" ]; - setOutputFlags = false; - - meta = with lib; { - description = "Flexible IO Tester - an IO benchmark tool"; - homepage = "https://git.kernel.dk/cgit/fio/"; - license = licenses.gpl2; - platforms = platforms.unix; - }; -} diff --git a/nix/pkgs/io-engine/cargo-package.nix b/nix/pkgs/io-engine/cargo-package.nix index bf03e2518..47282fa32 100644 --- a/nix/pkgs/io-engine/cargo-package.nix +++ b/nix/pkgs/io-engine/cargo-package.nix @@ -5,6 +5,7 @@ , lib , libaio , libbsd +, libexecinfo , libnvme , libspdk , libspdk-dev @@ -30,7 +31,7 @@ }: let version = versions.version; - channel = import ../../lib/rust.nix { inherit sources; }; + channel = import ../../../spdk-rs/nix/lib/rust.nix { inherit sources; }; rustPlatform = makeRustPlatform { rustc = channel.stable; cargo = channel.stable; @@ -75,6 +76,7 @@ let buildInputs = [ libaio libbsd + libexecinfo libnvme libpcap libunwind @@ -102,12 +104,12 @@ in cargoBuildFlags = "--bin io-engine --bin io-engine-client --bin casperf"; buildType = "release"; buildInputs = buildProps.buildInputs ++ [ libspdk ]; - SPDK_PATH = "${libspdk}"; + SPDK_ROOT_DIR = "${libspdk}"; }); debug = rustPlatform.buildRustPackage (buildProps // { cargoBuildFlags = "--workspace --bins --exclude io-engine-bench"; buildType = "debug"; buildInputs = buildProps.buildInputs ++ [ libspdk-dev ]; - SPDK_PATH = "${libspdk-dev}"; + SPDK_ROOT_DIR = "${libspdk-dev}"; }); } diff --git a/nix/pkgs/libnvme/default.nix b/nix/pkgs/libnvme/default.nix deleted file mode 100644 index c434f8b2b..000000000 --- a/nix/pkgs/libnvme/default.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ stdenv, lib, fetchgit, json_c, libuuid, meson, ninja, openssl, pkg-config, python3, sources }: - -stdenv.mkDerivation rec { - version = sources.libnvme.rev; - name = "libnvme-${version}"; - - src = sources.libnvme; - - nativeBuildInputs = [ json_c libuuid meson ninja openssl pkg-config python3 ]; - meta = { - description = "Userspace NVMe library"; - longDescription = '' - This is the libnvme development C library. libnvme provides type defintions for NVMe specification structures, enumerations, and bit fields, helper functions to construct, dispatch, and decode commands and payloads, and utilities to connect, scan, and manage nvme devices on a Linux system. - ''; - homepage = "https://github.com/linux-nvme/libnvme"; - licenses = lib.licenses.lgpl21Plus; - maintainers = [ "jonathan.teh@mayadata.io" ]; - }; -} diff --git a/nix/pkgs/libspdk/default.nix b/nix/pkgs/libspdk/default.nix deleted file mode 100644 index 06ebca40b..000000000 --- a/nix/pkgs/libspdk/default.nix +++ /dev/null @@ -1,223 +0,0 @@ -{ binutils -, cunit -, fetchFromGitHub -, pkg-config -, lcov -, lib -, libaio -, libbpf -, libbsd -, libelf -, libexecinfo -, libpcap -, liburing -, libuuid -, nasm -, cmake -, fio -, ninja -, jansson -, meson -, ncurses -, numactl -, openssl -, python3 -, stdenv -, libtool -, yasm -, targetPlatform -, buildPlatform -, buildPackages -, llvmPackages -, pkgs -, gcc -, zlib -, autoconf -, automake -, with-fio -, multi-outputs ? false -}: -let - fio-include = "${fio.dev}/include"; - fio-output = if multi-outputs then "fio" else "out"; - - # Derivation attributes for production version of libspdk - # - # How to update to new libspdk commit: - # 1. Push your SPDK commit to openebs repo. - # 2. Copy git commit hash to 'rev' field, and copy first 9 digits of it - # to 'version' field. - # 3. Leave old SHA256 intact. - # 4. Login to your machine and run 'sudo nix store gc' to get rid of stale - # copies of SPDK package. - # 5. Enter your mayastor 'nix-shell'. - # 6. Wait until SPDK pkg build fails with - # "hash mismatch in fixed-output derivation" error. - # 7. Copy SHA256 from 'got' of the error message to 'sha256' field. - # 8. 'nix-shell' build must now succeed. - drvAttrs = rec { - version = "24.01-535a9e2"; - - src = fetchFromGitHub { - owner = "openebs"; - repo = "spdk"; - rev = "535a9e23cf9c0692e307a72f18856a528cdec9ce"; - sha256 = "sha256-1FhOOr3gjmmk/p0IACI/A/uIIN2yiFxGSLAr377HiZQ="; - fetchSubmodules = true; - }; - - nativeBuildInputs = [ - meson - ninja - pkg-config - python3 - llvmPackages.clang - gcc - cmake - ]; - - buildInputs = [ - autoconf - automake - binutils - jansson - libaio - libbpf - libbsd - libelf - libexecinfo - libpcap - libtool - liburing - libuuid - nasm - ncurses - numactl - openssl - (python3.withPackages (ps: with ps; [ pyelftools ])) - yasm - zlib - ]; - - configureFlags = (if (targetPlatform.config == "x86_64-unknown-linux-gnu") then - [ - "--target-arch=nehalem" - "--without-shared" - "--without-crypto" - ] - else if (targetPlatform.config == "aarch64-unknown-linux-gnu") then - [ - "--target-arch=armv8-a+crypto" - ] - else - [ ] - ) ++ - (if (targetPlatform.config != buildPlatform.config) then [ "--cross-prefix=${targetPlatform.config}" ] else [ ]) ++ - (if with-fio then [ "--with-fio=${fio-include}" ] else [ ]) ++ - [ - "--with-uring" - "--without-uring-zns" - "--without-nvme-cuse" - "--without-fuse" - "--disable-unit-tests" - "--disable-tests" - ]; - - configurePhase = '' - patchShebangs ./. > /dev/null - export AS=nasm - ./configure ${builtins.concatStringsSep " " configureFlags} - ''; - enableParallelBuilding = true; - - hardeningDisable = [ "all" ]; - - buildPhase = (if (targetPlatform.config == "aarch64-unknown-linux-gnu") then - [ - "DPDKBUILD_FLAGS=-Dplatform=generic" - ] - else - [ ] - ) ++ - [ - "make -j`nproc`" - ]; - - installPhase = '' - echo "installing SPDK to $out" - mkdir -p $out/lib/pkgconfig - mkdir $out/bin - - pushd include - find . -type f -name "*.h" -exec install -vD "{}" $out/include/{} \; - popd - - pushd lib - find . -type f -name "*.h" -exec install -vD "{}" $out/include/spdk/lib/{} \; - popd - - # copy private headers from bdev modules needed for creating of bdevs - pushd module - find . -type f -name "*.h" -exec install -vD "{}" $out/include/spdk/module/{} \; - popd - - find . -executable -type f -name 'bdevperf' -exec install -vD "{}" $out/bin \; - - # copy libraries - install -v build/lib/*.a $out/lib/ - install -v build/lib/pkgconfig/*.pc $out/lib/pkgconfig/ - install -v dpdk/build/lib/*.a $out/lib/ - install -v dpdk/build/lib/pkgconfig/*.pc $out/lib/pkgconfig/ - '' + lib.optionalString targetPlatform.isx86_64 '' - install -v isa-l/.libs/*.a $out/lib/ - install -v isa-l/*.pc $out/lib/pkgconfig/ - install -v isa-l-crypto/.libs/*.a $out/lib/ - install -v isa-l-crypto/*.pc $out/lib/pkgconfig/ - - # fix paths in pkg config files - build_dir=`pwd` - for i in `ls $out/lib/pkgconfig/*.pc`; - do - echo "fixing pkg config paths in '$i' ..." - sed -i "s,$build_dir/build/lib,$out/lib,g" $i - sed -i "s,$build_dir/dpdk/build,$out,g" $i - sed -i "s,$build_dir/intel-ipsec-mb/lib,$out/lib,g" $i - sed -i "s,$build_dir/isa-l/.libs,$out/lib,g" $i - sed -i "s,$build_dir/isa-l-crypto/.libs,$out/lib,g" $i - sed -i "s,prefix\=/usr/local,prefix\=$out,g" $i - done - '' + lib.optionalString (with-fio && !multi-outputs) '' - mkdir $out/fio - cp build/fio/spdk_* $out/fio - '' + lib.optionalString (with-fio && multi-outputs) '' - mkdir $fio - cp build/fio/spdk_* $fio - ''; - - outputs = [ "out" ] ++ lib.optional (fio-output != "out") fio-output; - }; -in -{ - release = llvmPackages.stdenv.mkDerivation (drvAttrs // { - pname = "libspdk"; - dontStrip = false; - }); - debug = llvmPackages.stdenv.mkDerivation (drvAttrs // { - pname = "libspdk-dev"; - dontStrip = true; - nativeBuildInputs = drvAttrs.nativeBuildInputs ++ [ cunit lcov ]; - buildInputs = drvAttrs.buildInputs ++ [ cunit lcov ]; - configurePhase = '' - patchShebangs ./. > /dev/null - export AS=nasm - ./configure ${builtins.concatStringsSep " " (drvAttrs.configureFlags ++ - [ - "--enable-debug" - ])} - ''; - installPhase = drvAttrs.installPhase + '' - echo "Copying test files" - cp -ar test $out/test - ''; - }); -} diff --git a/nix/pkgs/nvme-cli/default.nix b/nix/pkgs/nvme-cli/default.nix deleted file mode 100644 index 2c8bbf038..000000000 --- a/nix/pkgs/nvme-cli/default.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ stdenv, lib, libuuid, pkg-config, sources }: - -stdenv.mkDerivation rec { - version = sources.nvme-cli.rev; - name = "nvme-cli-${version}"; - src = sources.nvme-cli; - - nativeBuildInputs = [ pkg-config ]; - buildInputs = [ libuuid ]; - - makeFlags = [ "DESTDIR=$(out)" "PREFIX=" ]; - - # To omit the hostnqn and hostid files that are impure and should be unique - # for each target host: - installTargets = [ "install-spec" ]; - - meta = with lib; { - description = sources.nvme-cli.description; - homepage = sources.nvme-cli.homepage; - license = licenses.gpl2Plus; - platforms = platforms.linux; - }; -} diff --git a/nix/sources.json b/nix/sources.json deleted file mode 100644 index 00b706d74..000000000 --- a/nix/sources.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "libnvme": { - "branch": "master", - "description": "nvme client library", - "homepage": "https://github.com/linux-nvme/libnvme", - "owner": "linux-nvme", - "repo": "libnvme", - "rev": "v1.0-rc3", - "sha256": "0wkr0axmm4wqjncb6x7fjyg0wxjdi9f2qd3df6ph671qh5ralrjy", - "type": "tarball", - "url": "https://github.com/linux-nvme/libnvme/archive/v1.0-rc3.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "nvme-cli": { - "branch": "master", - "description": "NVM-Express user space tooling for Linux.", - "homepage": "https://github.com/linux-nvme/nvme-cli", - "owner": "linux-nvme", - "repo": "nvme-cli", - "rev": "v1.16", - "sha256": "130x5cf6kkcnyg5qd35igii249ysfjnbxp1pxfwkickmqg3d007z", - "type": "tarball", - "url": "https://github.com/linux-nvme/nvme-cli/archive/refs/tags/v1.16.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "niv": { - "branch": "master", - "description": "Easy dependency management for Nix projects", - "homepage": "https://github.com/nmattia/niv", - "owner": "nmattia", - "repo": "niv", - "rev": "1819632b5823e0527da28ad82fecd6be5136c1e9", - "sha256": "08jz17756qchq0zrqmapcm33nr4ms9f630mycc06i6zkfwl5yh5i", - "type": "tarball", - "url": "https://github.com/nmattia/niv/archive/1819632b5823e0527da28ad82fecd6be5136c1e9.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "nixpkgs": { - "branch": "master", - "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to", - "homepage": "https://github.com/NixOS/nixpkgs", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "22.11", - "sha256": "11w3wn2yjhaa5pv20gbfbirvjq6i3m7pqrq2msf0g7cv44vijwgw", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/22.11.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "rust-overlay": { - "branch": "master", - "description": "Pure and reproducible nix overlay for binary distributed rust toolchains", - "homepage": "", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "673e2d3d2a3951adc6f5e3351c9fce6ad130baed", - "sha256": "sha256:1vgjkaikv8lwm3kmb4jbc96kxhdy38nmf1v4s7nmx6j4bd8pmlyd", - "type": "tarball", - "url": "https://github.com/oxalica/rust-overlay/archive/673e2d3d2a3951adc6f5e3351c9fce6ad130baed.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - } -} diff --git a/nix/sources.nix b/nix/sources.nix index ddf8be247..28a48153a 100644 --- a/nix/sources.nix +++ b/nix/sources.nix @@ -1,136 +1,3 @@ -# This file has been generated by Niv. -let - # - # The fetchers. fetch_ fetches specs of type . - # - fetch_file = pkgs: spec: - if spec.builtin or true then - builtins_fetchurl { inherit (spec) url sha256; } - else - pkgs.fetchurl { inherit (spec) url sha256; }; - - fetch_tarball = pkgs: spec: - if spec.builtin or true then - builtins_fetchTarball { inherit (spec) url sha256; } - else - pkgs.fetchzip { inherit (spec) url sha256; }; - - fetch_git = spec: - builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; }; - - fetch_builtin-tarball = spec: - builtins.trace - '' - WARNING: - The niv type "builtin-tarball" will soon be deprecated. You should - instead use `builtin = true`. - - $ niv modify -a type=tarball -a builtin=true - '' - builtins_fetchTarball - { inherit (spec) url sha256; }; - - fetch_builtin-url = spec: - builtins.trace - '' - WARNING: - The niv type "builtin-url" will soon be deprecated. You should - instead use `builtin = true`. - - $ niv modify -a type=file -a builtin=true - '' - (builtins_fetchurl { inherit (spec) url sha256; }); - - # - # Various helpers - # - - # The set of packages used when specs are fetched using non-builtins. - mkPkgs = sources: - let - sourcesNixpkgs = - import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { }; - hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; - hasThisAsNixpkgsPath = == ./.; - in - if builtins.hasAttr "nixpkgs" sources - then sourcesNixpkgs - else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then - import { } - else - abort - '' - Please specify either (through -I or NIX_PATH=nixpkgs=...) or - add a package called "nixpkgs" to your sources.json. - ''; - - # The actual fetching function. - fetch = pkgs: name: spec: - - if ! builtins.hasAttr "type" spec then - abort "ERROR: niv spec ${name} does not have a 'type' attribute" - else if spec.type == "file" then fetch_file pkgs spec - else if spec.type == "tarball" then fetch_tarball pkgs spec - else if spec.type == "git" then fetch_git spec - else if spec.type == "builtin-tarball" then fetch_builtin-tarball spec - else if spec.type == "builtin-url" then fetch_builtin-url spec - else - abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; - - # Ports of functions for older nix versions - - # a Nix version of mapAttrs if the built-in doesn't exist - mapAttrs = builtins.mapAttrs or ( - f: set: with builtins; - listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) - ); - - # fetchTarball version that is compatible between all the versions of Nix - builtins_fetchTarball = { url, sha256 }@attrs: - let - inherit (builtins) lessThan nixVersion fetchTarball; - in - if lessThan nixVersion "1.12" then - fetchTarball { inherit url; } - else - fetchTarball attrs; - - # fetchurl version that is compatible between all the versions of Nix - builtins_fetchurl = { url, sha256 }@attrs: - let - inherit (builtins) lessThan nixVersion fetchurl; - in - if lessThan nixVersion "1.12" then - fetchurl { inherit url; } - else - fetchurl attrs; - - # Create the final "sources" from the config - mkSources = config: - mapAttrs - ( - name: spec: - if builtins.hasAttr "outPath" spec - then - abort - "The values in sources.json should not have an 'outPath' attribute" - else - spec // { outPath = fetch config.pkgs name spec; } - ) - config.sources; - - # The "config" used by the fetchers - mkConfig = - { sourcesFile ? ./sources.json - , sources ? builtins.fromJSON (builtins.readFile sourcesFile) - , pkgs ? mkPkgs sources - }: rec { - # The sources, i.e. the attribute set of spec name to spec - inherit sources; - - # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers - inherit pkgs; - }; -in -mkSources (mkConfig { }) // { __functor = _: settings: mkSources (mkConfig settings); } +# Redirects to `spdk-rs`. +import ../spdk-rs/nix/sources.nix diff --git a/shell.nix b/shell.nix index f2f95bc53..7088c8aa2 100644 --- a/shell.nix +++ b/shell.nix @@ -1,92 +1,9 @@ -{ nospdk ? false, spdk_rel ? false }: -let - sources = import ./nix/sources.nix; - pkgs = import sources.nixpkgs { - overlays = - [ (_: _: { inherit sources; }) (import ./nix/overlay.nix { }) ]; - }; -in -with pkgs; -let - nospdk_moth = - "You have requested environment without SPDK, you should provide it!"; - norustc_msg = "no rustc, use rustup tool to install it"; - channel = import ./nix/lib/rust.nix { inherit sources; }; - # python environment for test/python - pytest_inputs = python3.withPackages - (ps: with ps; [ virtualenv grpcio grpcio-tools asyncssh black ]); - spdk = if (!spdk_rel) then libspdk-dev else libspdk; -in -mkShell { - name = "io-engine-dev-shell"; - # fortify does not work with -O0 which is used by spdk when --enable-debug - hardeningDisable = [ "fortify" ]; - buildInputs = [ - autoconf - automake - clang - cowsay - etcd - fio - gnuplot - libaio - libbsd - libnvme - libpcap - libunwind - liburing - llvmPackages.bintools - llvmPackages.libclang - meson - ninja - nodejs-16_x - numactl - nvme-cli - openssl - pkg-config - pre-commit - procps - pytest_inputs - python3 - udev - utillinux - xfsprogs - yasm - ] ++ (if (nospdk) then [ spdk.buildInputs ] else [ spdk ]); - - LIBCLANG_PATH = io-engine.LIBCLANG_PATH; - PROTOC = io-engine.PROTOC; - PROTOC_INCLUDE = io-engine.PROTOC_INCLUDE; - SPDK_PATH = if nospdk then null else "${spdk}"; - FIO_SPDK = if nospdk then null else "${spdk}/fio/spdk_nvme"; - ETCD_BIN = "${etcd}/bin/etcd"; - ETCDCTL_API = "3"; - LVM_BINS = "${lvm2.bin}/bin"; - - IO_ENGINE_DIR = "target/debug"; - - shellHook = '' - export FIO="$(which fio 2> /dev/null)" - echo 'FIO version :' $(fio --version 2> /dev/null) - echo 'FIO path :' $FIO - ${pkgs.lib.optionalString (!nospdk) "echo 'SPDK version :' $(echo $SPDK_PATH | sed 's/.*libspdk-//g')"} - ${pkgs.lib.optionalString (!nospdk) "echo 'SPDK path :' $SPDK_PATH"} - ${pkgs.lib.optionalString (!nospdk) "echo 'SPDK FIO plugin :' $FIO_SPDK"} - echo 'LVM path :' $LVM_BINS - echo 'Rust version :' $(rustc --version 2> /dev/null || echo '${norustc_msg}') - echo 'Rust path :' $(which rustc 2> /dev/null || echo '${norustc_msg}') - echo 'I/O engine dir :' $IO_ENGINE_DIR - ${pkgs.lib.optionalString (nospdk) "cowsay ${nospdk_moth}"} - ${pkgs.lib.optionalString (nospdk) "export CFLAGS=-msse4"} - ${pkgs.lib.optionalString (nospdk) "echo"} - - # SRCDIR is needed by docker-compose files as it requires absolute paths - export SRCDIR=`pwd` - if [ -z "$CI" ]; then - echo - pre-commit install - pre-commit install --hook commit-msg - fi - export PATH=$PATH:$(pwd)/scripts/nix-sudo - ''; -} +{ rust ? "stable" +, spdk ? "develop" +, spdk-path ? null +} @ args: + import ./ci.nix { + inherit rust; + inherit spdk; + inherit spdk-path; + } diff --git a/spdk-rs b/spdk-rs index d9fd02762..ea6ef4ef3 160000 --- a/spdk-rs +++ b/spdk-rs @@ -1 +1 @@ -Subproject commit d9fd027627266f1731064101624160f031779b05 +Subproject commit ea6ef4ef351429fd76cbaec20d0735dcfa2588e3 diff --git a/test/python/common/fio_spdk.py b/test/python/common/fio_spdk.py index ce7550403..51be9d893 100644 --- a/test/python/common/fio_spdk.py +++ b/test/python/common/fio_spdk.py @@ -25,7 +25,7 @@ def __init__(self, name, rw, uris, runtime=15): def build(self) -> str: spdk_fio_path = os.environ.get("FIO_SPDK") if spdk_fio_path is None: - spdk_path = os.environ.get("SPDK_PATH") + spdk_path = os.environ.get("SPDK_ROOT_DIR") if spdk_path is None: spdk_path = os.getcwd() + "/../../spdk-rs/spdk/build" spdk_fio_path = "{}/fio/spdk_nvme".format(spdk_path)