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

pommed service: Replace broken pommed package with pommed-light #21267

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions nixos/modules/services/hardware/pommed.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

with lib;

{
let cfg = config.services.hardware.pommed;
defaultConf = "${pkgs.pommed_light}/etc/pommed.conf.mactel";
in {

options = {

Expand All @@ -12,37 +14,37 @@ with lib;
type = types.bool;
default = false;
description = ''
Whether to use the pommed tool to handle Apple laptop keyboard hotkeys.
Whether to use the pommed tool to handle Apple laptop
keyboard hotkeys.
'';
};

configFile = mkOption {
type = types.path;
type = types.nullOr types.path;
default = null;
description = ''
The path to the <filename>pommed.conf</filename> file.
The path to the <filename>pommed.conf</filename> file. Leave
to null to use the default config file
(<filename>/etc/pommed.conf.mactel</filename>). See the
files <filename>/etc/pommed.conf.mactel</filename> and
<filename>/etc/pommed.conf.pmac</filename> for examples to
build on.
'';
};
};

};

config = mkIf config.services.hardware.pommed.enable {
environment.systemPackages = [ pkgs.polkit ];
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.polkit pkgs.pommed_light ];

environment.etc."pommed.conf".source = config.services.hardware.pommed.configFile;

services.hardware.pommed.configFile = "${pkgs.pommed}/etc/pommed.conf";

services.dbus.packages = [ pkgs.pommed ];
environment.etc."pommed.conf".source =
if cfg.configFile == null then defaultConf else cfg.configFile;

systemd.services.pommed = {
description = "Pommed hotkey management";
description = "Pommed Apple Hotkeys Daemon";
wantedBy = [ "multi-user.target" ];
after = [ "dbus.service" ];
postStop = "rm -f /var/run/pommed.pid";
script = "${pkgs.pommed}/bin/pommed";
serviceConfig.Type = "forking";
path = [ pkgs.eject ];
script = "${pkgs.pommed_light}/bin/pommed -f";
};
};
}
65 changes: 65 additions & 0 deletions pkgs/os-specific/linux/pommed-light/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
stdenv
, fetchurl
, pciutils
, confuse
, alsaLib
, audiofile
, pkgconfig
, zlib
, eject
}:

stdenv.mkDerivation rec {
pkgname = "pommed-light";
version = "1.50lw";
name = "${pkgname}-${version}";

src = fetchurl {
url = "https://github.com/bytbox/${pkgname}/archive/v${version}.tar.gz";

sha256 = "1r2f28zqmyvzgymd0ng53hscbrq8vcqhxdnkq5dppjf9yrzn018b";
};

postPatch = ''
substituteInPlace pommed.conf.mactel --replace /usr $out
substituteInPlace pommed.conf.pmac --replace /usr $out
substituteInPlace pommed/beep.h --replace /usr $out
substituteInPlace pommed/cd_eject.c --replace /usr/bin/eject ${eject}/bin/eject
'';

buildInputs = [
pciutils
confuse
alsaLib
audiofile
pkgconfig
zlib
eject
];

installPhase = ''
install -Dm755 pommed/pommed $out/bin/pommed
install -Dm644 pommed.conf.mactel $out/etc/pommed.conf.mactel
install -Dm644 pommed.conf.pmac $out/etc/pommed.conf.pmac

# Man page
install -Dm644 pommed.1 $out/share/man/man1/pommed.1

# Sounds
install -Dm644 pommed/data/goutte.wav $out/share/pommed/goutte.wav
install -Dm644 pommed/data/click.wav $out/share/pommed/click.wav
'';

meta = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps add meta.platforms = stdenv.lib.platforms.linux.

Also, have you considered adding yourself as the maintainer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have, but I don't feel like taking such a responsibility at the moment.

I will add your suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. Being listed as a maintainer primarily means that you're somebody who cares about the package and might be able to answer questions about it; beyond that, it means whatever you want it to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea I understand. I don't think it's something I will commit to long term (e.g. at least half a year or so), so that's why I prefer not to list myself as maintainer. In any case the @mention-bot would just tag me by analyzing the history when there's an issue right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never seen it do that for ordinary issues, but it usually works for PRs.

description = "A trimmed version of the pommed hotkey handler for MacBooks";
longDescription = ''
This is a stripped-down version of pommed with client, dbus, and
ambient light sensor support removed, optimized for use with dwm
and the like.
'';
homepage = https://github.com/bytbox/pommed-light;
platforms = stdenv.lib.platforms.linux;
license = stdenv.lib.licenses.gpl2;
};
}
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14347,6 +14347,8 @@ in

pommed = callPackage ../os-specific/linux/pommed {};

pommed_light = callPackage ../os-specific/linux/pommed-light {};

pond = callPackage ../applications/networking/instant-messengers/pond { };

ponymix = callPackage ../applications/audio/ponymix { };
Expand Down