Giter Club home page Giter Club logo

Comments (4)

jonafato avatar jonafato commented on May 26, 2024

@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 };

from gnome-shell-extension-docker.

maxkrieger avatar maxkrieger commented on May 26, 2024

@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.

from gnome-shell-extension-docker.

jonafato avatar jonafato commented on May 26, 2024

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.

from gnome-shell-extension-docker.

maxkrieger avatar maxkrieger commented on May 26, 2024

@jonafato gotcha, thanks!

from gnome-shell-extension-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.