13 # For the update script
22 srcJson = lib.importJSON ./src.json;
23 src = fetchFromGitHub {
26 inherit (srcJson) rev sha256;
29 # Python needed to instantiate the html templates
30 buildPython = python3Packages.python.withPackages (ps: [ ps.jinja2 ]);
33 stdenv.mkDerivation rec {
34 pname = "botamusique";
35 version = srcJson.version;
39 npmDeps = fetchNpmDeps {
41 hash = srcJson.npmDepsHash;
47 # botamusique by default resolves relative state paths by first checking
48 # whether it exists in the working directory, then falls back to using the
49 # installation directory. With Nix however, the installation directory is
50 # not writable, so that won't work. So we change this so that it uses
51 # relative paths unconditionally, whether they exist or not.
52 ./unconditional-relative-state-paths.patch
54 # We can't update the package at runtime with NixOS, so this patch makes
55 # the !update command mention that
56 ./no-runtime-update.patch
58 # Fix passing of invalid "git" version into version.parse, which results
59 # in an InvalidVersion exception. The upstream fix is insufficient, so
60 # we carry the correct patch downstream for now.
61 ./catch-invalid-versions.patch
65 # However, the function that's patched above is also used for
66 # configuration.default.ini, which is in the installation directory
67 # after all. So we need to counter-patch it here so it can find it absolutely
68 substituteInPlace mumbleBot.py \
69 --replace "configuration.default.ini" "$out/share/botamusique/configuration.default.ini" \
70 --replace "version = 'git'" "version = '${version}'"
73 NODE_OPTIONS = "--openssl-legacy-provider";
78 npmHooks.npmConfigHook
79 python3Packages.wrapPython
82 pythonPath = with python3Packages; [
97 # Generates artifacts in ./static
103 # Fills out http templates
104 ${buildPython}/bin/python scripts/translate_templates.py --lang-dir lang/ --template-dir templates/
112 mkdir -p $out/share $out/bin
113 cp -r . $out/share/botamusique
114 chmod +x $out/share/botamusique/mumbleBot.py
115 wrapPythonProgramsIn $out/share/botamusique "$out $pythonPath"
117 # Convenience binary and wrap with ffmpeg dependency
118 makeWrapper $out/share/botamusique/mumbleBot.py $out/bin/botamusique \
119 --prefix PATH : ${lib.makeBinPath [ ffmpeg-headless ]}
124 passthru.updateScript = writeShellScript "botamusique-updater" ''
138 VERSION="$(curl https://api.github.com/repos/$OWNER/$REPO/releases/latest | jq -r '.tag_name')"
140 nix-prefetch-git --rev "$VERSION" --url https://github.com/$OWNER/$REPO | \
141 jq > "${toString ./src.json}" \
142 --arg version "$VERSION" \
143 '.version |= $version'
144 path="$(jq '.path' -r < "${toString ./src.json}")"
147 trap 'rm -rf "$tmp"' exit
149 npmHash="$(prefetch-npm-deps $path/web/package-lock.json)"
150 jq '. + { npmDepsHash: "'"$npmHash"'" }' < "${toString ./src.json}" > "$tmp/src.json"
151 mv "$tmp/src.json" "${toString ./src.json}"
155 inherit (nixosTests) botamusique;
159 description = "Bot to play youtube / soundcloud / radio / local music on Mumble";
160 homepage = "https://github.com/azlux/botamusique";
161 license = licenses.mit;
162 platforms = platforms.all;
164 mainProgram = "botamusique";