diff --git a/pkgs/by-name/li/lirc/package.nix b/pkgs/by-name/li/lirc/package.nix index 730b003723a3..8804bc81cf74 100644 --- a/pkgs/by-name/li/lirc/package.nix +++ b/pkgs/by-name/li/lirc/package.nix @@ -51,24 +51,21 @@ stdenv.mkDerivation (finalAttrs: { # --with-systemdsystemunitdir # https://sourceforge.net/p/lirc/tickets/385/ ./ubuntu.diff + + # fix overriding PYTHONPATH + ./pythonpath.patch ]; postPatch = '' patchShebangs . - # fix overriding PYTHONPATH - sed -i 's,^PYTHONPATH *= *,PYTHONPATH := $(PYTHONPATH):,' \ - Makefile.in - sed -i 's,PYTHONPATH=,PYTHONPATH=$(PYTHONPATH):,' \ - doc/Makefile.in - # Pull fix for new pyyaml pending upstream inclusion # https://sourceforge.net/p/lirc/git/merge-requests/39/ - substituteInPlace python-pkg/lirc/database.py --replace 'yaml.load(' 'yaml.safe_load(' + substituteInPlace python-pkg/lirc/database.py \ + --replace-fail 'yaml.load(' 'yaml.safe_load(' - # cant import '/build/lirc-0.10.1/python-pkg/lirc/_client.so' while cross-compiling to check the version - substituteInPlace python-pkg/setup.py \ - --replace "VERSION='0.0.0'" "VERSION='${finalAttrs.version}'" + substituteInPlace systemd/*.service \ + --replace-fail "ExecStart=/usr/" "ExecStart=''${!outputBin}/" ''; preConfigure = '' @@ -112,6 +109,30 @@ stdenv.mkDerivation (finalAttrs: { "localstatedir=$TMPDIR" ]; + outputs = [ + "out" + "man" + "doc" + "dev" + # This is the output referenced by dependent packages most of the time. + # $out on the other hand contains files used by direct users of lirc - + # systemd units, binaries, shell scripts & lirc python package. Since + # Nixpkgs' stdenv puts by default python libraries in $lib, this causes a + # cyclic reference between $out and $lib. We solve this by moving the + # Python library to $out in postFixup below. Since the Python library is + # also strongly related to the direct usage of lirc (and not only linking + # to the libraries of it), this makes sense anyway. + "lib" + ]; + + postFixup = '' + moveToOutput "${python3.sitePackages}" "$out" + # $out/bin/lirc-setup is symlinked to $lib/''${python3.sitePackages}, so it + # has to be fixed due to the above. + rm $out/bin/lirc-setup + ln -s $out/${python3.sitePackages}/lirc-setup/lirc-setup $out/bin/lirc-setup + ''; + # Upstream ships broken symlinks in docs dontCheckForBrokenSymlinks = true; diff --git a/pkgs/by-name/li/lirc/pythonpath.patch b/pkgs/by-name/li/lirc/pythonpath.patch new file mode 100644 index 000000000000..53605962ecaa --- /dev/null +++ b/pkgs/by-name/li/lirc/pythonpath.patch @@ -0,0 +1,13 @@ +diff --git i/Makefile.in w/Makefile.in +index d039ed3e9d6a..c40e6eac56ae 100644 +--- i/Makefile.in ++++ w/Makefile.in +@@ -493,7 +493,7 @@ AUTOMAKE_OPTIONS = 1.5 check-news dist-bzip2 -Wno-portability \ + + PYTHONPATH1 = $(abs_top_srcdir)/python-pkg/lirc: + PYTHONPATH2 = $(abs_top_srcdir)/python-pkg/lirc/lib/.libs +-PYTHONPATH = $(PYTHONPATH1):$(PYTHONPATH2) ++PYTHONPATH := $(PYTHONPATH):$(PYTHONPATH1):$(PYTHONPATH2) + PYLINT = python3-pylint + pylint_template = {path}:{line}: [{msg_id}({symbol}), {obj}] {msg} + GIT_COMMIT = $(shell git log -1 --pretty=format:%h || echo UNKNOWN)