{"repo":"indiscipline/nix-db-repair","free":true,"listed":false,"github":"https://github.com/indiscipline/nix-db-repair","clone":"git clone https://github.com/indiscipline/nix-db-repair.git","description":"Automatically fix Nix/NixOS error `SQLite statement 'delete from ValidPaths where path = *;': constraint failed`","language":"Shell","stars":14,"topics":["database","nix","nixos","script","sqlite"],"license":"GPL-3.0","category":"databases-storage","readme_excerpt":"nix-db-repair error: executing SQLite statement 'delete from ValidPaths where path = '/nix/store/0ab7xhlvwpyl01xp9m19ddij9rsvw0cy-hello-1.0.0.drv';': constraint failed (in '/nix/var/nix/db/db.sqlite') 2218. It happened. Even though the issue's closed. You gotta fix it and reinstalling from the config is not an option. You run nix-store --gc , and get the error. Easy fix, you enter nix-shell -p sqlite and follow the steps. You restart the GC and get the same error for another derivation... Maybe this will be the last one! After a while you start questioning if you chose the right career/hobby. Usage Make sure bash , sqlite3 and sed are accessibly from your environment. DB PATH is usually /nix/var/nix/db/db.sqlite [!WARNING] Make a backup of your database first! sqlite3 DB PATH \".backup 'nix-store-db.sqlite'\" nix-db-cleanup.sh Perform database fixing operations for a single hash: nix-db-repair.sh Repair all ValidPaths errors iteratively: This repeatedly runs the nix-store --gc command by default and invokes nix-db-cleanup.sh on errors. Change the nix command at line #21 to an operation giving you the trouble. Disclaimer Shellcheck is ok with this, but think for yourself. No guarantees! License nix-db-repair licensed under GNU General Public License version 3.0 or later","default_branch":null,"files":null,"tree":[],"storefront":"/r/indiscipline","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/indiscipline/nix-db-repair/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}