Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deadd-notification-center: init at 1.7.2 #89118

Merged
merged 2 commits into from Dec 13, 2020

Conversation

Pacman99
Copy link
Contributor

Motivation for this change

Adds linux_notification-center, a notification daemon that also provides a toggle for a notification center
https://github.com/phuhl/linux_notification_center

I could not figure out how to compile from source. Stack tried to create a directory in '/' when compiling. The binary was much easier to package, so I chose to do that and get just the dbus service file from the github repository.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@06kellyjac
Copy link
Member

I've got a couple suggestions. I'll post after eating

@IvarWithoutBones
Copy link
Member

I am very inexperienced with haskell, but it seems like this might help with that stack problem

@Pacman99
Copy link
Contributor Author

Pacman99 commented May 28, 2020

@IvarWithoutBones phuhl/linux_notification_center#28 the nix section for stack is supposed to be added. Even then I'm not sure how to package with stack compilation.

I can try it with haskell.lib.buildStackProject, but is it okay to create a package with that? I thought it was meant for development purposes.

@IvarWithoutBones
Copy link
Member

I can try it with haskell.lib.buildStackProject, but is it okay to create a package with that? I thought it was meant for development purposes.

Seems like you're right, my bad. Looking around the repo it indeed never seems to be used, i just thought it might fix the issue when posting that comment 😅

Comment on lines 1 to 51
{ stdenv, lib, fetchurl, autoPatchelfHook
, gtk3, gobject-introspection, libxml2 }:

let
dbusService = fetchurl {
url = "https://github.com/phuhl/linux_notification_center/raw/master/com.ph-uhl.deadd.notification.service.in";
sha256 = "0jvmi1c98hm8x1x7kw9ws0nbf4y56yy44c3bqm6rjj4lrm89l83s";
};
in
stdenv.mkDerivation rec {

pname = "linux_notification_center";
version = "1.7.2";

src = fetchurl {
url = "https://github.com/phuhl/linux_notification_center/releases/download/${version}/deadd-notification-center";
sha256 = "13f15slkjiw2n5dnqj13dprhqm3nf1k11jqaqda379yhgygyp9zm";
};

dontUnpack = true;

nativeBuildInputs = [ autoPatchelfHook ];

buildInputs = [
gtk3
gobject-introspection
libxml2
];

installPhase = ''
mkdir -p $out/bin
cp $src $out/bin/deadd-notification-center
chmod +x $out/bin/deadd-notification-center

mkdir -p $out/share/dbus-1/services
sed "s|##PREFIX##|$out|g" ${dbusService} > $out/share/dbus-1/services/com.ph-uhl.deadd.notification.service
'';

meta = with lib; {
description = "A notification daemon/center for linux";
homepage = https://github.com/phuhl/linux_notification_center;
license = licenses.bsd3;
maintainers = [ maintainers.pacman99 ];
platforms = platforms.linux;
};
}

This comment was marked as outdated.

This comment was marked as outdated.

@Pacman99
Copy link
Contributor Author

Pacman99 commented May 28, 2020

@06kellyjac Thank you! I took all the suggestions, but added a bit of opinionated white spacing ;)

@Pacman99
Copy link
Contributor Author

I tried building from source here: https://github.com/Pacman99/nixpkgs/blob/notification-center-fromsource/pkgs/applications/misc/linux-notification-center/default.nix

I can't get it to build, it outputs: /nix/store/...linux_notification_center-1.7.2.drv' has '__noChroot' set, but that's not allowed when 'sandbox' is 'true' sandbox=true is default for nix, so it can't be shipped as a package. I tried to set it to false, but the same error came, since I guess its still "set". Not sure how to proceed from there.

@06kellyjac
Copy link
Member

Every haskell package I can think of searching for is in the configuration-hackage2nix.yaml file, linux_notification_center isn't on hackage yet 🙃

@06kellyjac
Copy link
Member

Here's something I was trying based on carp:

{ lib
, fetchFromGitHub
, haskellPackages
, pango
, cairo
, gtk3
, gobject-introspection
, libxml2
}:

