-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
99 lines (86 loc) · 2.64 KB
/
flake.nix
File metadata and controls
99 lines (86 loc) · 2.64 KB
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
{
description = "C++ wlroots development environment";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {inherit system;};
# List of dependencies for a typical wlroots compositor
wlroots-dependencies = with pkgs; [
# Core Wayland and rendering libraries
wlroots
wayland
wayland-protocols
wayland-scanner
mesa # Provides libGL
libdrm
cairo
pango
pixman
clang
# Input and keyboard handling
libinput
libxkbcommon
# Xwayland support for running X11 applications
xwayland
xorg.libxcb
xorg.xcbutilwm
bear
libei
];
# List of build tools
build-tools = with pkgs; [
gnumake
gdb # The GNU Debugger
pkg-config
socat
];
in {
# `nix build`
packages.default = pkgs.stdenv.mkDerivation {
name = "testcomp";
src = pkgs.lib.cleanSource ./.;
# Tools needed at build time
nativeBuildInputs = build-tools ++ [pkgs.wayland-scanner]; # Add wayland-scanner here
# Libraries to link against
buildInputs = wlroots-dependencies;
# Custom build phase to generate the protocol header
buildPhase = ''
# Generate the C header for the xdg-shell protocol
mkdir -p protocol_headers
${pkgs.wayland-scanner}/bin/wayland-scanner client-header \
${pkgs.wayland-protocols}/share/wayland-protocols/unstable/xdg-shell/xdg-shell.xml \
protocol_headers/xdg-shell-protocol.h
# Now run the make command
make CFLAGS="-I$(pwd)/protocol_headers"
'';
};
# `nix develop`
devShells.default = pkgs.mkShell {
name = "cpp-wlroots-dev-shell";
# All build tools and dependencies are available in the shell
packages =
build-tools
++ wlroots-dependencies
++ [
# Add extra development tools here
pkgs.valgrind # For memory debugging
];
shellHook = ''
echo "Entered C++ wlroots development shell."
echo "Compiler and dependencies are now in your PATH."
'';
};
# `nix fmt`
formatter = pkgs.nixfmt-rfc-style;
}
);
}