-
Notifications
You must be signed in to change notification settings - Fork 0
Support a reproducible build via Nix #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,6 @@ | ||
| build | ||
|
|
||
| # Nix | ||
| .direnv | ||
| .envrc | ||
| result |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| { | ||
| inputs = { | ||
| nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
| flake-utils.url = "github:numtide/flake-utils"; | ||
| self.submodules = true; | ||
| }; | ||
| outputs = | ||
| { | ||
| self, | ||
| nixpkgs, | ||
| flake-utils, | ||
| }: | ||
| flake-utils.lib.eachDefaultSystem ( | ||
| system: | ||
| let | ||
| pkgs = import nixpkgs { inherit system; }; | ||
| nativeBuildInputs = [ | ||
| pkgs.cmake | ||
| pkgs.python3 | ||
| pkgs.python3Packages.libclang | ||
| pkgs.shader-slang | ||
| ]; | ||
| buildInputs = [ | ||
| pkgs.SDL2 | ||
| pkgs.vulkan-headers | ||
| pkgs.vulkan-loader | ||
| ]; | ||
| CPATH = "${pkgs.glibc.dev}/include"; | ||
| in | ||
| { | ||
| defaultPackage = pkgs.stdenv.mkDerivation { | ||
| name = "slang-simple-vulkan"; | ||
| src = ./.; | ||
| strictDeps = true; | ||
| inherit nativeBuildInputs buildInputs CPATH; | ||
| installPhase = '' | ||
| mkdir -p $out/bin | ||
| cp *.spv demo $out/bin/ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having the .spv files in PATH if someone were to launch a (non-dev) shell with this or even install it globally... would get a bit awkward. I guess one option would be to wrap the demo to cd to a data dir in Anyway that's a fair bit of work for just a simple demo so that can also be done later if someone feels like it.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough! This was just a minimal attempt with the goal of making no changes to the rest of the code. If I were making other changes then I would have also gotten rid of the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This demo also doesn't even work when running the built binary with cwd outside this repo clone, because it assumes that |
||
| ''; | ||
| }; | ||
| devShell = pkgs.mkShell { | ||
| inherit buildInputs CPATH; | ||
| nativeBuildInputs = nativeBuildInputs ++ [ | ||
| pkgs.clang-tools | ||
| pkgs.nixfmt-rfc-style | ||
| ]; | ||
| }; | ||
| } | ||
| ); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there's a lockfile with pinned versions I'd prefer using a stable nixpkgs channel (say, nixos-25.04) so we get to use cached dependency builds for a longer time without updating the lockfile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh interesting, I wasn't aware that the cache on a release channel like
nixos-25.05lasts longer than the cache fornixpkgs-unstable. Out of curiosity, is there some documentation about the Nixpkgs cache policy that I can read?Unfortunately switching this from
nixpkgs-unstabletonixos-25.05doesn't currently work, because the Slang version there is still only v2025.8.1, which is too old to compile this demo.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know of an official policy, the closest thing I know is https://nixos.wiki/wiki/Nix_channels
Anyway the idea is that stable gets fewer updates in general so it's more likely that a given build hash is still relevant.