Skip to content

Commit 3f53522

Browse files
committed
add a flake.nix file for the development environment, add direnv-related files to .gitignore
1 parent ee0d178 commit 3f53522

File tree

3 files changed

+133
-0
lines changed

3 files changed

+133
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ lib*.a
1515
*.iml
1616
### macOS ###
1717
.DS_Store
18+
19+
### direnv ###
20+
/.direnv/

flake.lock

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "github:nixos/nixpkgs";
4+
flake-utils.url = "github:numtide/flake-utils";
5+
};
6+
7+
outputs = {
8+
self,
9+
nixpkgs,
10+
flake-utils,
11+
}:
12+
flake-utils.lib.eachDefaultSystem (system: let
13+
pkgs = nixpkgs.legacyPackages.${system};
14+
libselinuxPath = with pkgs;
15+
lib.makeLibraryPath [
16+
libselinux
17+
];
18+
libaclPath = with pkgs;
19+
lib.makeLibraryPath [
20+
acl
21+
];
22+
23+
build_deps = with pkgs; [
24+
clang
25+
llvmPackages.bintools
26+
rustup
27+
28+
pre-commit
29+
30+
# debugging
31+
gdb
32+
];
33+
gnu_testing_deps = with pkgs; [
34+
autoconf
35+
automake
36+
bison
37+
gnum4
38+
gperf
39+
gettext
40+
texinfo
41+
];
42+
in {
43+
devShell = pkgs.mkShell {
44+
buildInputs = build_deps ++ gnu_testing_deps;
45+
46+
RUSTC_VERSION = "1.75";
47+
LIBCLANG_PATH = pkgs.lib.makeLibraryPath [pkgs.llvmPackages_latest.libclang.lib];
48+
shellHook = ''
49+
export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin
50+
export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/
51+
'';
52+
53+
SELINUX_INCLUDE_DIR = ''${pkgs.libselinux.dev}/include'';
54+
SELINUX_LIB_DIR = libselinuxPath;
55+
SELINUX_STATIC = "0";
56+
57+
# Necessary to build GNU.
58+
LDFLAGS = ''-L ${libselinuxPath} -L ${libaclPath}'';
59+
60+
# Add precompiled library to rustc search path
61+
RUSTFLAGS =
62+
(builtins.map (a: ''-L ${a}/lib'') [
63+
])
64+
++ [
65+
''-L ${libselinuxPath}''
66+
''-L ${libaclPath}''
67+
];
68+
};
69+
});
70+
}

0 commit comments

Comments
 (0)