diff --git a/pkgs/build-support/setup-hooks/auto-patchelf.sh b/pkgs/build-support/setup-hooks/auto-patchelf.sh index 392163646aa8..541b7fc694d0 100644 --- a/pkgs/build-support/setup-hooks/auto-patchelf.sh +++ b/pkgs/build-support/setup-hooks/auto-patchelf.sh @@ -71,7 +71,7 @@ autoPatchelf() { fi done - @pythonInterpreter@ @autoPatchelfScript@ \ + auto-patchelf \ ${norecurse:+--no-recurse} \ --ignore-missing "${ignoreMissingDepsArray[@]}" \ --paths "$@" \ diff --git a/pkgs/build-support/setup-hooks/auto-patchelf.py b/pkgs/by-name/au/auto-patchelf/auto-patchelf.py similarity index 99% rename from pkgs/build-support/setup-hooks/auto-patchelf.py rename to pkgs/by-name/au/auto-patchelf/auto-patchelf.py index eca3007514de..938ea6310118 100644 --- a/pkgs/build-support/setup-hooks/auto-patchelf.py +++ b/pkgs/by-name/au/auto-patchelf/auto-patchelf.py @@ -425,7 +425,7 @@ interpreter_arch: str = None # type: ignore libc_lib: Path = None # type: ignore if __name__ == "__main__": - nix_support = Path(os.environ['NIX_BINTOOLS']) / 'nix-support' + nix_support = Path(os.environ.get('NIX_BINTOOLS', os.environ['DEFAULT_BINTOOLS'])) / 'nix-support' interpreter_path = Path((nix_support / 'dynamic-linker').read_text().strip()) libc_lib = Path((nix_support / 'orig-libc').read_text().strip()) / 'lib' diff --git a/pkgs/by-name/au/auto-patchelf/package.nix b/pkgs/by-name/au/auto-patchelf/package.nix new file mode 100644 index 000000000000..1e1880560adf --- /dev/null +++ b/pkgs/by-name/au/auto-patchelf/package.nix @@ -0,0 +1,41 @@ +{ + lib, + python3Packages, +}: + +python3Packages.buildPythonApplication { + pname = "auto-patchelf"; + version = "0-unstable-2024-08-14"; + pyproject = false; + + src = lib.fileset.toSource { + root = ./.; + fileset = lib.fileset.unions [ + ./auto-patchelf.py + ]; + }; + + dependencies = with python3Packages; [ + pyelftools + ]; + + installPhase = '' + runHook preInstall + + install -Dm755 auto-patchelf.py $out/bin/auto-patchelf + + runHook postInstall + ''; + + makeWrapperArgs = [ + "--set DEFAULT_BINTOOLS $NIX_BINTOOLS" + ]; + + meta = { + description = "Automatically patch ELF binaries using patchelf"; + mainProgram = "auto-patchelf"; + license = lib.licenses.mit; + platforms = lib.platforms.unix; + maintainers = with lib.maintainers; [ Scrumplex ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 4374c589db4c..cdd01a4d0470 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -185,11 +185,7 @@ with pkgs; autoPatchelfHook = makeSetupHook { name = "auto-patchelf-hook"; - propagatedBuildInputs = [ bintools ]; - substitutions = { - pythonInterpreter = "${python3.withPackages (ps: [ ps.pyelftools ])}/bin/python"; - autoPatchelfScript = ../build-support/setup-hooks/auto-patchelf.py; - }; + propagatedBuildInputs = [ auto-patchelf bintools ]; } ../build-support/setup-hooks/auto-patchelf.sh; appflowy = callPackage ../applications/office/appflowy { };