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