diff --git a/nixos/modules/services/hardware/triggerhappy.nix b/nixos/modules/services/hardware/triggerhappy.nix index d2137971b3a7..a9bcf250cf69 100644 --- a/nixos/modules/services/hardware/triggerhappy.nix +++ b/nixos/modules/services/hardware/triggerhappy.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: let cfg = config.services.triggerhappy; @@ -6,35 +11,53 @@ let socket = "/run/thd.socket"; configFile = pkgs.writeText "triggerhappy.conf" '' - ${lib.concatMapStringsSep "\n" - ({ keys, event, cmd, ... }: - ''${lib.concatMapStringsSep "+" (x: "KEY_" + x) keys} ${toString { press = 1; hold = 2; release = 0; }.${event}} ${cmd}'' - ) - cfg.bindings} + ${lib.concatMapStringsSep "\n" ( + { + keys, + event, + cmd, + ... + }: + ''${lib.concatMapStringsSep "+" (x: "KEY_" + x) keys} ${ + toString + { + press = 1; + hold = 2; + release = 0; + } + .${event} + } ${cmd}'' + ) cfg.bindings} ${cfg.extraConfig} ''; - bindingCfg = { ... }: { - options = { + bindingCfg = + { ... }: + { + options = { + + keys = lib.mkOption { + type = lib.types.listOf lib.types.str; + description = "List of keys to match. Key names as defined in linux/input-event-codes.h"; + }; + + event = lib.mkOption { + type = lib.types.enum [ + "press" + "hold" + "release" + ]; + default = "press"; + description = "Event to match."; + }; + + cmd = lib.mkOption { + type = lib.types.str; + description = "What to run."; + }; - keys = lib.mkOption { - type = lib.types.listOf lib.types.str; - description = "List of keys to match. Key names as defined in linux/input-event-codes.h"; }; - - event = lib.mkOption { - type = lib.types.enum ["press" "hold" "release"]; - default = "press"; - description = "Event to match."; - }; - - cmd = lib.mkOption { - type = lib.types.str; - description = "What to run."; - }; - }; - }; in @@ -65,9 +88,9 @@ in bindings = lib.mkOption { type = lib.types.listOf (lib.types.submodule bindingCfg); - default = []; + default = [ ]; example = lib.literalExpression '' - [ { keys = ["PLAYPAUSE"]; cmd = "''${pkgs.mpc-cli}/bin/mpc -q toggle"; } ] + [ { keys = ["PLAYPAUSE"]; cmd = "''${lib.getExe pkgs.mpc} -q toggle"; } ] ''; description = '' Key bindings for {command}`triggerhappy`. @@ -86,7 +109,6 @@ in }; - ###### implementation config = lib.mkIf cfg.enable { @@ -101,18 +123,22 @@ in wantedBy = [ "multi-user.target" ]; description = "Global hotkey daemon"; serviceConfig = { - ExecStart = "${pkgs.triggerhappy}/bin/thd ${lib.optionalString (cfg.user != "root") "--user ${cfg.user}"} --socket ${socket} --triggers ${configFile} --deviceglob /dev/input/event*"; + ExecStart = "${pkgs.triggerhappy}/bin/thd ${ + lib.optionalString (cfg.user != "root") "--user ${cfg.user}" + } --socket ${socket} --triggers ${configFile} --deviceglob /dev/input/event*"; }; }; - services.udev.packages = lib.singleton (pkgs.writeTextFile { - name = "triggerhappy-udev-rules"; - destination = "/etc/udev/rules.d/61-triggerhappy.rules"; - text = '' - ACTION=="add", SUBSYSTEM=="input", KERNEL=="event[0-9]*", ATTRS{name}!="triggerhappy", \ - RUN+="${pkgs.triggerhappy}/bin/th-cmd --socket ${socket} --passfd --udev" - ''; - }); + services.udev.packages = lib.singleton ( + pkgs.writeTextFile { + name = "triggerhappy-udev-rules"; + destination = "/etc/udev/rules.d/61-triggerhappy.rules"; + text = '' + ACTION=="add", SUBSYSTEM=="input", KERNEL=="event[0-9]*", ATTRS{name}!="triggerhappy", \ + RUN+="${pkgs.triggerhappy}/bin/th-cmd --socket ${socket} --passfd --udev" + ''; + } + ); }; diff --git a/nixos/tests/mpd.nix b/nixos/tests/mpd.nix index 0772c05d12ac..e268eb573808 100644 --- a/nixos/tests/mpd.nix +++ b/nixos/tests/mpd.nix @@ -1,12 +1,13 @@ -import ./make-test-python.nix ({ pkgs, lib, ... }: +import ./make-test-python.nix ( + { pkgs, lib, ... }: let track = pkgs.fetchurl { # Sourced from http://freemusicarchive.org/music/Blue_Wave_Theory/Surf_Music_Month_Challenge/Skyhawk_Beach_fade_in - # License: http://creativecommons.org/licenses/by-sa/4.0/ name = "Blue_Wave_Theory-Skyhawk_Beach.mp3"; url = "https://freemusicarchive.org/file/music/ccCommunity/Blue_Wave_Theory/Surf_Music_Month_Challenge/Blue_Wave_Theory_-_04_-_Skyhawk_Beach.mp3"; - sha256 = "0xw417bxkx4gqqy139bb21yldi37xx8xjfxrwaqa0gyw19dl6mgp"; + hash = "sha256-91VDWwrcP6Cw4rk72VHvZ8RGfRBrpRE8xo/02dcJhHc="; + meta.license = lib.licenses.cc-by-sa-40; }; defaultCfg = rec { @@ -16,42 +17,56 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: musicDirectory = "${dataDir}/music"; }; - defaultMpdCfg = with defaultCfg; { - inherit dataDir musicDirectory user group; + defaultMpdCfg = { + inherit (defaultCfg) + dataDir + musicDirectory + user + group + ; enable = true; }; - musicService = { user, group, musicDirectory }: { - description = "Sets up the music file(s) for MPD to use."; - requires = [ "mpd.service" ]; - after = [ "mpd.service" ]; - wantedBy = [ "default.target" ]; - script = '' - cp ${track} ${musicDirectory} - ''; - serviceConfig = { - User = user; - Group = group; + musicService = + { + user, + group, + musicDirectory, + }: + { + description = "Sets up the music file(s) for MPD to use."; + requires = [ "mpd.service" ]; + after = [ "mpd.service" ]; + wantedBy = [ "default.target" ]; + script = '' + cp ${track} ${musicDirectory} + ''; + serviceConfig = { + User = user; + Group = group; + }; }; - }; - mkServer = { mpd, musicService, }: - { boot.kernelModules = [ "snd-dummy" ]; + mkServer = + { mpd, musicService }: + { + boot.kernelModules = [ "snd-dummy" ]; services.mpd = mpd; systemd.services.musicService = musicService; }; - in { + in + { name = "mpd"; - meta = with pkgs.lib.maintainers; { - maintainers = [ emmanuelrosa ]; + meta = { + maintainers = with lib.maintainers; [ emmanuelrosa ]; }; - nodes = - { client = - { ... }: { }; + nodes = { + client = { ... }: { }; serverALSA = - { ... }: lib.mkMerge [ + { ... }: + lib.mkMerge [ (mkServer { mpd = defaultMpdCfg // { network.listenAddress = "any"; @@ -63,13 +78,14 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: } ''; }; - musicService = with defaultMpdCfg; musicService { inherit user group musicDirectory; }; + musicService = musicService { inherit (defaultMpdCfg) user group musicDirectory; }; }) { networking.firewall.allowedTCPPorts = [ 6600 ]; } ]; serverPulseAudio = - { ... }: lib.mkMerge [ + { ... }: + lib.mkMerge [ (mkServer { mpd = defaultMpdCfg // { extraConfig = '' @@ -80,7 +96,7 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: ''; }; - musicService = with defaultCfg; musicService { inherit user group musicDirectory; }; + musicService = musicService { inherit (defaultMpdCfg) user group musicDirectory; }; }) { hardware.pulseaudio = { @@ -94,40 +110,41 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: ]; }; - testScript = '' - mpc = "${pkgs.mpc-cli}/bin/mpc --wait" + testScript = '' + mpc = "${lib.getExe pkgs.mpc} --wait" - # Connects to the given server and attempts to play a tune. - def play_some_music(server): - server.wait_for_unit("mpd.service") - server.succeed(f"{mpc} update") - _, tracks = server.execute(f"{mpc} ls") + # Connects to the given server and attempts to play a tune. + def play_some_music(server): + server.wait_for_unit("mpd.service") + server.succeed(f"{mpc} update") + _, tracks = server.execute(f"{mpc} ls") - for track in tracks.splitlines(): - server.succeed(f"{mpc} add {track}") + for track in tracks.splitlines(): + server.succeed(f"{mpc} add {track}") - _, added_tracks = server.execute(f"{mpc} playlist") + _, added_tracks = server.execute(f"{mpc} playlist") - # Check we succeeded adding audio tracks to the playlist - assert len(added_tracks.splitlines()) > 0 + # Check we succeeded adding audio tracks to the playlist + assert len(added_tracks.splitlines()) > 0 - server.succeed(f"{mpc} play") + server.succeed(f"{mpc} play") - _, output = server.execute(f"{mpc} status") - # Assure audio track is playing - assert "playing" in output + _, output = server.execute(f"{mpc} status") + # Assure audio track is playing + assert "playing" in output - server.succeed(f"{mpc} stop") + server.succeed(f"{mpc} stop") - play_some_music(serverALSA) - play_some_music(serverPulseAudio) + play_some_music(serverALSA) + play_some_music(serverPulseAudio) - client.wait_for_unit("multi-user.target") - client.succeed(f"{mpc} -h serverALSA status") + client.wait_for_unit("multi-user.target") + client.succeed(f"{mpc} -h serverALSA status") - # The PulseAudio-based server is configured not to accept external client connections - # to perform the following test: - client.fail(f"{mpc} -h serverPulseAudio status") - ''; -}) + # The PulseAudio-based server is configured not to accept external client connections + # to perform the following test: + client.fail(f"{mpc} -h serverPulseAudio status") + ''; + } +) diff --git a/pkgs/applications/audio/clerk/default.nix b/pkgs/applications/audio/clerk/default.nix deleted file mode 100644 index f77b03daac78..000000000000 --- a/pkgs/applications/audio/clerk/default.nix +++ /dev/null @@ -1,82 +0,0 @@ -{ lib -, stdenv -, fetchFromGitHub -, makeWrapper -, rofi -, tmux -, fzf -, mpc-cli -, perl -, util-linux -, libnotify -, perlPackages -}: - -stdenv.mkDerivation { - pname = "clerk"; - version = "unstable-2023-10-07"; - - src = fetchFromGitHub { - owner = "carnager"; - repo = "clerk"; - rev = "907138d8fc2b1709fb49d062d0b663a48eb210bd"; - hash = "sha256-V2nDLq2ViC5Twve0EILBEYOdEavqgYB/TQq/T+ftfmk="; - }; - - postPatch = '' - substituteInPlace clerk_rating_client.service \ - --replace "/usr" "$out" - ''; - - nativeBuildInputs = [ makeWrapper ]; - - buildInputs = with perlPackages; [ - perl - DataMessagePack - DataSectionSimple - ConfigSimple - TryTiny - IPCRun - HTTPDate - FileSlurper - ArrayUtils - NetMPD - ]; - - dontBuild = true; - - strictDeps = true; - - installPhase = '' - runHook preInstall - - install -D clerk.pl $out/bin/clerk - install -D clerk_rating_client $out/bin/clerk_rating_client - install -D clerk_rating_client.service $out/lib/systemd/user/clerk_rating_client.service - runHook postInstall - ''; - - postFixup = let - binPath = lib.makeBinPath [ - libnotify - mpc-cli - rofi - tmux - fzf - util-linux - ]; - in - '' - wrapProgram $out/bin/clerk --set PERL5LIB $PERL5LIB --prefix PATH : "${binPath}" - wrapProgram $out/bin/clerk_rating_client --set PERL5LIB $PERL5LIB --prefix PATH : "${binPath}" - ''; - - meta = with lib; { - description = "MPD client based on rofi/fzf"; - homepage = "https://github.com/carnager/clerk"; - license = licenses.mit; - maintainers = with maintainers; [ anderspapitto rewine ]; - mainProgram = "clerk"; - platforms = platforms.linux; - }; -} diff --git a/pkgs/applications/audio/mpc/default.nix b/pkgs/applications/audio/mpc/default.nix deleted file mode 100644 index c58c6831edf4..000000000000 --- a/pkgs/applications/audio/mpc/default.nix +++ /dev/null @@ -1,63 +0,0 @@ -{ lib -, stdenv -, fetchFromGitHub -, fetchpatch -, installShellFiles -, libiconv -, libmpdclient -, meson -, ninja -, pkg-config -, sphinx -}: - -stdenv.mkDerivation rec { - pname = "mpc"; - version = "0.34"; - - src = fetchFromGitHub { - owner = "MusicPlayerDaemon"; - repo = pname; - rev = "v${version}"; - hash = "sha256-2FjYBfak0IjibuU+CNQ0y9Ei8hTZhynS/BK2DNerhVw="; - }; - - patches = [ - # fix the build with meson 0.60 (https://github.com/MusicPlayerDaemon/mpc/pull/76) - (fetchpatch { - url = "https://github.com/MusicPlayerDaemon/mpc/commit/b656ca4b6c2a0d5b6cebd7f7daa679352f664e0e.patch"; - sha256 = "sha256-fjjSlCKxgkz7Em08CaK7+JAzl8YTzLcpGGMz2HJlsVw="; - }) - ]; - - buildInputs = [ - libmpdclient - ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ]; - - nativeBuildInputs = [ - installShellFiles - meson - ninja - pkg-config - sphinx - ]; - - postInstall = '' - installShellCompletion --cmd mpc --bash $out/share/doc/mpc/contrib/mpc-completion.bash - ''; - - postFixup = '' - rm $out/share/doc/mpc/contrib/mpc-completion.bash - ''; - - meta = with lib; { - homepage = "https://www.musicpd.org/clients/mpc/"; - description = "Minimalist command line interface to MPD"; - changelog = "https://raw.githubusercontent.com/MusicPlayerDaemon/mpc/v${version}/NEWS"; - license = licenses.gpl2Plus; - maintainers = with maintainers; [ AndersonTorres ]; - platforms = with platforms; unix; - mainProgram = "mpc"; - }; -} diff --git a/pkgs/applications/window-managers/i3/bumblebee-status/plugins.nix b/pkgs/applications/window-managers/i3/bumblebee-status/plugins.nix index 5810070d2ff4..d5567ce15e8f 100644 --- a/pkgs/applications/window-managers/i3/bumblebee-status/plugins.nix +++ b/pkgs/applications/window-managers/i3/bumblebee-status/plugins.nix @@ -89,7 +89,7 @@ in memory.propagatedBuildInputs = [ pkgs.gnome-system-monitor ]; messagereceiver = { }; mocp.propagatedBuildInputs = [ pkgs.moc ]; - mpd.propagatedBuildInputs = [ pkgs.mpc-cli ]; + mpd.propagatedBuildInputs = [ pkgs.mpc ]; network.propagatedBuildInputs = [ py.netifaces pkgs.iw ]; network_traffic.propagatedBuildInputs = [ py.netifaces ]; nic.propagatedBuildInputs = [ py.netifaces pkgs.iw ]; diff --git a/pkgs/by-name/cl/clerk/package.nix b/pkgs/by-name/cl/clerk/package.nix new file mode 100644 index 000000000000..2470e4c5369c --- /dev/null +++ b/pkgs/by-name/cl/clerk/package.nix @@ -0,0 +1,103 @@ +{ + lib, + fetchFromGitHub, + fzf, + installShellFiles, + libnotify, + makeWrapper, + mpc, + perlPackages, + rofi, + stdenv, + tmux, + unstableGitUpdater, + util-linux, +}: + +stdenv.mkDerivation { + pname = "clerk"; + version = "4.0.5-unstable-2023-10-07"; + + src = fetchFromGitHub { + owner = "carnager"; + repo = "clerk"; + rev = "907138d8fc2b1709fb49d062d0b663a48eb210bd"; + hash = "sha256-V2nDLq2ViC5Twve0EILBEYOdEavqgYB/TQq/T+ftfmk="; + }; + + nativeBuildInputs = [ + installShellFiles + makeWrapper + ]; + + buildInputs = with perlPackages; [ + perl + DataMessagePack + DataSectionSimple + ConfigSimple + TryTiny + IPCRun + HTTPDate + FileSlurper + ArrayUtils + NetMPD + ]; + + dontBuild = true; + + strictDeps = true; + + postPatch = '' + substituteInPlace clerk_rating_client.service \ + --replace "/usr" "$out" + ''; + + installPhase = '' + runHook preInstall + + mv clerk.pl clerk + installBin clerk clerk_rating_client + install -D clerk_rating_client.service $out/lib/systemd/user/clerk_rating_client.service + + runHook postInstall + ''; + + postFixup = + let + binPath = lib.makeBinPath [ + fzf + libnotify + mpc + rofi + tmux + util-linux + ]; + in + '' + pushd $out/bin + for f in clerk clerk_rating_client; do + wrapProgram $f \ + --prefix PATH : "${binPath}" \ + --set PERL5LIB $PERL5LIB + done + popd + ''; + + passthru.updateScript = unstableGitUpdater { + url = "https://github.com/carnager/clerk.git"; + hardcodeZeroVersion = true; + }; + + meta = { + homepage = "https://github.com/carnager/clerk"; + description = "MPD client based on rofi/fzf"; + license = lib.licenses.mit; + mainProgram = "clerk"; + maintainers = with lib.maintainers; [ + anderspapitto + rewine + AndersonTorres + ]; + platforms = lib.platforms.linux; + }; +} diff --git a/pkgs/by-name/mp/mpc/package.nix b/pkgs/by-name/mp/mpc/package.nix new file mode 100644 index 000000000000..2d1976123167 --- /dev/null +++ b/pkgs/by-name/mp/mpc/package.nix @@ -0,0 +1,54 @@ +{ + lib, + fetchFromGitHub, + installShellFiles, + libiconv, + libmpdclient, + meson, + ninja, + pkg-config, + python3Packages, + stdenv, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "mpc"; + version = "0.35"; + + src = fetchFromGitHub { + owner = "MusicPlayerDaemon"; + repo = "mpc"; + rev = "v${finalAttrs.version}"; + hash = "sha256-oVdnj3nsYvOHcIOgoamLamriuWu9lucWUQtxVmXZabs="; + }; + + buildInputs = [ + libmpdclient + ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ]; + + nativeBuildInputs = [ + installShellFiles + meson + ninja + pkg-config + python3Packages.sphinx + ]; + + postInstall = '' + installShellCompletion --cmd mpc --bash $out/share/doc/mpc/contrib/mpc-completion.bash + ''; + + postFixup = '' + rm $out/share/doc/mpc/contrib/mpc-completion.bash + ''; + + meta = { + homepage = "https://www.musicpd.org/clients/mpc/"; + description = "Minimalist command line interface to MPD"; + changelog = "https://raw.githubusercontent.com/MusicPlayerDaemon/mpc/refs/heads/master/NEWS"; + license = lib.licenses.gpl2Plus; + mainProgram = "mpc"; + maintainers = with lib.maintainers; [ AndersonTorres ]; + platforms = lib.platforms.unix; + }; +}) diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index 394335eaee14..fcbe89709280 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -778,7 +778,8 @@ mapAliases { mongodb-5_0 = throw "mongodb-5_0 has been removed, it's end of life since October 2024"; # Added 2024-10-01 moz-phab = mozphab; # Added 2022-08-09 mp3info = throw "'mp3info' has been removed due to lack of maintenance upstream. Consider using 'eartag' or 'tagger' instead"; # Added 2024-09-14 - mpc_cli = mpc-cli; # moved from top-level 2022-01-24 + mpc-cli = mpc; # Added 2024-10-14 + mpc_cli = mpc; # Added 2024-10-14 mpd_clientlib = throw "'mpd_clientlib' has been renamed to/replaced by 'libmpdclient'"; # Converted to throw 2024-10-17 mpdevil = plattenalbum; # Added 2024-05-22 mpg321 = throw "'mpg321' has been removed due to it being unmaintained by upstream. Consider using mpg123 instead."; # Added 2024-05-10 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1ccdc8f5d639..84907eb22fbb 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -30932,12 +30932,6 @@ with pkgs; withConplay = false; }; - mpc-cli = callPackage ../applications/audio/mpc { - inherit (python3Packages) sphinx; - }; - - clerk = callPackage ../applications/audio/clerk { }; - nbstripout = callPackage ../applications/version-management/nbstripout { }; ncmpc = callPackage ../applications/audio/ncmpc { };