-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
134 lines (128 loc) · 3.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
{
description = "eBPF playground";
inputs = {
emacs-overlay = {
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
nixpkgs-stable.follows = "nixpkgs-stable";
};
url = "github:nix-community/emacs-overlay";
};
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
nixpkgs-stable.url = "github:nixos/nixpkgs/release-23.05";
pre-commit-hooks = {
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
nixpkgs-stable.follows = "nixpkgs-stable";
};
url = "github:cachix/pre-commit-hooks.nix";
};
treefmt-nix = {
inputs.nixpkgs.follows = "nixpkgs";
url = "github:numtide/treefmt-nix";
};
};
outputs = { self, emacs-overlay, flake-utils, nixpkgs, pre-commit-hooks, treefmt-nix, ... }:
{
overlays.default = _final: prev: {
inherit (self.packages.${prev.system}) bpf2go;
};
} // flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
pkgs = import nixpkgs {
overlays = [
emacs-overlay.overlay
self.overlays.default
];
inherit system;
};
in
{
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
revive.enable = true;
treefmt.enable = true;
};
settings = {
treefmt.package = self.formatter.${system};
};
};
};
devShells = {
default = with pkgs; mkShell {
FONTCONFIG_FILE = makeFontsConf {
fontDirectories = [
(nerdfonts.override { fonts = [ "Iosevka" ]; })
];
};
buildInputs = [
bpf2go
bpftools
(
emacsWithPackagesFromUsePackage {
alwaysEnsure = true;
config = ./emacs.el;
}
)
glibc_multi
go
gopls
gotools
libbpf_1
revive
rnix-lsp
];
inherit (self.checks.${system}.pre-commit-check) shellHook;
};
};
formatter = treefmt-nix.lib.mkWrapper pkgs {
projectRootFile = "flake.nix";
programs = {
clang-format.enable = true;
deadnix.enable = true;
gofmt.enable = true;
nixpkgs-fmt.enable = true;
};
};
packages = {
bpf2go = with pkgs; buildGoModule rec {
pname = "bpf2go";
version = "0.10.0";
src = fetchFromGitHub {
owner = "cilium";
repo = "ebpf";
rev = "v${version}";
hash = "sha256-3ndNjOvVnkpmqg0twWzdAnC+v6AWhr8XDQND4cn13us=";
};
vendorHash = "sha256-Nlc8cmTd8W1L/U1tVfG6icBgC2K6r3xaX/zI1dWXI2k=";
subPackages = [ "cmd/bpf2go" ];
# FIXME: hardcoded binaries in tests, e.g. clang-14, llvm-strip-14
doCheck = false;
};
hello-world = with pkgs; buildGoModule rec {
pname = "hello-world";
version = "0.0.1";
src = ./hello-world;
nativeBuildInputs = [
bpf2go
buildPackages.clang_14
buildPackages.llvm_14
glibc_multi
];
buildInputs = [
libbpf_1
];
vendorHash = "sha256-iw3HIkGXFQu/TgyLhJb9J80QU3+Pl1DxvusZxsNMPlI=";
postConfigure = ''
go generate ./...
'';
};
};
}
);
}