about summary refs log tree commit diff stats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/npins_to_unflake.jq34
-rwxr-xr-xscripts/unflake.sh6
2 files changed, 40 insertions, 0 deletions
diff --git a/scripts/npins_to_unflake.jq b/scripts/npins_to_unflake.jq
new file mode 100644
index 00000000..80e6b5a3
--- /dev/null
+++ b/scripts/npins_to_unflake.jq
@@ -0,0 +1,34 @@
+def make_url(value):
+        value.repository as $repo |
+        if value.type == "Git" then
+            if $repo.type == "Git" then
+                "git+\($repo.url)?ref=\(value.branch)"
+            elif $repo.type == "GitHub" then
+                "github:\($repo.owner)/\($repo.repo)/\(value.branch)"
+            elif $repo.type == "Forgejo" then
+                "git+\($repo.server)/\($repo.owner)/\($repo.repo)?ref=\(value.branch)"
+            else
+                error("Invalid repository type: '\($repo.type)'")
+            end
+        elif value.type == "GitRelease" then
+            if $repo.type == "GitHub" then
+                "github:\($repo.owner)/\($repo.repo)/\(value.version)"
+            else
+                error("Invalid repository type: '\($repo.type)'")
+            end
+        elif value.type == "Channel" then
+            empty
+        else
+                error("Invalid value type: '\(value.type)'")
+        end
+    ;
+
+"{
+\(
+        .pins | to_entries | map(
+        "    \"\(.key)\" = {
+        url = \"\(make_url(.value))\";
+    };"
+        ) | join("\n")
+    )
+}"
diff --git a/scripts/unflake.sh b/scripts/unflake.sh
new file mode 100755
index 00000000..e4aa816d
--- /dev/null
+++ b/scripts/unflake.sh
@@ -0,0 +1,6 @@
+#! /usr/bin/env sh
+
+NIX_CONFIG="pure-eval = false" nix run -f https://codeberg.org/goldstein/unflake/archive/main.tar.gz unflake -- "$@"
+
+
+# vim: ft=sh