Skip to content

Commit 112cb4c

Browse files
authored
Merge pull request #6947 from RenjiSann/nixos-devel
Nix/Nixos development
2 parents 9542e15 + 8fd4e1c commit 112cb4c

File tree

5 files changed

+143
-0
lines changed

5 files changed

+143
-0
lines changed

.envrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
if ! has nix_direnv_version || ! nix_direnv_version 3.0.6; then
2+
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.6/direnvrc" "sha256-RYcUJaRMf8oF5LznDrlCXbkOQrywm0HDv1VjYGaJGdM="
3+
fi
4+
5+
use flake

.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+
}

util/build-gnu.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,3 +345,8 @@ sed -i "s/color_code='0;31;42'/color_code='31;42'/" tests/ls/quote-align.sh
345345

346346
# Slightly different error message
347347
sed -i 's/not supported/unexpected argument/' tests/mv/mv-exchange.sh
348+
# Most tests check that `/usr/bin/tr` is working correctly before running.
349+
# However in NixOS/Nix-based distros, the tr coreutil is located somewhere in
350+
# /nix/store/xxxxxxxxxxxx...xxxx/bin/tr
351+
# We just replace the references to `/usr/bin/tr` with the result of `$(which tr)`
352+
sed -i 's/\/usr\/bin\/tr/$(which tr)/' tests/init.sh

0 commit comments

Comments
 (0)