Skip to content

Commit

Permalink
Give users chance to use their own rust version in nix-shell.
Browse files Browse the repository at this point in the history
Example usage: nix-shell --arg norust true

Update mozilla-pkgs overlay in order to get the fix for
mozilla/nixpkgs-mozilla#225 and enable us
to update rust nightly to latest snapshot (done on behalf of this
commit too).
  • Loading branch information
Jan Kryl committed Jul 29, 2020
1 parent e7df588 commit 7e1eaa8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 145 deletions.
5 changes: 5 additions & 0 deletions nix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,10 @@ With the overlay in place you can start nix-shell a within the project root.
To have iscsid enabled on your NixOS system you can use the service file
in your `configuration`.

## nix-shell

Build environment for mayastor including all test and debug dependencies.
It can be run with two arguments:

* `--arg nospdk true`: to use your own SPDK.
* `--arg norust true`: to use your own rust toolchain.
2 changes: 1 addition & 1 deletion nix/lib/rust.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ let
pkgs = import sources.nixpkgs { overlays = [ (import sources.nixpkgs-mozilla) ]; };
in
rec {
nightly = pkgs.rustChannelOf { channel = "nightly"; date = "2020-06-21"; };
nightly = pkgs.rustChannelOf { channel = "nightly"; date = "2020-07-26"; };
stable = pkgs.rustChannelOf { channel = "stable"; };
}
3 changes: 1 addition & 2 deletions nix/pkgs/mayastor/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ let
in
rustPlatform.buildRustPackage rec {
name = "mayastor";
cargoSha256 = "10vq6856l8ggfhqp2yayby199vdrngkid3bsfsnrys0rvczr645m";

#cargoSha256 = "0000000000000000000000000000000000000000000000000000";
cargoSha256 = "10vq6856l8ggfhqp2yayby199vdrngkid3bsfsnrys0rvczr645m";
version = sources.mayastor.branch;
src = if release then sources.mayastor else
whitelistSource ../../../. [
Expand Down
131 changes: 0 additions & 131 deletions nix/pkgs/mayastor/mayastor.nix

This file was deleted.

8 changes: 4 additions & 4 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@
"nixpkgs-mozilla": {
"branch": "master",
"description": "mozilla related nixpkgs (extends nixos/nixpkgs repo)",
"homepage": null,
"homepage": "https://github.com/mozilla/nixpkgs-mozilla",
"owner": "mozilla",
"repo": "nixpkgs-mozilla",
"rev": "e912ed483e980dfb4666ae0ed17845c4220e5e7c",
"sha256": "08fvzb8w80bkkabc1iyhzd15f4sm7ra10jn32kfch5klgl0gj3j3",
"rev": "efda5b357451dbb0431f983cca679ae3cd9b9829",
"sha256": "11wqrg86g3qva67vnk81ynvqyfj0zxk83cbrf0p9hsvxiwxs8469",
"type": "tarball",
"url": "https://github.com/mozilla/nixpkgs-mozilla/archive/e912ed483e980dfb4666ae0ed17845c4220e5e7c.tar.gz",
"url": "https://github.com/mozilla/nixpkgs-mozilla/archive/efda5b357451dbb0431f983cca679ae3cd9b9829.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
22 changes: 15 additions & 7 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{ nospdk ? false }:
{ nospdk ? false
, norust ? false
}:
let
sources = import ./nix/sources.nix;
pkgs = import sources.nixpkgs {
Expand All @@ -10,15 +12,15 @@ let
in
with pkgs;
let
moth = "You have requested environment without SPDK, you should provide it!";
nospdk_moth = "You have requested environment without SPDK, you should provide it!";
norust_moth = "You have requested environment without rust, you should provide it!";
channel = import ./nix/lib/rust.nix { inherit sources; };
in
mkShell {

# fortify does not work with -O0 which is used by spdk when --enable-debug
hardeningDisable = [ "fortify" ];
buildInputs = [
channel.nightly.rust
clang
cowsay
e2fsprogs
Expand All @@ -41,18 +43,24 @@ mkShell {
python3
utillinux
xfsprogs
] ++ pkgs.lib.optionals (nospdk) libspdk.buildInputs
++ pkgs.lib.optional (!nospdk) libspdk;
]
++ (if (nospdk) then [ libspdk.buildInputs ] else [ libspdk ])
++ pkgs.lib.optional (!norust) channel.nightly.rust;

LIBCLANG_PATH = mayastor.LIBCLANG_PATH;
PROTOC = mayastor.PROTOC;
PROTOC_INCLUDE = mayastor.PROTOC_INCLUDE;

SPDK_PATH = if nospdk then null else "${libspdk}";

shellHook = ''
${pkgs.lib.optionalString (nospdk) "cowsay ${moth}"}
${pkgs.lib.optionalString (nospdk) "cowsay ${nospdk_moth}"}
${pkgs.lib.optionalString (nospdk) "export CFLAGS=-msse4"}
${pkgs.lib.optionalString (nospdk)
''export RUSTFLAGS="-C link-args=-Wl,-rpath,$(pwd)/spdk-sys/spdk"''}
${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"}
pre-commit install
'';
}

0 comments on commit 7e1eaa8

Please sign in to comment.