]> git.scottworley.com Git - nix-pin-deps/blobdiff - nix_pin_deps.py
nix show-derivation → nix derivation show
[nix-pin-deps] / nix_pin_deps.py
index 30aef6d144d4b73d074658768e094579f23916fa..0b83d5c189fed1198cd4abc67725e4f6c7b57e13 100644 (file)
@@ -1,3 +1,10 @@
+# nix-pin-deps: gc-pin dependencies of a partially-built derivation
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, version 3.
+
+
 from contextlib import contextmanager
 import json
 import os
@@ -52,7 +59,7 @@ def getDrvInfo(drv: str) -> Any:
     with log(f"Loading {drv}..."):
         with subprocess.Popen(
                 ["nix", "--experimental-features", "nix-command",
-                    "show-derivation", "/nix/store/" + drv],
+                    "derivation", "show", f"/nix/store/{drv}^*"],
                 stdout=subprocess.PIPE) as process:
             assert process.stdout
             info = json.load(process.stdout)
@@ -96,6 +103,11 @@ def pinBuiltThings(thing: str,
         pinBuiltThings(dep, done, deps)
 
 
-dep_graph = getDeps(sys.argv[1])
-for root in dep_graph.roots:
-    pinBuiltThings(root, set(), dep_graph.deps)
+def main() -> None:
+    dep_graph = getDeps(sys.argv[1])
+    for root in dep_graph.roots:
+        pinBuiltThings(root, set(), dep_graph.deps)
+
+
+if __name__ == '__main__':
+    main()