FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add NIx support by chinyeungli · Pull Request #203 · aboutcode-org/fetchcode · GitHub

Add NIx support - #203

Closed
chinyeungli wants to merge 10 commits into
masterfrom
201_add_nix_support
Closed

Add NIx support#203
chinyeungli wants to merge 10 commits into
masterfrom
201_add_nix_support

Conversation

chinyeungli commented Jul 22, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Reference: #201

The code tries to get package metadata from https://search.devbox.sh/v2/. If the package cannot be found there, it will try to use the nix command to retrieve the metadata (if nix is installed on the host system).

It then uses https://cache.nixos.org/ to retrieve the download url such as: https://cache.nixos.org/0kz6msxd62b2hx2pacs1vvl6al5ma3ri.narinfo

Note that there are certain requirements: a system qualifier and version are required.

In addition to getting the download URL of the binary, I've also implemented a function to get the upstream source download URL.

Some samples run:

>>> from fetchcode import fetch
>>> from fetchcode import nix
>>> f = fetch("pkg:nix/nixpkgs/vixl@8.0.0?system=aarch64-linux")
>>> f.url
'https://cache.nixos.org/nar/1p9ml56vj79vng8c91vjxfdjmydia19fr7lir40ns4hqcy7lac37.nar.zst'
>>> print(nix.Nix.get_upstream_src_download_url("pkg:nix/nixpkgs/vixl@8.0.0?system=aarch64-linux"))
https://github.com/Linaro/vixl/archive/8.0.0.tar.gz
>>> g = fetch("pkg:nix/nixpkgs/imlib2@1.12.4?system=x86_64-linux")
>>> g.url
'https://cache.nixos.org/nar/0jxici9pc89vqa656rwjzlvk1rwrl6zg9dn8gpvh3p8g62n48328.nar.xz'
>>> print(nix.Nix.get_upstream_src_download_url("pkg:nix/nixpkgs/imlib2@1.12.4?system=x86_64-linux"))
https://downloads.sourceforge.net/enlightenment/imlib2-1.12.4.tar.xz
>>> print(nix.Nix.get_upstream_src_download_url("pkg:nix/hyprland/hyprland@0.53.3?flakeref=github:hyprwm/Hyprland"))
https://github.com/hyprwm/Hyprland/archive/dd220efe7b1e292415bd0ea7161f63df9c95bfd3.tar.gz

(Note that the flakeref qualifier only works for get_upstream_src_download_url, as "cache.nixos.org" only stores official packages, whereas flakeref usually points to third-party locations.)

For reference, the official Nix packages can be found at https://search.nixos.org/packages

 * There are two main functions: get_download_url (system‑specific binary) and get_src_download_url (source tarball).
 * Avoid using nix to retrieve data whenever possible, but provide a fallback to nix if the non‑Nix method does not yield results.

Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
 * version is now required
 * better error handling
 * etc...

Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
…-artifact@v7 and actions/download-artifact@v8 with a full-length commit SHA.

Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
* Correct typo
* Add tests

Signed-off-by: Chin Yeung Li <tli@nexb.com>

Copy link
Copy Markdown
Contributor Author

I am cancelling this PR as I've already implemented the workaround code to work on nix in other repo.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL