Closed maxkrieger closed 5 years ago
@maxkrieger As noted in #37, I have an expression suitable for NixOS that accounts for this issue. Once it can refer to git tags for the source, I'll open up a pull request against nixpkgs to add it there. In the mean time, the expression below should work for you:
default.nix
:
{ stdenv, substituteAll, fetchFromGitHub, docker, procps }:
stdenv.mkDerivation rec {
name = "gnome-shell-extension-docker-status-${version}";
version = "2019-03-08";
src = fetchFromGitHub {
owner = "gpouilloux";
repo = "gnome-shell-extension-docker";
rev = "5783aedd0c384c8859c7a134e079c813c8071cce";
sha256 = "0wmxca90mdlllh1xmvm89nbxnz65sbnab2s4mi6cjjgaqi4p3dc9";
};
uuid = "docker_status@gpouilloux";
installPhase = ''
mkdir -p $out/share/gnome-shell/extensions/${uuid}
cp docker.svg $out/share/gnome-shell/extensions/${uuid}
cp extension.js $out/share/gnome-shell/extensions/${uuid}
cp metadata.json $out/share/gnome-shell/extensions/${uuid}
cp stylesheet.css $out/share/gnome-shell/extensions/${uuid}
cp -R src $out/share/gnome-shell/extensions/${uuid}
'';
patches = [
(substituteAll {
src = ./fix-paths.patch;
docker = "${docker}/bin/docker";
ps = "${procps}/bin/ps";
})
];
meta = with stdenv.lib; {
description = "Status menu for managing Docker containers";
license = licenses.gpl2;
maintainers = with maintainers; [ jonafato ];
homepage = https://github.com/gpouilloux/gnome-shell-extension-docker;
};
}
fix-paths.patch
:
diff --git a/src/docker.js b/src/docker.js
index 3a3ba54..a3eed3e 100644
--- a/src/docker.js
+++ b/src/docker.js
@@ -40,7 +40,7 @@ const isDockerInstalled = () => !!GLib.find_program_in_path('docker');
* @return {Boolean} whether docker daemon is running or not
*/
const isDockerRunning = () => {
- const [res, pid, in_fd, out_fd, err_fd] = GLib.spawn_async_with_pipes(null, ['/bin/ps', 'cax'], null, 0, null);
+ const [res, pid, in_fd, out_fd, err_fd] = GLib.spawn_async_with_pipes(null, ['@ps@', 'cax'], null, 0, null);
const outReader = new Gio.DataInputStream({
base_stream: new Gio.UnixInputStream({ fd: out_fd })
@@ -66,7 +66,7 @@ const isDockerRunning = () => {
* @return {Array} The array of containers as { name, status }
*/
const getContainers = () => {
- const [res, out, err, status] = GLib.spawn_command_line_sync("docker ps -a --format '{{.Names}},{{.Status}}'");
+ const [res, out, err, status] = GLib.spawn_command_line_sync("@docker@ ps -a --format '{{.Names}},{{.Status}}'");
if (status !== 0)
throw new Error("Error occurred when fetching containers");
@@ -88,7 +88,7 @@ const getContainers = () => {
* @param {Function} callback A callback that takes the status, command, and stdErr
*/
const runCommand = (command, containerName, callback) => {
- const cmd = "docker " + command + " " + containerName;
+ const cmd = "@docker@ " + command + " " + containerName;
async(() => {
const [res, out, err, status] = GLib.spawn_command_line_async(cmd);
return { cmd: cmd, err: err, status: status };
@jonafato great! To clarify, I installed this package via the gnome shell web interface. Is this generally inadvisable for Nix users? I presume this will be installable directly via nixpkgs when it gets merged.
The selection of GNOME extensions available in nixpkgs is obviously not exhaustive, but I'd recommend installing extensions via nix primarily, anyway. If an extension you need isn't there, they tend to be pretty straightforward to package (I'm happy to help out if you run into any trouble). And as you've noticed, extensions that depend on external binaries are likely to fail when installed from extensions.gnome.org or other methods that don't contain these types of patches.
@jonafato gotcha, thanks!
I use NixOS, which doesn't have
/bin/ps
linked by default. It's instead in/run/current-system/sw/bin/ps
. So I had to link it manually. Is there a more principled way for the extension to do this automatically? Not all systems haveps
in/bin/ps
.Otherwise, the extension fails to install:
docker_status_gpouilloux has error: GLib.SpawnError: Failed to execute child process “/bin/ps” (No such file or directory)