-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.nix
41 lines (37 loc) · 1.15 KB
/
shell.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
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let
pre-commit = writeShellScriptBin "pre-commit" ''
# get the staged files
s_files=$(${git}/bin/git diff --name-only --cached)
# if a staged file contains the keyword, get it out of the staged list
for s_file in ''${s_files};do
if grep -q -E '@nocheckin' ''${s_file};then
echo "WARNING: ''${s_file} contains the keyword"
${git}/bin/git reset ''${s_file}
fi
done
# if there is not any staged file left, fail the commit, otherwise
# an empty commit would be created.
s_files=$(${git}/bin/git diff --name-only --cached)
if [[ "''${s_files}" = "" ]];then
echo "WARNING: nothing to commit"
exit 1
fi
exit 0
'';
monitor = writeShellScriptBin "monitor" ''
feh --auto-reload 1 out.png &
inotifywait -e close_write,moved_to,create -m . |
while read -r directory events filename; do
if [ "$filename" = "monitor.dot" ]; then
dot -Tpng ./monitor.dot > ./monitor.png
fi
done
'';
in
stdenv.mkDerivation {
name = "copernican";
src = null;
buildInputs = [ rustup gdb pkgconfig pre-commit gitui];
}