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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
{ lib
, stdenv
, fetchFromGitHub
, autoreconfHook
, bashInteractive
, cacert
, coreutils
, dbus
, docbook_xml_dtd_43
, docbook_xsl
, findutils
, gettext
, git
, glib
, glib-networking
, gnused
, gnutls
, json-glib
, krb5
, libssh
, libxcrypt
, libxslt
, makeWrapper
, nodejs
, nixosTests
, nix-update-script
, openssh
, openssl
, pam
, pkg-config
, polkit
, python3Packages
, runtimeShell
, systemd
, udev
, xmlto
}:
let
pythonWithGobject = python3Packages.python.withPackages (p: with p; [
pygobject3
]);
in
stdenv.mkDerivation rec {
pname = "cockpit";
version = "316";
src = fetchFromGitHub {
owner = "cockpit-project";
repo = "cockpit";
rev = "refs/tags/${version}";
hash = "sha256-AoRdeAA+K6VhRxgAF7t2COJtovk8U9B9j8MaBwMjJgw=";
fetchSubmodules = true;
};
nativeBuildInputs = [
autoreconfHook
makeWrapper
docbook_xml_dtd_43
docbook_xsl
findutils
gettext
git
(lib.getBin libxslt)
nodejs
openssl
pam
pkg-config
pythonWithGobject.python
python3Packages.setuptools
systemd
xmlto
];
buildInputs = [
(lib.getDev glib)
libxcrypt
gnutls
json-glib
krb5
libssh
polkit
udev
];
postPatch = ''
# Instead of requiring Internet access to do an npm install to generate the package-lock.json
# it copies the package-lock.json already present in the node_modules folder fetched as a git
# submodule.
echo "#!/bin/sh" > test/node_modules
substituteInPlace src/tls/cockpit-certificate-helper.in \
--replace 'COCKPIT_CONFIG="@sysconfdir@/cockpit"' 'COCKPIT_CONFIG=/etc/cockpit'
substituteInPlace src/tls/cockpit-certificate-ensure.c \
--replace '#define COCKPIT_SELFSIGNED_PATH PACKAGE_SYSCONF_DIR COCKPIT_SELFSIGNED_FILENAME' '#define COCKPIT_SELFSIGNED_PATH "/etc" COCKPIT_SELFSIGNED_FILENAME'
substituteInPlace src/common/cockpitconf.c \
--replace 'const char *cockpit_config_dirs[] = { PACKAGE_SYSCONF_DIR' 'const char *cockpit_config_dirs[] = { "/etc"'
# instruct users with problems to create a nixpkgs issue instead of nagging upstream directly
substituteInPlace configure.ac \
--replace 'devel@lists.cockpit-project.org' 'https://github.com/NixOS/nixpkgs/issues/new?assignees=&labels=0.kind%3A+bug&template=bug_report.md&title=cockpit%25'
patchShebangs \
build.js \
test/common/pixel-tests \
test/common/run-tests \
test/common/tap-cdp \
test/static-code \
tools/escape-to-c \
tools/make-compile-commands \
tools/node-modules \
tools/termschutz \
tools/webpack-make.js
for f in node_modules/.bin/*; do
patchShebangs $(realpath $f)
done
export HOME=$(mktemp -d)
cp node_modules/.package-lock.json package-lock.json
for f in pkg/**/*.js pkg/**/*.jsx test/**/* src/**/*; do
# some files substituteInPlace report as missing and it's safe to ignore them
substituteInPlace "$(realpath "$f")" \
--replace '"/usr/bin/' '"' \
--replace '"/bin/' '"' || true
done
substituteInPlace src/common/Makefile-common.am \
--replace 'TEST_PROGRAM += test-pipe' "" # skip test-pipe because it hangs the build
substituteInPlace test/pytest/*.py \
--replace "'bash" "'${bashInteractive}/bin/bash"
echo "m4_define(VERSION_NUMBER, [${version}])" > version.m4
'';
configureFlags = [
"--enable-prefix-only=yes"
"--disable-pcp" # TODO: figure out how to package its dependency
"--with-default-session-path=/run/wrappers/bin:/run/current-system/sw/bin"
"--with-admin-group=root" # TODO: really? Maybe "wheel"?
"--enable-old-bridge=yes"
];
enableParallelBuilding = true;
preBuild = ''
patchShebangs \
tools/test-driver
'';
postBuild = ''
chmod +x \
src/systemd/update-motd \
src/tls/cockpit-certificate-helper \
src/ws/cockpit-desktop
patchShebangs \
src/systemd/update-motd \
src/tls/cockpit-certificate-helper \
src/ws/cockpit-desktop
PATH=${pythonWithGobject}/bin patchShebangs src/client/cockpit-client
substituteInPlace src/ws/cockpit-desktop \
--replace ' /bin/bash' ' ${runtimeShell}'
'';
fixupPhase = ''
runHook preFixup
wrapProgram $out/libexec/cockpit-certificate-helper \
--prefix PATH : ${lib.makeBinPath [ coreutils openssl ]} \
--run 'cd $(mktemp -d)'
wrapProgram $out/share/cockpit/motd/update-motd \
--prefix PATH : ${lib.makeBinPath [ gnused ]}
substituteInPlace $out/share/polkit-1/actions/org.cockpit-project.cockpit-bridge.policy \
--replace /usr $out
runHook postFixup
'';
doCheck = true;
checkInputs = [
bashInteractive
cacert
dbus
glib-networking
openssh
python3Packages.pytest
];
checkPhase = ''
export GIO_EXTRA_MODULES=$GIO_EXTRA_MODULES:${glib-networking}/lib/gio/modules
export G_DEBUG=fatal-criticals
export G_MESSAGES_DEBUG=cockpit-ws,cockpit-wrapper,cockpit-bridge
export PATH=$PATH:$(pwd)
cockpit-bridge --version
make pytest -j$NIX_BUILD_CORES || true
make check -j$NIX_BUILD_CORES || true
test/static-code
npm run eslint
npm run stylelint || true
'';
passthru = {
tests = { inherit (nixosTests) cockpit; };
updateScript = nix-update-script {};
};
meta = with lib; {
description = "Web-based graphical interface for servers";
mainProgram = "cockpit-bridge";
homepage = "https://cockpit-project.org/";
license = licenses.lgpl21;
maintainers = with maintainers; [ lucasew ];
};
}
|