···214214215215You can rely on applications depending on the library setting the necessary environment variables but that is often easy to miss. Instead we recommend to patch the paths in the source code whenever possible. Here are some examples:216216217217-- []{#ssec-gnome-common-issues-unwrappable-package-gnome-shell-ext} [Replacing a `GI_TYPELIB_PATH` in GNOME Shell extension](https://github.com/NixOS/nixpkgs/blob/7bb8f05f12ca3cff9da72b56caa2f7472d5732bc/pkgs/desktops/gnome-3/core/gnome-shell-extensions/default.nix#L21-L24) – we are using `substituteAll` to include the path to a typelib into a patch.217217+- []{#ssec-gnome-common-issues-unwrappable-package-gnome-shell-ext} [Replacing a `GI_TYPELIB_PATH` in GNOME Shell extension](https://github.com/NixOS/nixpkgs/blob/e981466fbb08e6231a1377539ff17fbba3270fda/pkgs/by-name/gn/gnome-shell-extensions/package.nix#L25-L32) – we are using `replaceVars` to include the path to a typelib into a patch.218218219219- []{#ssec-gnome-common-issues-unwrappable-package-gsettings} The following examples are hardcoding GSettings schema paths. To get the schema paths we use the functions220220···222222223223 * `glib.makeSchemaPath` Takes a package output like `$out` and a derivation name. You should use this if the schemas you need to hardcode are in the same derivation.224224225225- []{#ssec-gnome-common-issues-unwrappable-package-gsettings-vala} [Hard-coding GSettings schema path in Vala plug-in (dynamically loaded library)](https://github.com/NixOS/nixpkgs/blob/7bb8f05f12ca3cff9da72b56caa2f7472d5732bc/pkgs/desktops/pantheon/apps/elementary-files/default.nix#L78-L86) – here, `substituteAll` cannot be used since the schema comes from the same package preventing us from pass its path to the function, probably due to a [Nix bug](https://github.com/NixOS/nix/issues/1846).225225+ []{#ssec-gnome-common-issues-unwrappable-package-gsettings-vala} [Hard-coding GSettings schema path in Vala plug-in (dynamically loaded library)](https://github.com/NixOS/nixpkgs/blob/7bb8f05f12ca3cff9da72b56caa2f7472d5732bc/pkgs/desktops/pantheon/apps/elementary-files/default.nix#L78-L86) – here, `replaceVars` cannot be used since the schema comes from the same package preventing us from pass its path to the function, probably due to a [Nix bug](https://github.com/NixOS/nix/issues/1846).226226227227 []{#ssec-gnome-common-issues-unwrappable-package-gsettings-c} [Hard-coding GSettings schema path in C library](https://github.com/NixOS/nixpkgs/blob/29c120c065d03b000224872251bed93932d42412/pkgs/development/libraries/glib-networking/default.nix#L31-L34) – nothing special other than using [Coccinelle patch](https://github.com/NixOS/nixpkgs/pull/67957#issuecomment-527717467) to generate the patch itself.228228
+32-29
doc/packages/build-support.md
···3030```3131:::32323333-## `pkgs.substituteAll` {#pkgs-substituteall}3333+## `pkgs.replaceVars` {#pkgs-replacevars}34343535-`pkgs.substituteAll` substitutes all instances of `@varName@` (`@`s included) in file `src` with the value of the corresponding environment variable.3636-As this uses the [`substituteAll`] (#fun-substitute) function, its limitations regarding variable names that will or will not be replaced also apply here.3535+`pkgs.replaceVars <src> <replacements>` replaces all instances of `@varName@` (`@`s included) in file `src` with the respective value in the attribute set `replacements`.37363838-:::{.example #ex-pkgs-substituteAll}3939-# Usage of `pkgs.substituteAll`3737+:::{.example #ex-pkgs-replace-vars}3838+# Usage of `pkgs.replaceVars`40394140If `say-goodbye.sh` contains the following:4241···50515152```nix5253{5353- substituteAll,5454+ replaceVars,5455 bash,5556 hello,5657}:5757-substituteAll {5858- src = ./say-goodbye.sh;5959- env = {6060- inherit bash hello;6161- greeting = "goodbye";6262- };5858+replaceVars ./say-goodbye.sh {5959+ inherit bash hello;6060+ greeting = "goodbye";6161+ unchanged = null;6362}6463```6564···6972echo @unchanged@7073/nix/store/566f5isbvw014h7knmzmxa5l6hshx43k-hello-2.12.1/bin/hello --greeting goodbye7174```7575+7676+Note that, in contrast to the old `substituteAll`, `unchanged = null` must explicitly be set.7777+Any unreferenced `@...@` pattern in the source file will throw an error.7278:::73797474-## `pkgs.substituteAllFiles` {#pkgs-substituteallfiles}8080+## `pkgs.replaceVarsWith` {#pkgs-replacevarswith}75817676-`pkgs.substituteAllFiles` replaces `@varName@` with the value of the environment variable `varName`.7777-It expects `src` to be a directory and requires a `files` argument that specifies which files will be subject to replacements; only these files will be placed in `$out`.8282+`pkgs.replaceVarsWith` works the same way as [pkgs.replaceVars](#pkgs-replacevars), but additionally allows more options.78837979-As it also uses the `substituteAll` function, it is subject to the same limitations on environment variables as discussed in [pkgs.substituteAll](#pkgs-substituteall).8484+:::{.example #ex-pkgs-replace-vars-with}8585+# Usage of `pkgs.replaceVarsWith`80868181-:::{.example #ex-pkgs-substitute-all-files}8282-# Usage of `pkgs.substituteAllFiles`8383-8484-If the current directory contains `{foo,bar,baz}.txt` and the following `default.nix`8787+With the example file `say-goodbye.sh`, consider:85888689```nix8787-{ substituteAllFiles }:8888-substituteAllFiles {8989- src = ./.;9090- files = [9191- "foo.txt"9292- "bar.txt"9393- ];9494- hello = "there";9090+{ replaceVarsWith }:9191+replaceVarsWith {9292+ src = ./say-goodbye.sh;9393+9494+ replacements = {9595+ inherit bash hello;9696+ greeting = "goodbye";9797+ unchanged = null;9898+ };9999+100100+ name = "say-goodbye";101101+ dir = "bin";102102+ isExecutable = true;103103+ meta.mainProgram = "say-goodbye";95104}96105```971069898-in the resulting derivation, every instance of `@hello@` will be replaced with `there` in `$out/foo.txt` and `$out/bar.txt`; `baz.txt` will not be processed nor will it appear in `$out`.107107+This will make the resulting file executable, put it in `bin/say-goodbye` and set `meta` attributes respectively.99108:::
···115115116116- All support for 32‐bit Darwin systems has been dropped.117117118118+- `substituteAll` and `substituteAllFiles` have been deprecated in favor of `replaceVars` and will be removed in the next release.119119+118120- Default ICU version updated from 74 to 76119121120122- Apache Kafka was updated to `>= 4.0.0`. Please note that this is the first release which operates
···14141515stdenv.mkDerivation (finalAttrs: {1616 pname = "openimagedenoise";1717- version = "2.3.2";1717+ version = "2.3.3";18181919 # The release tarballs include pretrained weights, which would otherwise need to be fetched with git-lfs2020 src = fetchzip {2121 url = "https://github.com/RenderKit/oidn/releases/download/v${finalAttrs.version}/oidn-${finalAttrs.version}.src.tar.gz";2222- sha256 = "sha256-yTa6U/1idfidbfNTQ7mXcroe7M4eM7Frxi45A/7e2A8=";2222+ sha256 = "sha256-JzAd47fYGLT6DeOep8Wag29VY9HOTpqf0OSv1v0kGQU=";2323 };24242525 patches = lib.optional cudaSupport ./cuda.patch;
···2626 qt6,2727 tbb_2021_11,2828 tracy,2929- substituteAll,2929+ replaceVars,3030 python3,3131}:3232let···9494 patches = [9595 # These are for Nix compatibility {{{9696 ./patches/use-find-package.patch # Replace some vendored dependencies with Nix provided versions9797- (substituteAll {9797+ (replaceVars ./patches/skip-git-versioning.patch {9898 # Skip tagging build with git version, and substitute it with the src revision (still uses current year timestamp)9999- src = ./patches/skip-git-versioning.patch;10099 rev = finalAttrs.src.rev;101100 })102101 # Prevents using some Qt scripts that seemed to break the install step. Fixes missing link to some targets.
···2727 gst_all_1,2828 libgudev,2929 umockdev,3030- substituteAll,3030+ replaceVars,3131 enableGeoLocation ? true,3232 enableSystemd ? true,3333}:···5151 patches = [5252 # The icon validator copied from Flatpak needs to access the gdk-pixbuf loaders5353 # in the Nix store and cannot bind FHS paths since those are not available on NixOS.5454- (substituteAll {5555- src = ./fix-icon-validation.patch;5454+ (replaceVars ./fix-icon-validation.patch {5655 inherit (builtins) storeDir;5756 })58575958 # Same for the sound validator, except the gdk-pixbuf part.6060- (substituteAll {6161- src = ./fix-sound-validation.patch;5959+ (replaceVars ./fix-sound-validation.patch {6260 inherit (builtins) storeDir;6361 })6462
···16161717buildPythonPackage rec {1818 pname = "textual-serve";1919- version = "1.1.1";1919+ version = "1.1.2";2020 pyproject = true;21212222 # No tags on GitHub2323 src = fetchPypi {2424 pname = "textual_serve";2525 inherit version;2626- hash = "sha256-ccZiRyxGLl42je/GYO5ujq47/aiMpAwFDFVHRobrDFQ=";2626+ hash = "sha256-DMr5ud+cCNSy16CIfK0yciQ7qH9oGSw2T0vtW2g+S9Q=";2727 };28282929 build-system = [
+2-3
pkgs/development/rocm-modules/6/llvm/default.nix
···1515 zlib,1616 gcc-unwrapped,1717 glibc,1818- substituteAll,1818+ replaceVars,1919 libffi,2020 libxml2,2121 removeReferencesTo,···319319 })320320 # FIXME: Needed due to https://github.com/NixOS/nixpkgs/issues/375431321321 # Once we can switch to overrideScope this can be removed322322- (substituteAll {323323- src = ./../../../compilers/llvm/common/clang/clang-at-least-16-LLVMgold-path.patch;322322+ (replaceVars ./../../../compilers/llvm/common/clang/clang-at-least-16-LLVMgold-path.patch {324323 libllvmLibdir = "${llvm.lib}/lib";325324 })326325 ];