Skip to content

Commit 8fa5a28

Browse files
cockpit-{files,machines,podman}: init packages (#447043)
2 parents 1dea22c + 549f5e6 commit 8fa5a28

File tree

6 files changed

+255
-24
lines changed

6 files changed

+255
-24
lines changed

maintainers/team-list.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,16 @@ with lib.maintainers;
141141
enableFeatureFreezePing = true;
142142
};
143143

144+
cockpit = {
145+
members = [
146+
alexandru0-dev
147+
andre4ik3
148+
lucasew
149+
];
150+
scope = "Maintain Cockpit and official plugins by the Cockpit project.";
151+
shortName = "Cockpit";
152+
};
153+
144154
coq = {
145155
members = [
146156
cohencyril

nixos/modules/services/monitoring/cockpit.nix

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,33 @@ let
1515
mkPackageOption
1616
;
1717
settingsFormat = pkgs.formats.ini { };
18+
19+
pathPkgs = [ cfg.package ] ++ cfg.plugins;
20+
21+
resourcesEnv = pkgs.buildEnv {
22+
name = "cockpit-plugins";
23+
paths = pathPkgs;
24+
pathsToLink = [ "/share/cockpit" ];
25+
};
26+
27+
depsEnv = pkgs.buildEnv {
28+
name = "cockpit-plugins-env";
29+
paths = lib.concatMap (p: p.passthru.cockpitPath or [ ]) pathPkgs;
30+
pathsToLink = [
31+
"/bin"
32+
"/share"
33+
"/lib"
34+
];
35+
};
36+
37+
share = pkgs.buildEnv {
38+
name = "cockpit-share";
39+
paths = [
40+
resourcesEnv
41+
depsEnv
42+
];
43+
pathsToLink = [ "/share" ];
44+
};
1845
in
1946
{
2047
options = {
@@ -100,22 +127,11 @@ in
100127
};
101128

102129
# Add plugins in discoverable folder
103-
"cockpit/share/cockpit".source = "${
104-
pkgs.buildEnv {
105-
name = "cockpit-plugins";
106-
paths = cfg.plugins ++ [ cfg.package ];
107-
pathsToLink = [ "/share/cockpit" ];
108-
}
109-
}/share/cockpit";
130+
"cockpit/share".source = "${share}/share";
110131

111132
# Add plugins dependencies
112-
"cockpit/bin".source = "${
113-
pkgs.buildEnv {
114-
name = "cockpit-path";
115-
paths = lib.concatMap (p: p.passthru.cockpitPath or [ ]) cfg.plugins;
116-
pathsToLink = [ "/bin" ];
117-
}
118-
}/bin";
133+
"cockpit/bin".source = "${depsEnv}/bin";
134+
"cockpit/lib".source = "${depsEnv}/lib";
119135
};
120136

