about summary refs log tree commit diff
diff options
context:
space:
mode:
-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 6cc37634ed..bdb49c7def 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 ]; }