NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.29k stars 13.54k forks source link

Package request: way-shell #329583

Open sudanchapagain opened 1 month ago

sudanchapagain commented 1 month ago

Project description A Gnome-like shell for wayland compositors

Metadata


I have so far done the following, but i just cannot get glib schema file to compile, i tried a lot. The binary itself compiles, but cannot run it as gschema is not available.

{ stdenv
, lib
, fetchFromGitHub
, pkg-config
, gtk-doc
, glib
, gtk4
, gsettings-desktop-schemas
, wrapGAppsHook4
, dconf
, libadwaita
, gtk4-layer-shell
, power-profiles-daemon
, upower
, wireplumber
, pipewire
, json-glib
, networkmanager
, libpulseaudio
, wayland-protocols
, wayland-utils
, xwayland
}:

stdenv.mkDerivation rec {
  pname = "wayshell";
  version = "0.1.0";

  src = fetchFromGitHub {
    owner = "ldelossa";
    repo = "way-shell";
    rev = "7c9d9c676914fc7f8df1ef10bf4fbfe70b4fd5bb";
    sha256 = "sha256-pT8e5t3ORlQcawcMhvcpWvBluPmK3tvTbyW/WdFlQPo=";
  };

  nativeBuildInputs = [
    pkg-config
    gtk-doc
    glib
    wrapGAppsHook4
  ];

  buildInputs = [
    libadwaita
    upower
    wireplumber
    json-glib
    networkmanager.dev
    libpulseaudio
    gtk4
    gtk4-layer-shell
    power-profiles-daemon
    gsettings-desktop-schemas
    dconf.lib
    pipewire
    pipewire.dev
    wayland-protocols
    wayland-utils
    xwayland
    glib.dev
  ];

  patches = [ ./add-pipewire-include.patch ];

  installPhase = ''
    make install DESTDIR=$out
    mkdir -p $out/share/glib-2.0/schemas
    glib-compile-schemas $out/share/glib-2.0/schemas
  '';

  #  postInstall = ''
  #    glib-compile-schemas $out/share/glib-2.0/schemas
  #  '';
  #make install-gschema DESTDIR=$out/share/glib-2.0/schemas

  # Apparently, No need to set SCHEMADIR explicitly as it likely defaults to share/glib-2.0/schemas

  preFixup = ''
    wrapProgram $out/usr/bin/way-shell \
      --prefix GIO_EXTRA_MODULES : "${dconf}/lib/gio/modules" \
      --prefix XDG_DATA_DIRS : "$out/share" \
      --prefix XDG_DATA_DIRS : "$out/share/gsettings-schemas/${gsettings-desktop-schemas.name}" \
      --prefix XDG_DATA_DIRS : "${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}" \
      --prefix GSETTINGS_SCHEMA_DIR : "$out/share" \
      --prefix GSETTINGS_SCHEMAS_PATH : "$out/share/glib-2.0/schemas"
  '';

  meta = with lib; {
    homepage = "https://github.com/ldelossa/way-shell/";
    description = "A Gnome-like shell for wayland compositors";
    mainProgram = "way-shell";
    license = licenses.gpl2;
    platforms = platforms.unix;
  };
}

patch file

  diff --git a/Makefile b/Makefile
index a3b6e7d..f7c2d12 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,8 @@
 # depedency order matters here.
 # Gtk4LayerShell must be linked before any wayland libraries
 DEPS := libadwaita-1 \
-        gtk4-layer-shell-0 \
+        gtk4-layer-shell-0 \
+        libpipewire-0.3 \
        upower-glib \
        wireplumber-0.5 \
        json-glib-1.0 \

Add a :+1: reaction to issues you find important.

eclairevoyant commented 1 month ago

The fixup should be unnecessary, that's what wrapGApps* is for. Putting .dev is also unnecessary, the builder will automatically select the correct output

Also it's missing the pre-/post-phase hooks, that can also cause issues.

eclairevoyant commented 1 month ago

What should be in pre and post hooks?

I was referring to the installPhase, if you set a phase manually, you should include runHook pre<Phase> and runHook post<Phase> at the beginning and end, as explained in https://nix.dev/tutorials/packaging-existing-software#phases-and-hooks

Anyway I gave it a go in #329677, perhaps you can take a look. upower must be enabled as a prerequisite so I create a small module for that as well.

sudanchapagain commented 1 month ago

Thank you for this. I really do not know much about the Nix language, let alone packaging applications for Nix.

eclairevoyant commented 1 month ago

It's a learning process, I didn't use nix before last year either. Besides nix itself is simple, it's the nixpkgs stuff and dealing with upstream build systems that's a lot to learn.