121137
security.pam.services.cockpit = {
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
lib,
3+
stdenv,
4+
cockpit,
5+
nodejs,
6+
gettext,
7+
writeShellScriptBin,
8+
fetchFromGitHub,
9+
gitUpdater,
10+
}:
11+
12+
stdenv.mkDerivation (finalAttrs: {
13+
pname = "cockpit-files";
14+
version = "34";
15+
16+
src = fetchFromGitHub {
17+
owner = "cockpit-project";
18+
repo = "cockpit-files";
19+
tag = finalAttrs.version;
20+
hash = "sha256-nxlPzNrX3mAwhR8mpRfoZ7d6tdfVOBEaTtzEHU14p68=";
21+
22+
fetchSubmodules = true;
23+
postFetch = "cp $out/node_modules/.package-lock.json $out/package-lock.json";
24+
};
25+
26+
buildInputs = [
27+
nodejs
28+
gettext
29+
(writeShellScriptBin "git" "true")
30+
];
31+
32+
cockpitSrc = cockpit.src;
33+
34+
postPatch = ''
35+
mkdir -p pkg; cp -r $cockpitSrc/pkg/lib pkg
36+
mkdir -p test; cp -r $cockpitSrc/test/common test
37+
38+
substituteInPlace Makefile \
39+
--replace-fail '$(MAKE) package-lock.json' 'true' \
40+
--replace-fail '$(COCKPIT_REPO_FILES) | tar x' "" \
41+
--replace-fail '/usr/local' "$out"
42+
43+
patchShebangs build.js
44+
'';
45+
46+
passthru.updateScript = gitUpdater { };
47+
48+
meta = {
49+
description = "Featureful file browser for Cockpit";
50+
homepage = "https://github.com/cockpit-project/cockpit-files";
51+
changelog = "https://github.com/cockpit-project/cockpit-files/releases/tag/${finalAttrs.version}";
52+
platforms = lib.platforms.linux;
53+
license = [ lib.licenses.lgpl21 ];
54+
teams = [ lib.teams.cockpit ];
55+
};
56+
})
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
lib,
3+
stdenv,
4+
cockpit,
5+
nodejs,
6+
gettext,
7+
writeShellScriptBin,
8+
fetchFromGitHub,
9+
gitUpdater,
10+
libosinfo,
11+
osinfo-db,
12+
}:
13+
14+
stdenv.mkDerivation (finalAttrs: {
15+
pname = "cockpit-machines";
16+
version = "346";
17+
18+
src = fetchFromGitHub {
19+
owner = "cockpit-project";
20+
repo = "cockpit-machines";
21+
tag = finalAttrs.version;
22+
hash = "sha256-fsEmxJ/9w4NbjgKhb4JTFY94FFTc735+ZQ8YieLQVpA=";
23+
24+
fetchSubmodules = true;
25+
postFetch = "cp $out/node_modules/.package-lock.json $out/package-lock.json";
26+
};
27+
28+
buildInputs = [
29+
nodejs
30+
gettext
31+
(writeShellScriptBin "git" "true")
32+
];
33+
34+
cockpitSrc = cockpit.src;
35+
36+
postPatch = ''
37+
mkdir -p pkg; cp -r $cockpitSrc/pkg/lib pkg
38+
mkdir -p test; cp -r $cockpitSrc/test/common test
39+
40+
substituteInPlace Makefile \
41+
--replace-fail '$(MAKE) package-lock.json' 'true' \
42+
--replace-fail '$(COCKPIT_REPO_FILES) | tar x' "" \
43+
--replace-fail '/usr/local' "$out"
44+
45+
substituteInPlace src/manifest.json \
46+
--replace-fail '"/usr/share/dbus-1/system.d/org.libvirt.conf"' '"/etc/systemd/system/libvirt-dbus.service"'
47+
48+
patchShebangs build.js
49+
'';
50+
51+
passthru = {
52+
updateScript = gitUpdater { };
53+
cockpitPath = [
54+
libosinfo
55+
osinfo-db
56+
];
57+
};
58+
59+
meta = {
60+
description = "Cockpit UI for virtual machines";
61+
homepage = "https://github.com/cockpit-project/cockpit-machines";
62+
changelog = "https://github.com/cockpit-project/cockpit-machines/releases/tag/${finalAttrs.version}";
63+
platforms = lib.platforms.linux;
64+
license = [ lib.licenses.lgpl21 ];
65+
teams = [ lib.teams.cockpit ];
66+
};
67+
})
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
lib,
3+
stdenv,
4+
cockpit,
5+
nodejs,
6+
gettext,
7+
writeShellScriptBin,
8+
fetchFromGitHub,
9+
gitUpdater,
10+
podman,
11+
}:
12+
13+
stdenv.mkDerivation (finalAttrs: {
14+
pname = "cockpit-podman";
15+
version = "119.1";
16+
17+
src = fetchFromGitHub {
18+
owner = "cockpit-project";
19+
repo = "cockpit-podman";
20+
tag = finalAttrs.version;
21+
hash = "sha256-XAOHkul9oh1mUJ27ghJgZLtriBGjofyoGhQ3gb7Gunc=";
22+
23+
fetchSubmodules = true;
24+
postFetch = "cp $out/node_modules/.package-lock.json $out/package-lock.json";
25+
};
26+
27+
buildInputs = [
28+
nodejs
29+
gettext
30+
(writeShellScriptBin "git" "true")
31+
];
32+
33+
cockpitSrc = cockpit.src;
34+
35+
postPatch = ''
36+
mkdir -p pkg; cp -r $cockpitSrc/pkg/lib pkg
37+
mkdir -p test; cp -r $cockpitSrc/test/common test
38+
39+
substituteInPlace Makefile \
40+
--replace-fail '$(MAKE) package-lock.json' 'true' \
41+
--replace-fail '$(COCKPIT_REPO_FILES) | tar x' "" \
42+
--replace-fail '/usr/local' "$out"
43+
44+
substituteInPlace src/manifest.json \
45+
--replace-fail '"/lib/systemd' '"/run/current-system/sw/lib/systemd'
46+
47+
patchShebangs build.js
48+
'';
49+
50+
passthru = {
51+
updateScript = gitUpdater { };
52+
cockpitPath = [ podman ];
53+
};
54+
55+
meta = {
56+
description = "Cockpit UI for podman containers";
57+
homepage = "https://github.com/cockpit-project/cockpit-podman";
58+
changelog = "https://github.com/cockpit-project/cockpit-podman/releases/tag/${finalAttrs.version}";
59+
platforms = lib.platforms.linux;
60+
license = [ lib.licenses.lgpl21 ];
61+
teams = [ lib.teams.cockpit ];
62+
};
63+
})

