This repository was archived by the owner on Feb 7, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathdefault.nix
More file actions
131 lines (110 loc) · 2.87 KB
/
default.nix
File metadata and controls
131 lines (110 loc) · 2.87 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
{ pkgs ? import (builtins.fetchTarball "https://github.com/NixOS/nixpkgs-channels/tarball/nixos-unstable") {},
}:
let
inherit (pkgs) writeTextFile;
inherit (pkgs.stdenv) mkDerivation;
inherit (pkgs.rustPlatform) buildRustPackage;
shellcheckCmd = ''
echo "=========================================================="
echo "----> Shellchecking:"
for file in `find . -name '*.sh'`; do
echo "----> $file"
${pkgs.shellcheck}/bin/shellcheck -e SC1090 -e SC1091 -x $file
done
'';
in rec {
ci = writeTextFile {
name = "tests";
text = ''
${lwnvulns.pkg}
${notate.pkgSrc}
${ported-notes.pkgSrc}
'';
};
notate = rec {
pkgSrc = mkDerivation {
name = "notate-src";
src = ./notate.sh;
unpackPhase = ''
cp $src .
'';
buildPhase = shellcheckCmd;
installPhase = ''
mkdir $out
cp -r $src $out/notate.sh
'';
};
};
ported-notes = rec {
pkgSrc = mkDerivation {
name = "ported-notes-src";
src = ./ported-notes.sh;
unpackPhase = ''
cp $src .
'';
buildPhase = shellcheckCmd;
installPhase = ''
mkdir $out
cp -r $src $out/ported-note.sh
'';
};
};
lwnvulns = rec {
dependencies = with pkgs; [
perl
pkgconfig
openssl.dev
zlib.dev
curl.dev
];
formatcheckCmd = ''
echo "=========================================================="
echo "----> Formatting:"
for file in `find . -name '*.rs' -not -path '*/target/*'`; do # */ Hi emacs ...
echo "----> $file"
${pkgs.rustfmt}/bin/rustfmt --write-mode=diff "$file"
done
'';
shell = mkDerivation {
name = "nixos-security-tools-shell";
src = ./.;
formatcheck = formatcheckCmd;
buildInputs = dependencies ++ (with pkgs; [
rustfmt
rustc
cargo
]);
shellHook = ''
cd lwnvulns;
'';
};
pkg = buildRustPackage {
name = "lwn-vuln";
src = pkgSrc;
depsSha256 = "19l6p7g8xy5hvy562saxaia1jxcbyrq657nnk7i055lla9i199p2";
preBuild = formatcheckCmd;
buildInputs = dependencies;
};
pkgSrc = mkDerivation {
name = "nixos-security-tools-src";
src = builtins.filterSource (
path: type:
let
bpath = baseNameOf path;
in !(
((builtins.substring 0 1 bpath) == ".")
|| (type == "symlink" && bpath == "result")
|| (type == "directory" && bpath == ".git")
|| (type == "directory" && bpath == "target")
|| (type == "file" && bpath == "db")
|| (type == "file" && bpath == "shell.nix")
|| (type == "file" && bpath == "default.nix")
)
) ./lwnvulns;
buildPhase = formatcheckCmd;
installPhase = ''
cp -r $src $out
'';
};
};
}