Last active
July 12, 2026 21:14
-
-
Save sortofsleepy/cdaa4c2fb8c89a44fd55fa8022450714 to your computer and use it in GitHub Desktop.
Nix package derivation example
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
| # Fetches the specified version of Odin | |
| odin-fetch = pkgs.stdenv.mkDerivation { | |
| pname = "odin-source"; | |
| version = odin-version; # references a variable declared earlier in the file | |
| src = pkgs.fetchurl { | |
| url="https://github.com/odin-lang/Odin/releases/download/${odin-version}/odin-linux-amd64-${odin-version}.tar.gz"; | |
| # When you change versions, you should get an error pointing to the correct SHA | |
| hash = "sha256-zX7CzRqyhAoLfrwY5ctBxnG86HsS8Fb92+8/CAtN3n0="; | |
| }; | |
| #nativeBuildInputs = [pkgs.makeWrapper]; | |
| #postFixup = '' | |
| #wrapProgram $out/bin/odin \ | |
| #--set ODIN_ROOT $out/share/odin | |
| #''; | |
| buildInputs = [ | |
| pkgs.llvm | |
| pkgs.clang | |
| pkgs.libiconv | |
| ]; | |
| installPhase = '' | |
| mkdir -p $out/bin $out/share/odin | |
| cp odin $out/bin | |
| cp -r base core vendor $out/share/odin/ | |
| ''; | |
| }; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This shows a basic derivation of how to download a package outside of Nix packages and use it in the rest of your flake.
note that for Odin specifically, you'll need to either add
to any derivations that need to utilize Odin or adjust odin-fetch to include
nativeBuildInputs = [pkgs.autoPatchelfHook];and add a phase