pkgs/by-name/co/cockpit/package.nix

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
git,
1515
glib,
1616
glib-networking,
17+
gobject-introspection,
1718
gnused,
1819
gnutls,
1920
hostname,
@@ -160,15 +161,23 @@ stdenv.mkDerivation (finalAttrs: {
160161
--replace-warn '"/usr/share' '"/run/current-system/sw/share' \
161162
--replace-warn '"/lib/systemd' '"/run/current-system/sw/lib/systemd'
162163
163-
# replace reference to system python interpreter, used for e.g. sosreport
164-
substituteInPlace pkg/lib/python.ts \
165-
--replace-fail /usr/libexec/platform-python ${python3Packages.python.interpreter}
164+
# fix polkit agent helper path
165+
substituteInPlace src/cockpit/polkit.py \
166+
--replace-fail "/usr/lib/polkit-1/polkit-agent-helper-1" "/run/wrappers/bin/polkit-agent-helper-1"
166167
'';
167168

168169
configureFlags = [
169170
"--enable-prefix-only=yes"
170171
"--disable-pcp" # TODO: figure out how to package its dependency
171-
"--with-default-session-path=${placeholder "out"}/bin:/etc/cockpit/bin:${util-linux}/bin:/run/wrappers/bin:/run/current-system/sw/bin"
172+
"--with-default-session-path=${
173+
lib.makeBinPath [
174+
(placeholder "out")
175+
"/etc/cockpit"
176+
util-linux
177+
"/run/wrappers"
178+
"/run/current-system/sw"
179+
]
180+
}"
172181
"--with-admin-group=root" # TODO: really? Maybe "wheel"?
173182
];
174183

@@ -192,8 +201,15 @@ stdenv.mkDerivation (finalAttrs: {
192201
for binary in $out/bin/cockpit-bridge $out/libexec/cockpit-askpass; do
193202
chmod +x $binary
194203
wrapProgram $binary \
195-
--prefix PYTHONPATH : $out/${python3Packages.python.sitePackages} \
196-
--prefix XDG_DATA_DIRS : /etc/cockpit/share # Cockpit apps will be stored at /etc/cockpit/share/cockpit/ (managed by Cockpit nixos service)
204+
--prefix PATH : "/etc/cockpit/bin" \
205+
--prefix PYTHONPATH : ${
206+
lib.makeSearchPath python3Packages.python.sitePackages [
207+
"$out"
208+
"/etc/cockpit"
209+
]
210+
} \
211+
--prefix GI_TYPELIB_PATH : "/etc/cockpit/lib/girepository-1.0" \
212+
--prefix XDG_DATA_DIRS : "/etc/cockpit/share"
197213
done
198214
199215
patchShebangs $out/share/cockpit/issue/update-issue
@@ -256,6 +272,12 @@ stdenv.mkDerivation (finalAttrs: {
256272
passthru = {
257273
tests = { inherit (nixosTests) cockpit; };
258274
updateScript = nix-update-script { };
275+
cockpitPath = [
276+
glib
277+
gobject-introspection
278+
python3Packages.python
279+
python3Packages.pygobject3
280+
];
259281
};
260282

261283
meta = {
@@ -264,9 +286,6 @@ stdenv.mkDerivation (finalAttrs: {
264286
homepage = "https://cockpit-project.org/";
265287
changelog = "https://cockpit-project.org/blog/cockpit-${finalAttrs.version}.html";
266288
license = lib.licenses.lgpl21;
267-
maintainers = with lib.maintainers; [
268-
lucasew
269-
andre4ik3
270-
];
289+
teams = [ lib.teams.cockpit ];
271290
};
272291
})

0 commit comments

Comments
 (0)