Hi,
So I’m trying to learn how to make my own packages in Nix. There’s still lots of magic that I don’t understand, but I’ve pieced this together after a lot of trial and error when reading the youtube-dl package:
{ stdenv, lib, pkgs
, python3Packages
, fetchPypi
, opusSupport ? true
, vorbisSupport ? true
, flacSupport ? true
, lameSupport ? false
, faad2Support ? false
, imageMagickSupport ? false
, makeWrapper }:
# buildPythonPackage rec {
python3Packages.buildPythonApplication rec {
pname = "CherryMusic";
version = "0.41.1";
src = fetchPypi {
inherit pname version;
sha256 = "bbd826c05919b76bc72ecd892ff07557ca7b8fa5df240750518d3ada3ff5f843";
};
doCheck = false;
nativeBuildInputs = [ makeWrapper ];
propagatedBuildInputs = with python3Packages; [ cherrypy unidecode ];
makeWrapperArgs = let
packagesToBinPath = with pkgs;
[]
++ lib.optional opusSupport lame
++ lib.optional vorbisSupport vorbis-tools
++ lib.optional lameSupport lame
++ lib.optional flacSupport flac
++ lib.optional faad2Support faad2
++ lib.optional imageMagickSupport imagemagick_light;
in [ ''--prefix PATH : "${lib.makeBinPath packagesToBinPath}"'' ];
meta = with stdenv.lib; {
description = "Stream your own music collection to all your devices! The easy to use free and open-source music streaming server.";
longDescription = ''
CherryMusic is a music streaming server based on CherryPy and jPlayer. It
plays the music inside your PC, smartphone, tablet, toaster or whatever
device has a HTML5 compliant browser installed.
'';
homepage = http://www.fomori.org/cherrymusic;
downloadPage = https://github.com/devsnd/cherrymusic;
license = licenses.gpl3;
maintainers = [ maintainers.monotux ];
platforms = platforms.all;
};
}
So…it builds, but doesn’t run:
./result/bin/cherrymusic
Traceback (most recent call last):
File "/nix/store/yb1q870pr0ss6rfll90zapa624k867v1-CherryMusic-0.41.1/bin/.cherrymusic-wrapped", line 34, in <module>
import cherrymusicserver
File "/nix/store/yb1q870pr0ss6rfll90zapa624k867v1-CherryMusic-0.41.1/lib/python3.7/site-packages/cherrymusicserver/__init__.py", line 64, in <module>
gettext.install('default', localedir=pathprovider.getResourcePath('res/i18n'))
File "/nix/store/yb1q870pr0ss6rfll90zapa624k867v1-CherryMusic-0.41.1/lib/python3.7/site-packages/cherrymusicserver/pathprovider.py", line 166, in getResourcePath
"Couldn't locate {path!r} in any {res!r}!".format(path=path, res=RESOURCE_PATHS)
cherrymusicserver.pathprovider.ResourceNotFound: "Couldn't locate 'res/i18n' in any ['/nix/store/yv4pzx3lxk3lscq0pw3hqzs7k4x76xsm-python3-3.7.2/share/cherrymusic', '/nix/store/yv4pzx3lxk3lscq0pw3hqzs7k4x76xsm-python3-3.7.2/local/share/cherrymusic', '/nix/store/yb1q870pr0ss6rfll90zapa624k867v1-CherryMusic-0.41.1/lib/python3.7/site-packages', '/home/oscar/.local/share/cherrymusic']!"
If I look in the relevant folder, the files are there:
ls result/share/cherrymusic/res/i18n/
cherrymusic.pot de es __pycache__ update_translations.py
…so what is going on here?
And I’d love some other critique on my current attempt. Next step is to create a service for this package as well.