main
 1{
 2  python3,
 3  lib,
 4  makeWrapper,
 5  installShellFiles,
 6}:
 7
 8python3.pkgs.buildPythonApplication {
 9  pname = "arr";
10  version = "1.1.0";
11  format = "other";
12
13  src = ./.;
14
15  nativeBuildInputs = [
16    makeWrapper
17    installShellFiles
18  ];
19
20  propagatedBuildInputs = with python3.pkgs; [
21    click
22    requests
23    spotipy
24  ];
25
26  # Don't try to create __pycache__ directories during build
27  dontUsePythonImportsCheck = true;
28
29  installPhase = ''
30    runHook preInstall
31
32    mkdir -p $out/bin $out/lib/arr
33
34    # Install the main CLI
35    cp arr $out/bin/arr
36    chmod +x $out/bin/arr
37
38    # Install the library
39    cp lib.py $out/lib/arr/
40
41    # Install commands
42    cp -r commands $out/lib/arr/
43
44    # Create __init__.py for the package
45    touch $out/lib/arr/__init__.py
46
47    # Wrap the main script to set PYTHONPATH
48    wrapProgram $out/bin/arr \
49      --prefix PYTHONPATH : "$out/lib/arr"
50
51    runHook postInstall
52  '';
53
54  postFixup = ''
55    # Generate shell completions using arr's built-in completion command
56    export PYTHONPATH="$out/lib/arr:$PYTHONPATH"
57    installShellCompletion --cmd arr \
58      --bash <($out/bin/arr completion bash) \
59      --fish <($out/bin/arr completion fish) \
60      --zsh <($out/bin/arr completion zsh)
61  '';
62
63  meta = {
64    description = "Unified CLI for managing *arr services (Sonarr, Radarr, Lidarr)";
65    longDescription = ''
66      arr provides a consistent interface for common operations across
67      the *arr media management stack, including renaming, retagging,
68      path updates, and Spotify playlist syncing.
69    '';
70    license = lib.licenses.mit;
71    platforms = lib.platforms.unix;
72    mainProgram = "arr";
73  };
74}