-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshell.nix
More file actions
156 lines (140 loc) · 5.33 KB
/
Copy pathshell.nix
File metadata and controls
156 lines (140 loc) · 5.33 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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# SPDX-FileCopyrightText: 2025 Povl Filip Sonne-Frederiksen
#
# SPDX-License-Identifier: GPL-3.0-or-later
{
pkgs,
self,
system,
...
}: let
motd = ''
echo ""
echo " ┌─────────────────────────────────────────────┐"
echo " │ ReUseX development shell │"
echo " └─────────────────────────────────────────────┘"
echo " configure [Release|Debug] cmake + compile_commands.json"
echo " build cmake --build --parallel"
echo " run-tests build, then ctest"
echo " clean remove build/"
echo " format clang-format all C++ sources"
echo " lint cppcheck static analysis"
echo " docs build Doxygen docs"
echo " menu show this menu"
echo ""
'';
# Convenience scripts available in any shell (bash, fish, zsh).
scripts = pkgs.lib.attrValues {
menu = pkgs.writeShellScriptBin "menu" motd;
configure = pkgs.writeShellScriptBin "configure" ''
cmake -B "$PWD/build" -GNinja \
-DCMAKE_BUILD_TYPE=''${1:-Release} \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
"''${@:2}"
ln -sf "$PWD/build/compile_commands.json" "$PWD/compile_commands.json"
'';
build = pkgs.writeShellScriptBin "build" ''
cmake --build "$PWD/build" --parallel "$@"
'';
run-tests = pkgs.writeShellScriptBin "run-tests" ''
cmake --build "$PWD/build" --parallel \
&& ctest --test-dir "$PWD/build" --output-on-failure --parallel "$@"
'';
clean = pkgs.writeShellScriptBin "clean" ''
rm -rf "$PWD/build" && echo "Build directory removed."
'';
format = pkgs.writeShellScriptBin "format" ''
find "$PWD/libs" "$PWD/apps" \( -name '*.cpp' -o -name '*.hpp' \) \
| xargs clang-format -i && echo "Done."
'';
lint = pkgs.writeShellScriptBin "lint" ''
cppcheck --enable=all --suppress=missingIncludeSystem \
--suppress=unmatchedSuppression --inline-suppr \
--check-level=exhaustive \
-I "$PWD/libs/reusex/include" \
-I "$PWD/build/include" \
-I "$PWD/build/generated" \
-I "$PWD/apps/rux/include" \
"$PWD/libs/" "$PWD/apps/"
'';
docs = pkgs.writeShellScriptBin "docs" ''
cmake --build "$PWD/build" --target doc "$@"
'';
};
in
pkgs.mkShell {
inputsFrom = [self.packages.${system}.default];
buildInputs = self.checks.${system}.pre-commit-check.enabledPackages;
packages =
scripts
++ (with pkgs; [
# Python 3.11 (matches Blender) - must come first to take precedence
blender.pythonPackages.python
# Documentation tools
help2man # For generating man pages from --help output
pandoc
sphinx
graphviz # For Doxygen diagrams and visualization
# Debugging and analysis tools
gdb
valgrind
kdePackages.kcachegrind
heaptrack # Memory profiler with GUI
# Build tools
cmake-format # Format CMakeLists.txt files
ccache # Cache C++ compilation to speed up rebuilds
ninja # Faster build system alternative to Make
bear # Generate compile_commands.json for LSP/clangd
# C++ development tools
clang-tools # Includes clang-format, clang-tidy, clang-rename
cppcheck # Static analysis for C++
include-what-you-use # Check #include dependencies
# Performance profiling
linuxPackages.perf # Performance profiling
hotspot # GUI for perf data visualization
# Development tools
libnotify # Send notification when build finishes
sqlite
ffmpeg
openusd
jq # JSON processor for scripts
ripgrep # Fast code search (faster than grep)
fd # Fast file finder (faster than find)
hyperfine # Command-line benchmarking
# Version control tools
tig # Text-mode interface for git
git-filter-repo # Advanced git history rewriting
gitui # Terminal UI for git (alternative)
#qt6.full
#qtcreator
# DevOps tools
nix-update
sqlitebrowser
hugin
github-copilot-cli
claude-code
gh
doxygen
tree
git-lfs
# Code coverage
lcov
gcovr # Alternative coverage report generator
# Python development
python3Packages.black # Python code formatter
python3Packages.pytest # Testing framework
python3Packages.mypy # Type checking
]);
shellHook =
''
export VIRTUAL_ENV_PROMPT="ReUseX"
# NixOS keeps the real libcuda.so outside Nix, at /run/opengl-driver/lib.
# Binaries built in this shell (./build/apps/rux/rux, ctest binaries) are
# not wrapped with addDriverRunpath, so without this they load the stub
# libcuda.so from cuda_cudart and crash with cudaErrorStubLibrary.
if [ -d /run/opengl-driver/lib ]; then
export LD_LIBRARY_PATH="/run/opengl-driver/lib''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
fi
${motd}
''
+ self.checks.${system}.pre-commit-check.shellHook;
}