3 ms·
If you just want to take a precompiled binary and install it, you just have to write a derivation wrapper around the binary which will declare the expected hash
by JamesSwift 5y ago
If you just want to take a precompiled binary and install it, you just have to write a derivation wrapper around the binary which will declare the expected hash and take care of e.g. unzipping and moving to $out/bin.
Here is a more involved example of downloading a release and then extracting the binary from a .pkg file: https://gist.github.com/J-Swift/364a8b158bf0b603f6e784e454ca6e53 https://gist.github.com/J-Swift/364a8b158bf0b603f6e784e454ca...
Here is a more simplified example: https://gist.github.com/mitchellh/c47e3333bb78f57836ba2aa8064ad993#file-hashicorp-generic-nix-L32-L47 https://gist.github.com/mitchellh/c47e3333bb78f57836ba2aa806...
EDIT: to get the sha, unfortunately you have to perform some esoteric command line incantations: https://github.com/NixOS/nix/issues/1880#issuecomment-366615204 https://github.com/NixOS/nix/issues/1880#issuecomment-366615... and https://gist.github.com/boxofrox/d8a3080fbb03f84b7d7a31e102b35f09 https://gist.github.com/boxofrox/d8a3080fbb03f84b7d7a31e102b...
- codingkoi 5y agoOnce I discovered `lib.fakeSha256`, I just put that in the derivation, try to build it and then use the error message to find the correct hash to put into it. Probably not the fastest way to do it, but it's easier for me to remember.
- JamesSwift 5y agoyeah that seems way easier, thanks for the tip!