aboutsummaryrefslogtreecommitdiff
path: root/src/nix/flake-update.md
diff options
context:
space:
mode:
authorThéophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>2023-10-31 16:19:05 +0100
committerLunaphied <lunaphied@lunaphied.me>2024-03-25 17:36:24 -0600
commit86881226b0e51c204f07385b7b57743c23e34d44 (patch)
tree737e75ee7cc6ec8932b850ff6f20adfc4e285628 /src/nix/flake-update.md
parentaa7653608d4d0028bb98af491aec76b2fea7f882 (diff)
Merge pull request #8817 from iFreilicht/flake-update-lock-overhaul
Overhaul `nix flake update` and `nix flake lock` UX (cherry picked from commit 12a0ae73dbb37becefa5a442eb4532ff0de9ce65) Change-Id: Iff3b4f4235ebb1948ec612036b39ab29e4ca22b2
Diffstat (limited to 'src/nix/flake-update.md')
-rw-r--r--src/nix/flake-update.md64
1 files changed, 44 insertions, 20 deletions
diff --git a/src/nix/flake-update.md b/src/nix/flake-update.md
index 8c6042d94..63df3b12a 100644
--- a/src/nix/flake-update.md
+++ b/src/nix/flake-update.md
@@ -2,33 +2,57 @@ R""(
# Examples
-* Recreate the lock file (i.e. update all inputs) and commit the new
- lock file:
+* Update all inputs (i.e. recreate the lock file from scratch):
```console
- # nix flake update --commit-lock-file
- * Updated 'nix': 'github:NixOS/nix/9fab14adbc3810d5cc1f88672fde1eee4358405c' -> 'github:NixOS/nix/8927cba62f5afb33b01016d5c4f7f8b7d0adde3c'
- * Updated 'nixpkgs': 'github:NixOS/nixpkgs/3d2d8f281a27d466fa54b469b5993f7dde198375' -> 'github:NixOS/nixpkgs/a3a3dda3bacf61e8a39258a0ed9c924eeca8e293'
- …
- warning: committed new revision '158bcbd9d6cc08ab859c0810186c1beebc982aad'
+ # nix flake update
+ warning: updating lock file '/home/myself/repos/testflake/flake.lock':
+ • Updated input 'nix':
+ 'github:NixOS/nix/9fab14adbc3810d5cc1f88672fde1eee4358405c' (2023-06-28)
+ → 'github:NixOS/nix/8927cba62f5afb33b01016d5c4f7f8b7d0adde3c' (2023-07-11)
+ • Updated input 'nixpkgs':
+ 'github:NixOS/nixpkgs/3d2d8f281a27d466fa54b469b5993f7dde198375' (2023-06-30)
+ → 'github:NixOS/nixpkgs/a3a3dda3bacf61e8a39258a0ed9c924eeca8e293' (2023-07-05)
```
-# Description
+* Update only a single input:
+
+ ```console
+ # nix flake update nixpkgs
+ warning: updating lock file '/home/myself/repos/testflake/flake.lock':
+ • Updated input 'nixpkgs':
+ 'github:NixOS/nixpkgs/3d2d8f281a27d466fa54b469b5993f7dde198375' (2023-06-30)
+ → 'github:NixOS/nixpkgs/a3a3dda3bacf61e8a39258a0ed9c924eeca8e293' (2023-07-05)
+ ```
+
+* Update only a single input of a flake in a different directory:
-This command recreates the lock file of a flake (`flake.lock`), thus
-updating the lock for every unlocked input (like `nixpkgs`) to its
-current version. This is equivalent to passing `--recreate-lock-file`
-to any command that operates on a flake. That is,
+ ```console
+ # nix flake update nixpkgs --flake ~/repos/another
+ warning: updating lock file '/home/myself/repos/another/flake.lock':
+ • Updated input 'nixpkgs':
+ 'github:NixOS/nixpkgs/3d2d8f281a27d466fa54b469b5993f7dde198375' (2023-06-30)
+ → 'github:NixOS/nixpkgs/a3a3dda3bacf61e8a39258a0ed9c924eeca8e293' (2023-07-05)
+ ```
+
+ > **Note**
+ >
+ > When trying to refer to a flake in a subdirectory, write `./another`
+ > instead of `another`.
+ > Otherwise Nix will try to look up the flake in the registry.
+
+# Description
-```console
-# nix flake update
-# nix build
-```
+This command updates the inputs in a lock file (`flake.lock`).
+**By default, all inputs are updated**. If the lock file doesn't exist
+yet, it will be created. If inputs are not in the lock file yet, they will be added.
-is equivalent to:
+Unlike other `nix flake` commands, `nix flake update` takes a list of names of inputs
+to update as its positional arguments and operates on the flake in the current directory.
+You can pass a different flake-url with `--flake` to override that default.
-```console
-# nix build --recreate-lock-file
-```
+The related command [`nix flake lock`](@docroot@/command-ref/new-cli/nix3-flake-lock.md)
+also creates lock files and adds missing inputs, but is safer as it
+will never update inputs already in the lock file.
)""