Repository navigation
feat(nix): add flake with package, overlay and devShells - #104
Open
WangYiBen0 wants to merge 1 commit into
Open
WangYiBen0 wants to merge 1 commit into
WangYiBen0 wants to merge 1 commit into
Conversation
Adds a flake exposing packages.celemod, packages.celemod-ui,
overlays.default and devShells.{default,ci} for x86_64-linux and
aarch64-linux.
The package builds and runs:
nix build .#celemod
nix run .#celemod
The Vite frontend is a separate derivation driven by fetchPnpmDeps. The Tauri
shell builds through cargo-tauri.hook, which runs tauri-build with the
custom-protocol feature so the finished dist/ is embedded; without it the
binary loads build.devUrl at runtime and shows an empty window.
wrapGAppsHook4 supplies the GTK runtime environment (XDG_DATA_DIRS,
GDK_PIXBUF_MODULE_PATH, GIO modules) and installs the desktop entry and icons.
Constraints worth knowing, each commented at the relevant line and written up
in nix/README.md:
* nightly Rust is required (src-tauri/src/lib.rs uses #![feature(try_blocks)]);
rustPlatform comes from rust-overlay's nightly .default toolchain
* cargoHash must be top-level and cargoLock absent; supplying both makes
buildRustPackage prefer importCargoLock, which then demands outputHashes
for the git dependency
* cargoRoot stays "." so fetchCargoVendor finds the workspace lockfile
* rust-overlay is pinned by rev, not HEAD, so evaluation never calls the
GitHub API
* nix/ must stay git-tracked: a git-repo flake cannot see untracked files
Every hash in nix/versions.nix came from a real fetch failure.
scripts/update-nix-hashes.sh refreshes them idempotently and asserts that what
it writes matches what it measured.
checks.<system>.celemod-is-real guards against the packages collapsing to
runCommand placeholders, which `nix flake check --no-build` cannot detect.
This was referenced Nov 7, 2026
Open
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Nix flake:
packages.celemod,packages.celemod-ui,overlays.defaultand
devShells.{default,ci}forx86_64-linuxandaarch64-linux.Verified
nix eval .#packages.x86_64-linux.celemod.version1.2.2, read fromversion.txtnix build .#packages.x86_64-linux.celemod$out/bin/cele-mod(GTK wrapper) +.cele-mod-wrappednix flake check --all-systems --no-buildImplementation notes
Constraints of this nixpkgs or this repository, not preferences. Each is
commented at the relevant line and written up in
nix/README.md.src-tauri/src/lib.rsuses#![feature(try_blocks)], so a stable rustc fails withE0554.rustPlatformcomes from rust-overlay'srust-bin.nightly.latest.default; the component.rustcships no std sysroot (E0463).cargo-tauri.hookdrives the build. It runstauri-buildwith thecustom-protocolfeature, so the frontend is embedded instead of loaded frombuild.devUrlat runtime. Building without it produces a binary that opens a window and shows nothing.wrapGAppsHook4supplies the GTK runtime environment (XDG_DATA_DIRS,GDK_PIXBUF_MODULE_PATH, GIO modules) and installs the desktop entry and icons.cargoHashis top-level andcargoLockabsent.buildRustPackagepreferscargoLockwhenever it is set and silently ignores a top-levelcargoHash, then fails withNo hash was found while vendoring the git dependency game-scanner-1.2.0.cargoRoot = ".". It also drives vendor staging, so any other value makes it look forCargo.lockoutside the workspace root;buildAndTestSubdirselectssrc-tauri.CMAKE_POLICY_VERSION_MINIMUM = 3.5.prost-build 0.10.4vendors protobuf and runs CMake on a pre-3.5CMakeLists.txt.nix/must stay tracked. A git-repo flake cannot see untracked files.Hashes
All three hashes in
nix/versions.nixcame from real fetch failures, neverguesses.
scripts/update-nix-hashes.shrecomputes them, validates everydigest, asserts the written value matches the one just measured, and is
byte-identical on a second run.
Guard
checks.<system>.celemod-is-realfails the build if either package stops beinga real derivation, because
nix flake check --no-buildcannot tell a realderivation from an empty
runCommandstub. It asserts onnativeBuildInputsrather than
passthru.placeholder, which a plainrunCommandnever sets.Scope
Desktop builds only. Android, AppImage/deb bundling and
tauri buildoutputartifacts are untouched.