haskellPackages.mkDerivation rec {
  pname = "linux-notification-center";
  version = "1.7.2";

  src = fetchFromGitHub {
    owner = "phuhl";
    repo = builtins.replaceStrings ["-"] ["_"] pname;
    rev = version;
    sha256 = "1j3j9m7hhrq9jk95kpf458dimy08xp7nxd47na6nmcvybdv4kgq8";
  };

  buildDepends = [
    # cairo
    pango
    gtk3
    gobject-introspection
    libxml2
  ];

  executableHaskellDepends = with haskellPackages; [
    ConfigFile
    cairo
    dbus
    gi-gdk
    gi-gdkpixbuf
    gi-gio
    gi-gtk
    gtk3
    hdaemonize
    here
    hgettext
    lens
    setlocale
    system-locale
    tuple
  ];

  isExecutable = true;

  description = "A notification daemon/center for linux";
  homepage = https://github.com/phuhl/linux_notification_center;
  license = lib.licenses.bsd3;
  maintainers = with lib.maintainers; [ pacman99 ];
  platforms = lib.platforms.linux;
  
}

but system-locale is broken so I didn't get past there. Seems like time in nixpkgs is the wrong version for system-locale.

Also I only found one other package using haskellPackages.mkDerivation like this, taskell and even taskell is in configuration-hackage2nix.yaml (note: might need to remove the nix derivation in favor of the hackage2nix stuff?)

@06kellyjac
Copy link
Member

06kellyjac commented May 28, 2020

This is a nifty line you can keep for if you get it building from source: repo = builtins.replaceStrings ["-"] ["_"] pname;
(or you can put it in the fetchurl string)


or it might be useless, as it might be better to package it as deadd-notification-center as that's what it's referred to in the README a lot and on the AUR

@Pacman99 Pacman99 changed the title linux_notification_center: init at 1.7.2 deadd-notification-center: init at 1.7.2 May 28, 2020
@Pacman99
Copy link
Contributor Author

Pacman99 commented May 28, 2020

or it might be useless, as it might be better to package it as deadd-notification-center as that's what it's referred to in the README a lot and on the AUR

Makes sense to me, I renamed everything.

Here's something I was trying based on carp:

Wow that looks great! Without the broken system-locale, it would probably work. Not sure how to test that theory though.

From source would be nice, but I'll keep it as a binary package for now, because of the time issue. I think it makes sense, since that is how the author released the program. Maybe if they release it to hackage it can packaged with that or as a haskell derivation if the time issue is fixed.

This is a nifty line you can keep for if you get it building from source: repo = builtins.replaceStrings ["-"] ["_"] pname;
(or you can put it in the fetchurl string)

Thats cool, I might be able to use that somewhere else

Also I only found one other package using haskellPackages.mkDerivation like this, taskell and even taskell is in configuration-hackage2nix.yaml (note: might need to remove the nix derivation in favor of the hackage2nix stuff?)

The hackage taskell is marked as broken, so I guess that is why the separate derivation was created.

@jozuas
Copy link
Member

jozuas commented Aug 31, 2020

Hi Pacman99, thanks for your work. I couldn't wait for this to be merged and built your expression locally without modifications.

Everything works fine with an exception of notifications with icons, e.g. Spotify.
image
Please notice the Spotify icon.

deadd-notification-center produces the following warning:

(deadd-notification-center:11100): Gtk-WARNING **: 19:23:31.432: Could not find the icon 'spotify-client-ltr'. The 'hicolor' theme
was not found either, perhaps you need to install it.
You can get a copy from:
	http://icon-theme.freedesktop.org/releases

Manually adding the nixpkgs.hicolor-icon-theme fixes the issue:
image

I'm very new to Nix/NixOS, but my thinking is that this hicolor theme should be a build input. Similar situation was encountered in the Network Manager Applet #32730 and was resolved by this PR.

@berbiche
Copy link
Member

berbiche commented Oct 31, 2020

Tested locally on Sway after rebasing on latest master and it worked fine.

Here's the patch for hicolor-icon-theme:

