Skip to content

Commit

Permalink
add a flake.nix file for the development environment, add direnv-rela…
Browse files Browse the repository at this point in the history
…ted files to .gitignore
  • Loading branch information
RenjiSann committed Jan 2, 2025
1 parent eb6086d commit d7a681e
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ lib*.a
*.iml
### macOS ###
.DS_Store

### direnv ###
/.direnv/
60 changes: 60 additions & 0 deletions flake.lock

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

70 changes: 70 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = {
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
libselinuxPath = with pkgs;
lib.makeLibraryPath [
libselinux
];
libaclPath = with pkgs;
lib.makeLibraryPath [
acl
];

build_deps = with pkgs; [
clang
llvmPackages.bintools
rustup

pre-commit

# debugging
gdb
];
gnu_testing_deps = with pkgs; [
autoconf
automake
bison
gnum4
gperf
gettext
texinfo
];
in {
devShell = pkgs.mkShell {
buildInputs = build_deps ++ gnu_testing_deps;

RUSTC_VERSION = "1.75";
LIBCLANG_PATH = pkgs.lib.makeLibraryPath [pkgs.llvmPackages_latest.libclang.lib];
shellHook = ''
export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin
export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/
'';

SELINUX_INCLUDE_DIR = ''${pkgs.libselinux.dev}/include'';
SELINUX_LIB_DIR = libselinuxPath;
SELINUX_STATIC = "0";

# Necessary to build GNU.
LDFLAGS = ''-L ${libselinuxPath} -L ${libaclPath}'';

# Add precompiled library to rustc search path
RUSTFLAGS =
(builtins.map (a: ''-L ${a}/lib'') [
])
++ [
''-L ${libselinuxPath}''
''-L ${libaclPath}''
];
};
});
}

0 comments on commit d7a681e

Please sign in to comment.