about summary refs log tree commit diff
path: root/doc
diff options
context:
space:
mode:
authorSophie Tauchert <sophie@999eagle.moe>2023-12-06 09:44:17 +0100
committerEmery Hemingway <ehmry@posteo.net>2023-12-10 09:10:02 +0000
commit3b40e1bd33b442bb705f88a2bada2f6ace51e607 (patch)
tree844e393fa95a7f5a09c299e9c9b7ce4d932504c7 /doc
parentdb3bd72ed27a5b2b96c3e6cca463117d27bb052b (diff)
downloadnixlib-3b40e1bd33b442bb705f88a2bada2f6ace51e607.tar
nixlib-3b40e1bd33b442bb705f88a2bada2f6ace51e607.tar.gz
nixlib-3b40e1bd33b442bb705f88a2bada2f6ace51e607.tar.bz2
nixlib-3b40e1bd33b442bb705f88a2bada2f6ace51e607.tar.lz
nixlib-3b40e1bd33b442bb705f88a2bada2f6ace51e607.tar.xz
nixlib-3b40e1bd33b442bb705f88a2bada2f6ace51e607.tar.zst
nixlib-3b40e1bd33b442bb705f88a2bada2f6ace51e607.zip
buildNimPackage: allow overriding nim package args
Without this, it's impossible to override the lockFile as the default
overrideAttrs is applied after the composition in buildNimPackage has
read the lock file and generated the nim flags from it.
Diffstat (limited to 'doc')
-rw-r--r--doc/languages-frameworks/nim.section.md17
1 files changed, 15 insertions, 2 deletions
diff --git a/doc/languages-frameworks/nim.section.md b/doc/languages-frameworks/nim.section.md
index 45cd07b3a3d8..c6ebf49b83f6 100644
--- a/doc/languages-frameworks/nim.section.md
+++ b/doc/languages-frameworks/nim.section.md
@@ -50,7 +50,20 @@ $ nix build -f . ttop.src
 $ nix run -f . nim_lk ./result | jq --sort-keys > pkgs/by-name/tt/ttop/lock.json
 ```
 
-## Lockfile dependency overrides {#nimoverrides}
+## Overriding Nim packages {#nim-overrides}
+
+The `buildNimPackage` function generates flags and additional build dependencies from the `lockFile` parameter passed to `buildNimPackage`. Using [`overrideAttrs`](#sec-pkg-overrideAttrs) on the final package will apply after this has already been generated, so this can't be used to override the `lockFile` in a package built with `buildNimPackage`. To be able to override parameters before flags and build dependencies are generated from the `lockFile`, use `overrideNimAttrs` instead with the same syntax as `overrideAttrs`:
+
+```nix
+pkgs.nitter.overrideNimAttrs {
+  # using a different source which has different dependencies from the standard package
+  src = pkgs.fetchFromGithub { /* … */ };
+  # new lock file generated from the source
+  lockFile = ./custom-lock.json;
+}
+```
+
+## Lockfile dependency overrides {#nim-lock-overrides}
 
 The `buildNimPackage` function matches the libraries specified by `lockFile` to attrset of override functions that are then applied to the package derivation.
 The default overrides are maintained as the top-level `nimOverrides` attrset at `pkgs/top-level/nim-overrides.nix`.
@@ -81,7 +94,7 @@ The annotations in the `nim-overrides.nix` set are functions that take three arg
 - finalAttrs: the final attrset passed by `buildNimPackage` to `stdenv.mkDerivation`.
 - prevAttrs: the attrset produced by initial arguments to `buildNimPackage` and any preceding lockfile overlays.
 
-### Overriding an Nim library override {#nimoverrides-overrides}
+### Overriding an Nim library override {#nim-lock-overrides-overrides}
 
 The `nimOverrides` attrset makes it possible to modify overrides in a few different ways.