botamusique: init at unstable-2021-03-13
This commit is contained in:
parent
8c77085b18
commit
1638776b7b
150
pkgs/tools/audio/botamusique/default.nix
Normal file
150
pkgs/tools/audio/botamusique/default.nix
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
{ pkgs
|
||||||
|
, lib
|
||||||
|
, stdenv
|
||||||
|
, fetchFromGitHub
|
||||||
|
, python3Packages
|
||||||
|
, ffmpeg
|
||||||
|
, makeWrapper
|
||||||
|
|
||||||
|
# For the update script
|
||||||
|
, coreutils
|
||||||
|
, nix-prefetch-git
|
||||||
|
, jq
|
||||||
|
, nodePackages
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
nodejs = pkgs.nodejs-12_x;
|
||||||
|
nodeEnv = import ../../../development/node-packages/node-env.nix {
|
||||||
|
inherit (pkgs) stdenv lib python2 runCommand writeTextFile;
|
||||||
|
inherit pkgs nodejs;
|
||||||
|
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
|
||||||
|
};
|
||||||
|
botamusiqueNodePackages = import ./node-packages.nix {
|
||||||
|
inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
|
||||||
|
inherit nodeEnv;
|
||||||
|
};
|
||||||
|
|
||||||
|
srcJson = lib.importJSON ./src.json;
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "azlux";
|
||||||
|
repo = "botamusique";
|
||||||
|
inherit (srcJson) rev sha256;
|
||||||
|
};
|
||||||
|
|
||||||
|
nodeDependencies = (botamusiqueNodePackages.shell.override (old: {
|
||||||
|
src = src + "/web";
|
||||||
|
})).nodeDependencies;
|
||||||
|
|
||||||
|
# Python needed to instantiate the html templates
|
||||||
|
buildPython = python3Packages.python.withPackages (ps: [ ps.jinja2 ]);
|
||||||
|
in
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
pname = "botamusique";
|
||||||
|
version = "unstable-${lib.substring 0 10 srcJson.date}";
|
||||||
|
|
||||||
|
inherit src;
|
||||||
|
|
||||||
|
patches = [
|
||||||
|
# botamusique by default resolves relative state paths by first checking
|
||||||
|
# whether it exists in the working directory, then falls back to using the
|
||||||
|
# installation directory. With Nix however, the installation directory is
|
||||||
|
# not writable, so that won't work. So we change this so that it uses
|
||||||
|
# relative paths unconditionally, whether they exist or not.
|
||||||
|
./unconditional-relative-state-paths.patch
|
||||||
|
|
||||||
|
# We can't update the package at runtime with NixOS, so this patch makes
|
||||||
|
# the !update command mention that
|
||||||
|
./no-runtime-update.patch
|
||||||
|
];
|
||||||
|
|
||||||
|
postPatch = ''
|
||||||
|
# However, the function that's patched above is also used for
|
||||||
|
# configuration.default.ini, which is in the installation directory
|
||||||
|
# after all. So we need to counter-patch it here so it can find it absolutely
|
||||||
|
substituteInPlace mumbleBot.py \
|
||||||
|
--replace "configuration.default.ini" "$out/share/botamusique/configuration.default.ini"
|
||||||
|
'';
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
python3Packages.wrapPython
|
||||||
|
nodejs
|
||||||
|
makeWrapper
|
||||||
|
];
|
||||||
|
|
||||||
|
pythonPath = with python3Packages; [
|
||||||
|
pymumble
|
||||||
|
packaging
|
||||||
|
magic
|
||||||
|
requests
|
||||||
|
youtube-dl
|
||||||
|
flask
|
||||||
|
mutagen
|
||||||
|
pillow
|
||||||
|
pyradios
|
||||||
|
];
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
|
||||||
|
# Generates artifacts in ./static
|
||||||
|
(
|
||||||
|
cd web
|
||||||
|
ln -s ${nodeDependencies}/lib/node_modules ./node_modules
|
||||||
|
export PATH="${nodeDependencies}/bin:$PATH"
|
||||||
|
|
||||||
|
npm run build
|
||||||
|
)
|
||||||
|
|
||||||
|
# Fills out http templates
|
||||||
|
${buildPython}/bin/python scripts/translate_templates.py --lang-dir lang/ --template-dir templates/
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
|
||||||
|
mkdir -p $out/share $out/bin
|
||||||
|
cp -r . $out/share/botamusique
|
||||||
|
chmod +x $out/share/botamusique/mumbleBot.py
|
||||||
|
wrapPythonProgramsIn $out/share/botamusique "$out $pythonPath"
|
||||||
|
|
||||||
|
# Convenience binary and wrap with ffmpeg dependency
|
||||||
|
makeWrapper $out/share/botamusique/mumbleBot.py $out/bin/botamusique \
|
||||||
|
--prefix PATH : ${lib.makeBinPath [ ffmpeg ]}
|
||||||
|
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
|
||||||
|
passthru.updateScript = pkgs.writeShellScript "botamusique-updater" ''
|
||||||
|
export PATH=${lib.makeBinPath [ coreutils nix-prefetch-git jq nodePackages.node2nix ]}
|
||||||
|
|
||||||
|
nix-prefetch-git https://github.com/azlux/botamusique > ${toString ./src.json}
|
||||||
|
path=$(jq '.path' -r < ${toString ./src.json})
|
||||||
|
|
||||||
|
tmp=$(mktemp -d)
|
||||||
|
trap 'rm -rf "$tmp"' exit
|
||||||
|
|
||||||
|
# botamusique doesn't have a version in its package.json
|
||||||
|
# But that's needed for node2nix
|
||||||
|
jq < "$path"/web/package.json > "$tmp/package.json" \
|
||||||
|
--arg version "0.0.0" \
|
||||||
|
'.version |= $version'
|
||||||
|
|
||||||
|
node2nix \
|
||||||
|
--input "$tmp"/package.json \
|
||||||
|
--lock "$path"/web/package-lock.json \
|
||||||
|
--no-copy-node-env \
|
||||||
|
--development \
|
||||||
|
--composition /dev/null \
|
||||||
|
--output ${toString ./node-packages.nix}
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "Bot to play youtube / soundcloud / radio / local music on Mumble";
|
||||||
|
homepage = "https://github.com/azlux/botamusique";
|
||||||
|
license = licenses.mit;
|
||||||
|
platforms = platforms.all;
|
||||||
|
maintainers = with maintainers; [ infinisil ];
|
||||||
|
};
|
||||||
|
}
|
12
pkgs/tools/audio/botamusique/no-runtime-update.patch
Normal file
12
pkgs/tools/audio/botamusique/no-runtime-update.patch
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
diff --git a/util.py b/util.py
|
||||||
|
index bfec1ed..5147757 100644
|
||||||
|
--- a/util.py
|
||||||
|
+++ b/util.py
|
||||||
|
@@ -132,6 +132,7 @@ def check_update(current_version):
|
||||||
|
|
||||||
|
|
||||||
|
def update(current_version):
|
||||||
|
+ return "Can't update Nix installation at runtime"
|
||||||
|
global log
|
||||||
|
|
||||||
|
target = var.config.get('bot', 'target_version')
|
5247
pkgs/tools/audio/botamusique/node-packages.nix
generated
Normal file
5247
pkgs/tools/audio/botamusique/node-packages.nix
generated
Normal file
File diff suppressed because it is too large
Load Diff
10
pkgs/tools/audio/botamusique/src.json
Normal file
10
pkgs/tools/audio/botamusique/src.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"url": "https://github.com/azlux/botamusique",
|
||||||
|
"rev": "df38c7dbd6d59c6790cf2364d1f344b7f6f72107",
|
||||||
|
"date": "2021-03-13T15:44:40+08:00",
|
||||||
|
"path": "/nix/store/30ds4gp7aldj9rqix1xf7j2ps5blrx8w-botamusique",
|
||||||
|
"sha256": "06xw1pif145zcm9z8l9kzl8ayl7vy5ywr0m3a5yswybcp2fzj087",
|
||||||
|
"fetchSubmodules": false,
|
||||||
|
"deepClone": false,
|
||||||
|
"leaveDotGit": false
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
diff --git a/util.py b/util.py
|
||||||
|
index bfec1ed..0546772 100644
|
||||||
|
--- a/util.py
|
||||||
|
+++ b/util.py
|
||||||
|
@@ -22,16 +22,7 @@ log = logging.getLogger("bot")
|
||||||
|
|
||||||
|
|
||||||
|
def solve_filepath(path):
|
||||||
|
- if not path:
|
||||||
|
- return ''
|
||||||
|
-
|
||||||
|
- if path[0] == '/':
|
||||||
|
- return path
|
||||||
|
- elif os.path.exists(path):
|
||||||
|
- return path
|
||||||
|
- else:
|
||||||
|
- mydir = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
- return mydir + '/' + path
|
||||||
|
+ return path
|
||||||
|
|
||||||
|
|
||||||
|
def get_recursive_file_list_sorted(path):
|
@ -1161,6 +1161,8 @@ in
|
|||||||
|
|
||||||
bonfire = callPackage ../tools/misc/bonfire { };
|
bonfire = callPackage ../tools/misc/bonfire { };
|
||||||
|
|
||||||
|
botamusique = callPackage ../tools/audio/botamusique { };
|
||||||
|
|
||||||
boulder = callPackage ../tools/admin/boulder { };
|
boulder = callPackage ../tools/admin/boulder { };
|
||||||
|
|
||||||
btrfs-heatmap = callPackage ../tools/filesystems/btrfs-heatmap { };
|
btrfs-heatmap = callPackage ../tools/filesystems/btrfs-heatmap { };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user