Closed luisnquin closed 1 year ago
How can I get this data without using NixOS as I need to update the rev and sha256?
Well, there's a Python app that also does that, I think that is even simpler, its name is nix-prefetch-github
Install it by using:
pip install nix-prefetch-github
or pipx install nix-prefetch-github
Usage example:
$ nix-prefetch-github gabrielzschmitz Tomato.C
{
"owner": "gabrielzschmitz",
"repo": "Tomato.C",
"rev": "dda8e0ffe0b8612691ed336962f33580fb3a6038",
"sha256": "+ydnRPhOKdydNKQ4YCpbyBoKnJMfMFWVXgAcoofJfaQ="
}
Ok, thanks. Will implement
Oh no:
$ nix-prefetch-github gabrielzschmitz Tomato.C
Traceback (most recent call last):
File "/home/gabrielzschmitz/.local/bin/nix-prefetch-github", line 8, in <module>
sys.exit(main())
File "/home/gabrielzschmitz/.local/lib/python3.10/site-packages/nix_prefetch_github/cli/fetch_github.py", line 9, in main
controller.process_arguments(sys.argv[1:])
File "/home/gabrielzschmitz/.local/lib/python3.10/site-packages/nix_prefetch_github/controller/nix_prefetch_github_controller.py", line 29, in process_arguments
self._use_case.prefetch_github_repository(
File "/home/gabrielzschmitz/.local/lib/python3.10/site-packages/nix_prefetch_github/use_cases/prefetch_github_repository.py", line 38, in prefetch_github_repository
prefetch_result = self.prefetcher.prefetch_github(
File "/home/gabrielzschmitz/.local/lib/python3.10/site-packages/nix_prefetch_github/prefetch.py", line 38, in prefetch_github
return self._prefetch_github(repository, revision, prefetch_options)
File "/home/gabrielzschmitz/.local/lib/python3.10/site-packages/nix_prefetch_github/prefetch.py", line 46, in _prefetch_github
calculated_hash = self._calculate_sha256_sum(
File "/home/gabrielzschmitz/.local/lib/python3.10/site-packages/nix_prefetch_github/prefetch.py", line 82, in _calculate_sha256_sum
return self.url_hasher.calculate_sha256_sum(
File "/home/gabrielzschmitz/.local/lib/python3.10/site-packages/nix_prefetch_github/url_hasher/url_hasher_selector.py", line 39, in calculate_sha256_sum
return hasher.calculate_sha256_sum(
File "/home/gabrielzschmitz/.local/lib/python3.10/site-packages/nix_prefetch_github/url_hasher/nix_build.py", line 28, in calculate_sha256_sum
status_code, output = self.run_fetch_command(
File "/home/gabrielzschmitz/.local/lib/python3.10/site-packages/nix_prefetch_github/url_hasher/nix_build.py", line 57, in run_fetch_command
result = self.command_runner.run_command(
File "/home/gabrielzschmitz/.local/lib/python3.10/site-packages/nix_prefetch_github/command/command_runner.py", line 25, in run_command
process = subprocess.Popen(
File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.10/subprocess.py", line 1847, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'nix-build'
Lol
@gabrielzschmitz I was investigating more about that and apparently is a feature that is only available for Nix machines, even I wanted to create a bash script for that but the above answer was repeated
You could try to install Nix package manager for your computer, maybe it should be an upgrade for you regardless of this
Here's the download link: https://nixos.org/download.html
Once you have Nix installed then you can type nix-env -iA nixpkgs.nix-prefetch-git
to of course, install the package
You can also search for more packages here, start by searching something like I don't know ¿docker?
Anyway, I don't have problems by updating the file just for relevant updates, let me know what you will do
I will install a NixOS VM so I can get a better support for all NixOS users. But I will be very happy if you could update it until then!
Let's gooo
Personally, I don't think that
src = ./.
gets too useful for now, this new .nix file version installs tomato from GitHubYou only will need to update the
sha256
andrev
with the data from the generated JSON innix-prefetch-git <repo-url>
for each big change that you do in the programExample:
Now there are two ways of installation
By cloning the repository and using Nix package manager and executing
$ nix-build default.nix
Or if using
NixOS
by adding the .nix file to theconfiguration.nix
and then calling it like hereI guess that's it, maybe later if I find it useful I'll add a
flake.nix
, but for now this is enough