From 9fb55f492c750da2ffcfd69bd958f156fe86f2a7 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Mon, 15 Jan 2024 21:39:22 +0100 Subject: [PATCH 1/2] auto-multiple-choice: use absolute paths instead of "portable" strategy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, auto-multiple-choice from nixpkgs doesn't work on systems with /lib directory. Running auto-multiple-choice there fails with: Unknown action gui at /nix/store/n3cyw5ngp0v52rny9gr6z35vslh5d4vx-auto-multiple-choice-1.6.0/bin/.auto-multiple-choice-wrapped line 94. This happens on non-NixOS systems as well as on NixOS with e.g. nix-ldĀ [1] enabled. The reason is documented in the Nix expression and the problem is reported upstream at https://project.auto-multiple-choice.net/issues/872. However, the problem can be worked around without requiring upstream changes, as shown in this commit. We stop using the "portable distribution", which tries to detect the base directory at run time, and instead hardcode all paths as absolute at build time. [1] https://github.com/Mic92/nix-ld --- .../misc/auto-multiple-choice/default.nix | 47 +++++++++---------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/pkgs/applications/misc/auto-multiple-choice/default.nix b/pkgs/applications/misc/auto-multiple-choice/default.nix index 43aad6d5be16..4d1a80faf28f 100644 --- a/pkgs/applications/misc/auto-multiple-choice/default.nix +++ b/pkgs/applications/misc/auto-multiple-choice/default.nix @@ -37,31 +37,28 @@ stdenv.mkDerivation (finalAttrs: rec { makeFlags = [ "PERLPATH=${perl}/bin/perl" - # We *need* to pass DESTDIR, as the Makefile ignores PREFIX. - "DESTDIR=$(out)" - # Relative paths. - "BINDIR=/bin" - "PERLDIR=/share/perl5" - "MODSDIR=/lib" # At runtime, AMC will test for that dir before - # defaulting to the "portable" strategy we use, so this test - # *must* fail. *But* this variable cannot be set to anything but - # "/lib" , because that name is hardcoded in the main executable - # and this variable controls both both the path AMC will check at - # runtime, AND the path where the actual modules will be stored at - # build-time. This has been reported upstream as - # https://project.auto-multiple-choice.net/issues/872 - "TEXDIR=/tex/latex/" # what texlive.combine expects - "TEXDOCDIR=/share/doc/texmf/" # TODO where to put this? - "MAN1DIR=/share/man/man1" - "DESKTOPDIR=/share/applications" - "METAINFODIR=/share/metainfo" - "ICONSDIR=/share/auto-multiple-choice/icons" - "APPICONDIR=/share/icons/hicolor" - "LOCALEDIR=/share/locale" - "MODELSDIR=/share/auto-multiple-choice/models" - "DOCDIR=/share/doc/auto-multiple-choice" - "SHARED_MIMEINFO_DIR=/share/mime/packages" - "LANG_GTKSOURCEVIEW_DIR=/share/gtksourceview-4/language-specs" + # We *need* to set DESTDIR as empty and use absolute paths below, + # because the Makefile ignores PREFIX and MODSDIR is required to + # be an absolute path to not trigger "portable distribution" check + # in auto-multiple-choice.in. + "DESTDIR=" + # Set variables from Makefile.conf to absolute paths + "BINDIR=${placeholder "out"}/bin" + "PERLDIR=${placeholder "out"}/share/perl5" + "MODSDIR=${placeholder "out"}/lib" + "TEXDIR=${placeholder "out"}/tex/latex/" # what texlive.combine expects + "TEXDOCDIR=${placeholder "out"}/share/doc/texmf/" # TODO where to put this? + "MAN1DIR=${placeholder "out"}/share/man/man1" + "DESKTOPDIR=${placeholder "out"}/share/applications" + "METAINFODIR=${placeholder "out"}/share/metainfo" + "ICONSDIR=${placeholder "out"}/share/auto-multiple-choice/icons" + "CSSDIR=${placeholder "out"}/share/auto-multiple-choice/gtk" + "APPICONDIR=${placeholder "out"}/share/icons/hicolor" + "LOCALEDIR=${placeholder "out"}/share/locale" + "MODELSDIR=${placeholder "out"}/share/auto-multiple-choice/models" + "DOCDIR=${placeholder "out"}/share/doc/auto-multiple-choice" + "SHARED_MIMEINFO_DIR=${placeholder "out"}/share/mime/packages" + "LANG_GTKSOURCEVIEW_DIR=${placeholder "out"}/share/gtksourceview-4/language-specs" # Pretend to be redhat so `install` doesn't try to chown/chgrp. "SYSTEM_TYPE=rpm" "GCC=${stdenv.cc.targetPrefix}cc" From b94b15151a2d3c9ff8f13dad82fbd1f0d8354563 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Tue, 16 Jan 2024 21:53:55 +0100 Subject: [PATCH 2/2] auto-multiple-choice: add itself to PATH in the wrapper auto-multiple-choice (the GUI) needs to run subcommands of itself, e.g., `auto-multiple-choice prepare ...` to work correctly. Until now, for this to work, it was necessary to install auto-multiple-choice to $PATH. Running it via e.g. `nix run` was not possible. This commit changes that. It enables not only using `nix run`, but also having multiple working AMC versions installed simultaneously. --- pkgs/applications/misc/auto-multiple-choice/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/applications/misc/auto-multiple-choice/default.nix b/pkgs/applications/misc/auto-multiple-choice/default.nix index 4d1a80faf28f..80d007773769 100644 --- a/pkgs/applications/misc/auto-multiple-choice/default.nix +++ b/pkgs/applications/misc/auto-multiple-choice/default.nix @@ -90,6 +90,7 @@ stdenv.mkDerivation (finalAttrs: rec { XMLWriter ]}:"$out/share/perl5 \ --prefix XDG_DATA_DIRS : "$out/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH" \ + --prefix PATH : "$out/bin" \ --set TEXINPUTS ":.:$out/tex/latex" '';