diff --git a/pkgs/applications/misc/deadd-notification-center/default.nix b/pkgs/applications/misc/deadd-notification-center/default.nix
index 98fe799b110..ed5100d722a 100644
--- a/pkgs/applications/misc/deadd-notification-center/default.nix
+++ b/pkgs/applications/misc/deadd-notification-center/default.nix
@@ -1,9 +1,11 @@
 { stdenv
 , fetchurl
 , autoPatchelfHook
+, wrapGAppsHook
 , gtk3
 , gobject-introspection
 , libxml2
+, hicolor-icon-theme
 }:
 
 let
@@ -25,12 +27,16 @@ stdenv.mkDerivation rec {
 
   dontUnpack = true;
 
-  nativeBuildInputs = [ autoPatchelfHook ];
+  nativeBuildInputs = [
+    autoPatchelfHook
+    wrapGAppsHook
+  ];
 
   buildInputs = [
     gtk3
     gobject-introspection
     libxml2
+    hicolor-icon-theme
   ];
 
   installPhase = ''
@@ -38,7 +44,7 @@ stdenv.mkDerivation rec {
     cp $src $out/bin/deadd-notification-center
     chmod +x $out/bin/deadd-notification-center
 
-    sed "s|##PREFIX##|$out|g" ${dbusService} > $out/share/dbus-1/services/com.ph-uhl.deadd.notification.service 
+    sed "s|##PREFIX##|$out|g" ${dbusService} > $out/share/dbus-1/services/com.ph-uhl.deadd.notification.service
   '';
 
   meta = with stdenv.lib; {

Locally tested deadd-notification-center and Spotify with the following commands:

$ nix-shell --pure -I nixpkgs=<PATH-TO-LOCAL-NIXPKGS> -p deadd-notification-center dbus --run "dbus-run-session -- bash -c 'echo \$DBUS_SESSION_BUS_ADDRESS; deadd-notification-center'" &
unix:abstract=/tmp/dbus-0VyhuZqAYs,guid=long-string

[nix-shell:~]$ DBUS_SESSION_BUS_ADDRESS="<copy-paste result above>" spotify &

Note that processes are not killed upon leaving the shell and must be manually killed.

Spotify's icon is still missing (which is expected since there is no icon theme in the pure shell in $XDG_DATA_DIRS) but the warning disappears.

@SuperSandro2000
Copy link
Member

Result of nixpkgs-review pr 89118 run on x86_64-linux 1

1 package built:
  • deadd-notification-center

@teto
Copy link
Member

teto commented Dec 13, 2020

It's a damn cool software, let's not make perfect be in the way of good, this can be iteratively improved. It passes nixpkgs-review here.

@teto teto merged commit ea85760 into NixOS:master Dec 13, 2020
@teto
Copy link
Member

teto commented Dec 13, 2020

random question: I would love to have a toggle to show the center in systray. Anyone with a snippet ? kill -s USR1 $(pidof deadd-notification-center) works but would rather have something to click.

@jozuas
Copy link
Member

jozuas commented Dec 13, 2020

On polybar you could write a button module, e.g. on my polybar I can toggle mute by clicking on the volume icon:

image

image

While it's not going to be in the tray, you could position in before or after the tray.

@teto
Copy link
Member

teto commented Dec 13, 2020

thanks I am using i3pystatus + i3bar so that's doable. Endgame would be to have a counter too so I will track phuhl/linux_notification_center#34.

@06kellyjac
Copy link
Member

@noreferences thats a nice polybar config. Is the one in your nix-config repo up to date?

@jozuas
Copy link
Member

jozuas commented Dec 13, 2020

@noreferences thats a nice polybar config. Is the one in your nix-config repo up to date?

Yep

@Pacman99
Copy link
Contributor Author

Pacman99 commented Dec 13, 2020

Thanks for merging! Sorry I didn't respond to some of the comments, I didn't get much time to work on this. I can send in a PR later for the icon themes as @berbiche and @noreferences suggested. Also If the errors from system-locale and time in haskellPackges gets fixed at some point, I'd like to get this building from source. But till then this expression works pretty well.

@ddorn
Copy link

ddorn commented Dec 14, 2020

Thanks for merging ! I've been looking forward to this for some time !

@teto I have a binding in my i3 config for kill -s USR1 $(pidof deadd-notification-center) on Mod+shift+enter, it seems to do the job quite well, though it's not a toggle in the systray.

@Pacman99 Pacman99 deleted the notification-center branch December 25, 2020 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants