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

add nix flake #997

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ bench_*
/sdk/errors_table/
/rust-clippy-results.sarif
/Cross.toml
result
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,70 @@ To see the detailed logs from the CLI/server, run it with `RUST_LOG=trace` envir

---

## Nix

This repo provides a [Nix](https://github.com/DeterminateSystems/nix-installer) managed development environment. To start the development shell, run:

```console
> nix develop -c $SHELL
```

This will provide you with the development environment, including the Rust toolchain and the necessary dependencies.

```console
> cargo run --bin iggy
```

The Nix flake defines derivations for the cargo workspace packages `sdk`, `cli`, `server`, `bench` & `tools`. You can build and run
these derivations with:

```console
> nix build .#sdk
> nix build .#cli
> nix build .#server
> nix build .#bench
> nix build .#tools
```

We also export an overlay so that you can use `iggy` in your own Nix flake project:

```nix
# flake.nix
{
description = "My Iggy project";

inputs.nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.iggy.url = "github:iggy-rs/iggy";

outputs = {
self,
nixpkgs,
flake-utils,
iggy,
...
}: let
systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
outputs = flake-utils.lib.eachSystem systems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
iggy.overlay
];
};
in {
devShells.default = pkgs.mkShell {
packages = [
pkgs.iggy-pkgs.cli
pkgs.iggy-pkgs.server
];
};
});
}
```

---

## Examples

You can find the sample consumer & producer applications under `examples` directory. The purpose of these apps is to showcase the usage of the client SDK. To find out more about building the applications, please refer to the [getting started](https://docs.iggy.rs/introduction/getting-started) guide.
Expand Down
68 changes: 68 additions & 0 deletions bench.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
config,
lib,
dream2nix,
...
}: {
imports = [
dream2nix.modules.dream2nix.rust-cargo-lock
dream2nix.modules.dream2nix.rust-crane
];

deps = {nixpkgs, ...}: {
inherit
(nixpkgs)
stdenv
pkg-config
openssl
libiconv
darwin
;
};
env = {
OPENSSL_NO_VENDOR = 1;
PKG_CONFIG_PATH = "${config.deps.openssl.dev}/lib/pkgconfig";
};
mkDerivation = {
src = ./.;

nativeBuildInputs = [
config.deps.pkg-config
];
buildInputs =
[
config.deps.openssl
]
++ lib.optionals (config.deps.stdenv.isDarwin) [
config.deps.libiconv
config.deps.darwin.apple_sdk.frameworks.Security
config.deps.darwin.apple_sdk.frameworks.SystemConfiguration
];
};

rust-crane = {
depsDrv = {
env = {
OPENSSL_NO_VENDOR = 1;
PKG_CONFIG_PATH = "${config.deps.openssl.dev}/lib/pkgconfig";
};
mkDerivation = {
nativeBuildInputs = [
config.deps.pkg-config
];
buildInputs =
[
config.deps.openssl
]
++ lib.optionals (config.deps.stdenv.isDarwin) [
config.deps.libiconv
config.deps.darwin.apple_sdk.frameworks.Security
config.deps.darwin.apple_sdk.frameworks.SystemConfiguration
];
};
};
};

name = "bench";
version = "0.1.0";
}
68 changes: 68 additions & 0 deletions cli.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
config,
lib,
dream2nix,
...
}: {
imports = [
dream2nix.modules.dream2nix.rust-cargo-lock
dream2nix.modules.dream2nix.rust-crane
];

deps = {nixpkgs, ...}: {
inherit
(nixpkgs)
stdenv
pkg-config
openssl
libiconv
darwin
;
};
env = {
OPENSSL_NO_VENDOR = 1;
PKG_CONFIG_PATH = "${config.deps.openssl.dev}/lib/pkgconfig";
};
mkDerivation = {
src = ./.;

nativeBuildInputs = [
config.deps.pkg-config
];
buildInputs =
[
config.deps.openssl
]
++ lib.optionals (config.deps.stdenv.isDarwin) [
config.deps.libiconv
config.deps.darwin.apple_sdk.frameworks.Security
config.deps.darwin.apple_sdk.frameworks.SystemConfiguration
];
};

rust-crane = {
depsDrv = {
env = {
OPENSSL_NO_VENDOR = 1;
PKG_CONFIG_PATH = "${config.deps.openssl.dev}/lib/pkgconfig";
};
mkDerivation = {
nativeBuildInputs = [
config.deps.pkg-config
];
buildInputs =
[
config.deps.openssl
]
++ lib.optionals (config.deps.stdenv.isDarwin) [
config.deps.libiconv
config.deps.darwin.apple_sdk.frameworks.Security
config.deps.darwin.apple_sdk.frameworks.SystemConfiguration
];
};
};
};

name = "cli";
version = "0.20.1";
}
112 changes: 112 additions & 0 deletions flake.lock

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

Loading
Loading