From 28d46aac23257c007dc164d993238216401e7d14 Mon Sep 17 00:00:00 2001 From: Nora Widdecke Date: Wed, 3 Mar 2021 20:48:28 +0100 Subject: Add NixOS instructions to readme. - Closes #685 --- README.md | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/README.md b/README.md index 1cc1552d..90bcb957 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,67 @@ $ sudo pacman -S git cargo clang make pkg-config nettle openssl capnproto sqlite $ sudo dnf install git rustc cargo clang make pkg-config nettle-devel openssl-devel capnproto sqlite-devel ``` +### NixOS + +Development environment for use with `nix-shell` or `direnv`: +
+ + `shell.nix` + + +```nix +let + moz_overlay = import (builtins.fetchTarball + "https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz"); + nixpkgs = import { overlays = [ moz_overlay ]; }; + rust_channel = (nixpkgs.rustChannelOf { rustToolchain = ./rust-toolchain; }); +in with nixpkgs; +pkgs.mkShell { + buildInputs = [ + nettle + openssl + sqlite + + # for the python bindings + (python3.withPackages + (python-packages: with python-packages; [ setuptools pip ])) + ]; + + nativeBuildInputs = [ + (rust_channel.rust.override{ + extensions = [ "rust-src" "rust-std" ]; + }) + + llvmPackages.clang + pkgconfig + capnproto + + # for the python bindings + (python3.withPackages + (python-packages: with python-packages; [ setuptools pip ])) + + # tools + codespell + ]; + + RUST_BACKTRACE = 1; + + # NixOS enables "fortify" by default, but that is incompatible with + # gcc -O0 in `make -Cffi examples`. + hardeningDisable = [ "fortify" ]; + + # compilation of -sys packages requires manually setting LIBCLANG_PATH + LIBCLANG_PATH = "${pkgs.llvmPackages.libclang}/lib"; + + # Workaround for https://github.com/mozilla/nixpkgs-mozilla/issues/240 + # with Rust 1.46.0 + LD_LIBRARY_PATH = ''${zlib.out}/lib''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}''; +} +``` + +
+ + ### macOS (Mojave), using MacPorts ```shell -- cgit v1.2.3