about summary refs log tree commit diff
path: root/nix/nix-1p/README.md
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-11-14T12·53+0300
committerVincent Ambo <mail@tazj.in>2021-11-14T13·28+0300
commita9a1a4645814053935976406e25b5e4c43f60a02 (patch)
tree6457d31c5281ce133aab80448abe3655c605c6ca /nix/nix-1p/README.md
parent2a098e081b92ce20d320a3bc3491594984d26450 (diff)
Note recommended use of 'or' in override patterns
This fixes #6
Diffstat (limited to 'nix/nix-1p/README.md')
-rw-r--r--nix/nix-1p/README.md11
1 files changed, 9 insertions, 2 deletions
diff --git a/nix/nix-1p/README.md b/nix/nix-1p/README.md
index 6cc37634ed3d..bdb49c7defe7 100644
--- a/nix/nix-1p/README.md
+++ b/nix/nix-1p/README.md
@@ -549,7 +549,7 @@ like this:
 
 ```nix
 someProgram.overrideAttrs(old: {
-    configureFlags = old.configureFlags ++ ["--mimic-threaten-tag"];
+    configureFlags = old.configureFlags or [] ++ ["--mimic-threaten-tag"];
 })
 ```
 
@@ -557,6 +557,13 @@ This pattern has a variety of applications of varying complexity. The top-level
 package set itself can have an `overlays` argument passed to it which may add
 new packages to the imported set.
 
+Note the use of the `or` operator to default to an empty list if the
+original flags do not include `configureFlags`. This is required in
+case a package does not set any flags by itself.
+
+Since this can change in a package over time, it is useful to guard
+against it using `or`.
+
 For a slightly more advanced example, assume that we want to import `<nixpkgs>`
 but have the modification above be reflected in the imported package set:
 
@@ -564,7 +571,7 @@ but have the modification above be reflected in the imported package set:
 let
   overlay = (self: super: {
     someProgram = super.someProgram.overrideAttrs(old: {
-      configureFlags = old.configureFlags ++ ["--mimic-threaten-tag"];
+      configureFlags = old.configureFlags or [] ++ ["--mimic-threaten-tag"];
     });
   });
 in import <nixpkgs> { overlays = [ overlay ]; }