From e0c52b06fd2fa0092e36b357fc8d5c1193bd141a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Sun, 9 Jun 2024 22:42:50 +0200 Subject: [PATCH] cro: abstract out and use for chromecasting radio streams --- configs/browser.nix | 12 ------------ configs/packages.nix | 6 ++++++ flake.nix | 1 + packages/cro.nix | 10 ++++++++++ packages/mpv-radio.nix | 8 ++++++-- 5 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 packages/cro.nix diff --git a/configs/browser.nix b/configs/browser.nix index 7b29068b..be9b1c70 100644 --- a/configs/browser.nix +++ b/configs/browser.nix @@ -5,18 +5,6 @@ }: let inherit (import ../lib) tmpfilesConfig; in { - environment.systemPackages = [ - (pkgs.writers.writeDashBin "cro" '' - ${pkgs.chromium}/bin/chromium \ - --disable-sync \ - --no-default-browser-check \ - --no-first-run \ - --user-data-dir="$(mktemp -d)" \ - --incognito \ - "$@" - '') - ]; - home-manager.users.me = { programs.firefox = { enable = true; diff --git a/configs/packages.nix b/configs/packages.nix index 636e8514..eaab14db 100644 --- a/configs/packages.nix +++ b/configs/packages.nix @@ -153,9 +153,15 @@ in { niveumPackages.emailmenu niveumPackages.closest niveumPackages.trans + niveumPackages.cro (niveumPackages.mpv-radio.override { di-fm-key-file = config.age.secrets.di-fm-key.path; }) + (niveumPackages.mpv-radio.override { + di-fm-key-file = config.age.secrets.di-fm-key.path; + executableName = "cro-radio"; + mpvCommand = "${niveumPackages.cro}/bin/cro"; + }) (niveumPackages.mpv-tuner.override { di-fm-key-file = config.age.secrets.di-fm-key.path; }) diff --git a/flake.nix b/flake.nix index bf4804e6..9e86e91a 100644 --- a/flake.nix +++ b/flake.nix @@ -321,6 +321,7 @@ brassica = pkgs.callPackage packages/brassica.nix {}; cheat-sh = pkgs.callPackage packages/cheat-sh.nix {}; closest = pkgs.callPackage packages/closest {}; + cro = pkgs.callPackage packages/cro.nix {}; cyberlocker-tools = pkgs.callPackage packages/cyberlocker-tools.nix {}; default-gateway = pkgs.callPackage packages/default-gateway.nix {}; depp = pkgs.callPackage packages/depp.nix {}; diff --git a/packages/cro.nix b/packages/cro.nix new file mode 100644 index 00000000..0693a749 --- /dev/null +++ b/packages/cro.nix @@ -0,0 +1,10 @@ +{ writers, chromium }: +writers.writeDashBin "cro" '' + ${chromium}/bin/chromium \ + --disable-sync \ + --no-default-browser-check \ + --no-first-run \ + --user-data-dir="$(mktemp -d)" \ + --incognito \ + "$@" +'' diff --git a/packages/mpv-radio.nix b/packages/mpv-radio.nix index dd1993f0..9eb958a5 100644 --- a/packages/mpv-radio.nix +++ b/packages/mpv-radio.nix @@ -7,6 +7,8 @@ coreutils, gnused, di-fm-key-file, + executableName ? "mpv-radio", + mpvCommand ? "${mpv}/bin/mpv --force-window=yes" }: let streams = import ../lib/streams.nix { di-fm-key = "%DI_FM_KEY%"; @@ -19,11 +21,13 @@ }: "${station}\t${desc}\t${stream}") streams); in - writers.writeDashBin "mpv-radio" '' + writers.writeDashBin executableName '' + set -x + if [ -z ''${DI_FM_KEY} ]; then DI_FM_KEY=$(cat "${di-fm-key-file}") fi - exec ${mpv}/bin/mpv --force-window=yes "$( + exec ${mpvCommand} "$( ${dmenu}/bin/dmenu -i -l 5 < ${streams-tsv} \ | ${coreutils}/bin/cut -f3 \ | ${gnused}/bin/sed s/%DI_FM_KEY%/"$DI_FM_KEY"/