Commit bb2ae01e authored by S0AndS0's avatar S0AndS0
Browse files

radio-active: init at 2.9.1

Internally adds `zenlog` which, in the future, may break due to
`colorlog` introducing breaking-changes.  Hence why for the commented
code in that section.  Searching if any other packages have this
dependency did not result in results;

```bash
shopt -s globstar;
grep -rEn -- zenlog pkgs/**/*.nix;
```

Overrides and pins `pyradios` to version `1.0.2` because without this
the main application complains during install time.

Main package `src` is obtained via `fetchFromGitHub` because I forked it
to enable XDG configuration directory support as well as reduce need of
declaring defaults.  Once deep5050/radio-active#124 is accepted, or
rejected, we can revisit the `src` value.

Attributions;

- @qzylinra for making code look pretty
- @SuperSandro2000 for encouraging `zenlog` to be packaged separately
parent fbbb3b9e
Loading
Loading
Loading
Loading
+68 −0
Original line number Diff line number Diff line
{
  lib,
  python3Packages,
  fetchFromGitHub,
  ffmpeg,
}:

let
  ## https://github.com/deep5050/radio-active/blob/main/requirements.txt
  pyradios_1-0-2 = python3Packages.pyradios.overrideAttrs (
    finalAttrs: previousAttrs:
    let
      version = "1.0.2";
    in
    {
      inherit version;

      src = previousAttrs.src.override {
        inherit version;
        hash = "sha256-O30ExmvWu4spwDytFVPWGjR8w3XSTaWd2Z0LGQibq9g=";
      };
    }
  );

  pname = "radio-active";
  version = "2.9.1";
in
python3Packages.buildPythonApplication {
  inherit pname version;
  pyproject = true;

  src = fetchFromGitHub {
    owner = "S0AndS0";
    repo = "radio-active";
    rev = "2befa6a309d9c411ef1ea522e706ed3e098e5341";
    hash = "sha256-wqETmdqvxsKnjkjQADq59J83QkOhLA74SPtuWTpsvO0=";
  };

  postPatch = ''
    substituteInPlace radioactive/recorder.py \
      --replace-fail '"ffmpeg",' '"${lib.getExe ffmpeg}",'

    substituteInPlace radioactive/ffplay.py \
      --replace-fail 'self.exe_path = which(self.program_name)' \
      'self.exe_path = "${ffmpeg.outPath}/bin/ffplay"'
  '';

  build-system = with python3Packages; [ setuptools ];

  dependencies = with python3Packages; [
    requests
    urllib3
    psutil
    pyradios_1-0-2
    zenlog
    requests-cache
    rich
    pick
  ];

  meta = {
    description = "Play any radios from around the globe right from the terminal";
    homepage = "https://www.radio-browser.info/";
    changelog = "https://github.com/deep5050/radio-active/releases/tag/v${version}";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ S0AndS0 ];
  };
}