-
-
Notifications
You must be signed in to change notification settings - Fork 181
/
flake.nix
79 lines (77 loc) · 2.77 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
{
inputs = {
nixpkgs.url = "nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, flake-utils, ... }@inputs:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = inputs.nixpkgs.legacyPackages."${system}";
in
{
packages.default = pkgs.stdenv.mkDerivation rec {
name = "lldpd";
# We should be able to just use ./., but we have libevent as a submodule.
# Currently, we should use:
# nix build ".?submodules=1"
# See:
# - https://github.com/NixOS/nix/pull/5434
# - https://github.com/NixOS/nix/pull/5497
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
configureFlags = [
"--localstatedir=/var"
"--enable-pie"
"--with-snmp"
"--with-systemdsystemunitdir=\${out}/lib/systemd/system"
];
nativeBuildInputs = with pkgs; [ pkg-config autoreconfHook git check ];
buildInputs = with pkgs; [ libevent readline net-snmp openssl ];
outputs = [ "out" "dev" "man" "doc" ];
};
apps = {
# Use:
# nix run ".?submodules=1#lldpcli" -- --help
lldpd = {
type = "app";
program = "${self.packages."${system}".default}/bin/lldpd";
};
lldpcli = {
type = "app";
program = "${self.packages."${system}".default}/bin/lldpcli";
};
};
devShells.default =
let
llvm = pkgs.llvmPackages_14;
clang-tools = pkgs.clang-tools.override { llvmPackages = llvm; };
in
pkgs.mkShell {
name = "lldpd-dev";
buildInputs =
self.packages."${system}".default.nativeBuildInputs ++
self.packages."${system}".default.buildInputs ++ [
clang-tools # clang-format (C)
llvm.libclang.python # git-clang-format (C)
pkgs.python3Packages.black # black (Python)
# CI helper
(pkgs.writeShellScriptBin "ci-helper" ''
set -eu
while [ $# -gt 0 ]; do
case $1 in
format-c)
echo "Run clang-format on C code..."
${pkgs.git}/bin/git ls-files '*.c' '*.h' \
| xargs ${clang-tools}/bin/clang-format -i
;;
format-python)
echo "Run black on Python code..."
${pkgs.python3Packages.black}/bin/black tests/integration
;;
esac
shift
done
'')
];
};
});
}