···20, runtimeShell
21, systemLocale ? config.i18n.defaultLocale or "en_US"
22, patchelfUnstable # have to use patchelfUnstable to support --no-clobber-old-sections
023}:
2425let
···57 source = lib.findFirst (sourceMatches mozLocale) defaultSource sources;
5859 pname = "firefox-${channel}-bin-unwrapped";
0000000000000060in
6162stdenv.mkDerivation {
···6465 src = fetchurl { inherit (source) url sha256; };
6667+ nativeBuildInputs = [ wrapGAppsHook autoPatchelfHook patchelfUnstable ];
68 buildInputs = [
69 gtk3
70 adwaita-icon-theme
···80 appendRunpaths = [
81 "${pipewire.lib}/lib"
82 ];
83+ # Firefox uses "relrhack" to manually process relocations from a fixed offset
84+ patchelfFlags = [ "--no-clobber-old-sections" ];
8586 installPhase =
87 ''
+14-6
pkgs/build-support/setup-hooks/auto-patchelf.py
···174 found: bool = False # Whether it was found somewhere
175176177-def auto_patchelf_file(path: Path, runtime_deps: list[Path], append_rpaths: List[Path] = []) -> list[Dependency]:
178 try:
179 with open_elf(path) as elf:
180···213 if file_is_dynamic_executable:
214 print("setting interpreter of", path)
215 subprocess.run(
216- ["patchelf", "--set-interpreter", interpreter_path.as_posix(), path.as_posix()],
217 check=True)
218 rpath += runtime_deps
219···250 if rpath:
251 print("setting RPATH to:", rpath_str)
252 subprocess.run(
253- ["patchelf", "--set-rpath", rpath_str, path.as_posix()],
254 check=True)
255256 return dependencies
···262 runtime_deps: List[Path],
263 recursive: bool = True,
264 ignore_missing: List[str] = [],
265- append_rpaths: List[Path] = []) -> None:
0266267 if not paths_to_patch:
268 sys.exit("No paths to patch, stopping.")
···275 dependencies = []
276 for path in chain.from_iterable(glob(p, '*', recursive) for p in paths_to_patch):
277 if not path.is_symlink() and path.is_file():
278- dependencies += auto_patchelf_file(path, runtime_deps, append_rpaths)
279280 missing = [dep for dep in dependencies if not dep.found]
281···333 type=Path,
334 help="Paths to append to all runtime paths unconditionally",
335 )
000000336337 print("automatically fixing dependencies for ELF files")
338 args = parser.parse_args()
···344 args.runtime_dependencies,
345 args.recursive,
346 args.ignore_missing,
347- append_rpaths=args.append_rpaths)
0348349350interpreter_path: Path = None # type: ignore
···174 found: bool = False # Whether it was found somewhere
175176177+def auto_patchelf_file(path: Path, runtime_deps: list[Path], append_rpaths: List[Path] = [], extra_args: List[str] = []) -> list[Dependency]:
178 try:
179 with open_elf(path) as elf:
180···213 if file_is_dynamic_executable:
214 print("setting interpreter of", path)
215 subprocess.run(
216+ ["patchelf", "--set-interpreter", interpreter_path.as_posix(), path.as_posix()] + extra_args,
217 check=True)
218 rpath += runtime_deps
219···250 if rpath:
251 print("setting RPATH to:", rpath_str)
252 subprocess.run(
253+ ["patchelf", "--set-rpath", rpath_str, path.as_posix()] + extra_args,
254 check=True)
255256 return dependencies
···262 runtime_deps: List[Path],
263 recursive: bool = True,
264 ignore_missing: List[str] = [],
265+ append_rpaths: List[Path] = [],
266+ extra_args: List[str] = []) -> None:
267268 if not paths_to_patch:
269 sys.exit("No paths to patch, stopping.")
···276 dependencies = []
277 for path in chain.from_iterable(glob(p, '*', recursive) for p in paths_to_patch):
278 if not path.is_symlink() and path.is_file():
279+ dependencies += auto_patchelf_file(path, runtime_deps, append_rpaths, extra_args)
280281 missing = [dep for dep in dependencies if not dep.found]
282···334 type=Path,
335 help="Paths to append to all runtime paths unconditionally",
336 )
337+ parser.add_argument(
338+ "--extra-args",
339+ nargs="*",
340+ type=str,
341+ help="Extra arguments to pass to patchelf"
342+ )
343344 print("automatically fixing dependencies for ELF files")
345 args = parser.parse_args()
···351 args.runtime_dependencies,
352 args.recursive,
353 args.ignore_missing,
354+ append_rpaths=args.append_rpaths,
355+ extra_args=args.extra_args)
356357358interpreter_path: Path = None # type: ignore
+3-1
pkgs/build-support/setup-hooks/auto-patchelf.sh
···6364 local appendRunpathsArray=($appendRunpaths)
65 local runtimeDependenciesArray=($runtimeDependencies)
066 @pythonInterpreter@ @autoPatchelfScript@ \
67 ${norecurse:+--no-recurse} \
68 --ignore-missing "${ignoreMissingDepsArray[@]}" \
···70 --libs "${autoPatchelfLibs[@]}" \
71 "${extraAutoPatchelfLibs[@]}" \
72 --runtime-dependencies "${runtimeDependenciesArray[@]/%//lib}" \
73- --append-rpaths "${appendRunpathsArray[@]}"
074}
7576# XXX: This should ultimately use fixupOutputHooks but we currently don't have
···6364 local appendRunpathsArray=($appendRunpaths)
65 local runtimeDependenciesArray=($runtimeDependencies)
66+ local patchelfFlagsArray=($patchelfFlags)
67 @pythonInterpreter@ @autoPatchelfScript@ \
68 ${norecurse:+--no-recurse} \
69 --ignore-missing "${ignoreMissingDepsArray[@]}" \
···71 --libs "${autoPatchelfLibs[@]}" \
72 "${extraAutoPatchelfLibs[@]}" \
73 --runtime-dependencies "${runtimeDependenciesArray[@]/%//lib}" \
74+ --append-rpaths "${appendRunpathsArray[@]}" \
75+ --extra-args "${patchelfFlagsArray[@]}"
76}
7778# XXX: This should ultimately use fixupOutputHooks but we currently don't have