-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
88 lines (74 loc) · 2.51 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
{
description = "Raw Rust FFI bindings to util-linux/libmount";
inputs = {
# Nixpkgs / NixOS version to use.
nixpkgs.url = "nixpkgs/nixos-23.11";
# Set of functions to make flake nix packages simpler to set up without
# external dependencies.
utils.url = "github:numtide/flake-utils";
# Nix library for building Rust projects
naersk.url = "github:nix-community/naersk/master";
# Backward compatibility for people without flakes enabled.
# https://github.com/edolstra/flake-compat
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
};
outputs = { self, nixpkgs, utils, naersk, flake-compat }:
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
naersk-lib = pkgs.callPackage naersk { };
in rec
{
packages.default = naersk-lib.buildPackage ./.;
# Development environment
devShells.default = with pkgs; mkShell {
buildInputs = [
# For Markdown
glow
pandoc
lynx
w3m
# For Rust
cargo
cargo-audit
cargo-flamegraph
cargo-modules
cargo-nextest
cargo-vet
cargo-valgrind
cargo-workspaces
lldb
pkg-config
rustc
rust-analyzer
rustfmt
rustPackages.clippy
# For code linting and formatting
nodejs_20
marksman
pre-commit
ruby
shellcheck
shfmt
# Required by `bindgen`
clang
libclang.lib
# `libmount` source files
util-linux.dev
];
# Rust source path
RUST_SRC_PATH = rustPlatform.rustLibSrc;
# Required by `bindgen`
LIBCLANG_PATH = pkgs.lib.makeLibraryPath [ pkgs.libclang ];
# Required by `pkg-config` to discover the locations of `libmount`
PKG_CONFIG_PATH = "${pkgs.util-linux.dev}/lib/pkgconfig";
# Inspired by: "C header includes in NixOS"
# https://discourse.nixos.org/t/c-header-includes-in-nixos/17410
# Solves the root cause of error messages emitted when trying to
# compile rsmount-sys from inside a VM.
# --- stderr
# src/wrapper.h:1:10: fatal error: 'libmount/libmount.h' file not found
C_INCLUDE_PATH="${pkgs.util-linux.dev}/include";
};
});
}