From 510d65c38d81f7fe9faa4576069d8232296b6fb4 Mon Sep 17 00:00:00 2001 From: RealStickman Date: Thu, 4 May 2023 20:21:57 +0200 Subject: [PATCH] Add info about broken derivations and how to fix them --- pages/02.linux/guides/nixos/default.en.md | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pages/02.linux/guides/nixos/default.en.md b/pages/02.linux/guides/nixos/default.en.md index cf553a4..3a7d07e 100644 --- a/pages/02.linux/guides/nixos/default.en.md +++ b/pages/02.linux/guides/nixos/default.en.md @@ -346,6 +346,32 @@ nix-env --delete-generations (gen1) (gen2) # generation gen1 and gen2 nix-env --delete-generations 7d # older than 7 days ``` +### "Fixing?" errors about derivations + +While trying to rebuild NixOS in a test VM I made, I ran across the following errors: + +``` +unpacking channels... +this derivation will be built: + /nix/store/xzmcf9zqnk3jlkdk7z80y9f1xwjlh89k-nixos-rebuild.drv +error: getting status of '/nix/store/a9ndjg0b1ivi0av9m93vfkrndp7fqbw1-strip.sh': No such file or directory +building Nix... +error: opening file '/nix/store/6igxs6xrl07pfh7l2lcls4z43b61xpn3-patchelf-0.15.0.drv': No such file or directory +``` + +Nix seemed to still point to some older paths for some reason. +After some scouring the web, I finally found a post that helped me. + +> [File in nix store empty, unable to be repaired](https://discourse.nixos.org/t/file-in-nix-store-empty-unable-to-be-repaired/14497) + +From this post I got the following command + +```sh +nix-store --verify --check-contents --repair +``` + +Running the command only once did not resolve all errors, so I just ran it multiple times until it didn't output any errors anymore. + ## Automatisms Automatic upgrades