Use this when
- Creating a new package under
pkgs/ - Updating an exported package version or hash
- Fixing a build/runtime issue in an existing derivation
- Adding or updating a library helper in
lib/ - Wiring exports through
default.nixorlib/default.nix
Repository-specific ground rules
default.nixis the source of truth for exported packages.lib/default.nixis the source of truth for library helpers and currently exportsfetchPixiv.modules/default.nixandoverlays/default.nixare placeholders right now; do not document them as populated unless you add real entries.- CI behavior comes from
ci.nix(imported byflake.nixasciPackages/ciJobs), not from guesswork.
Packaging styles actually used in this repo
Python applications and packages
Used heavily for GUI apps and helpers.
Examples:
pkgs/JMComic-qt.nixpkgs/picacg-qt.nixpkgs/sr-vulkan.nix
Common patterns:
python3Packages.buildPythonApplicationpython3Packages.buildPythonPackage- wrapper scripts for GUI entrypoints
- Vulkan or site-packages symlink setup in
postInstall
Flutter applications
Example: pkgs/LoveIwara/default.nix
Use the pinned Flutter SDK's buildFlutterApplication (currently flutter347) for reproducible Linux desktop builds:
- convert and check in upstream
pubspec.lockaspubspec.lock.json - use
customSourceBuilderswhen Dart native-asset hooks attempt sandboxed downloads - put dynamically loaded FFI libraries in
runtimeDependencies - install the upstream desktop entry and icon in
postInstall - launch the built GUI to verify native plugins and runtime libraries
Rust packages
Example: pkgs/waybar-vd/default.nix
rustPlatform.buildRustPackage rec {
pname = "...";
version = "...";
cargoLock.lockFile = ./Cargo.lock;
postPatch = ''
ln -s ${./Cargo.lock} Cargo.lock
'';
}
Go packages
Example: pkgs/mihomo-smart.nix
buildGoModule rec {
pname = "...";
version = "...";
vendorHash = "sha256-...";
}
npm dependencies
No exported package currently uses buildNpmPackage directly. npm usage here is limited to
offline dependency rebuilds inside other derivations:
Example: pkgs/wechat-web-devtools-linux
pkgs/wechat-web-devtools-linux/npm/nativeandnpm/toolshold hand-written manifests
plus lockfiles; the derivation runs npm ci --offline --ignore-scripts with a FOD cache
to rebuild native npm modules (nodegit, node-pty, ...) with Electron headers.
bun + `stdenvNoCC` packages
Example: pkgs/mcp-cli.nix
This repo also contains packages that:
- prebuild dependency trees as fixed-output derivations
- use
bun install --frozen-lockfile - compile a final CLI binary with
bun build --compile
Gradle / JVM packages
Example: pkgs/jadx-headless-mcp/default.nix
stdenv.mkDerivation (finalAttrs: {
nativeBuildInputs = [ gradle_9 jdk17 makeBinaryWrapper ];
mitmCache = gradle_9.fetchDeps {
pkg = finalAttrs.finalPackage; # required outside nixpkgs
data = ./deps.json;
};
gradleBuildTask = "installDist";
})
- The Gradle dependency tree lives in a committed
deps.jsonlockfile; regenerate it
with <attr>.mitmCache.updateScript on every bump.
- Match the Gradle major/minor to the project's wrapper (
gradle_9= 9.8.0); the
nixpkgs default gradle may be too old for modern plugin versions.
- A
jvmToolchain(...)declaration needs
-Dorg.gradle.java.installations.paths=${jdk17.home} — the build runs --offline.
- Wrap the
installDistlauncher with--set JAVA_HOMEinstead of trustingPATH.
Generic derivations
Examples:
pkgs/grub-theme-yorha.nix
Use stdenv.mkDerivation or stdenvNoCC.mkDerivation for asset packages, extracted binaries, or custom build workflows.
Export wiring patterns
Package export in `default.nix`
some-package = pkgs.callPackage ./pkgs/some-package.nix { };
Library export in `lib/default.nix`
{ pkgs }:
{
someHelper = pkgs.callPackage ./someHelper/default.nix { };
}
Current repo-specific examples worth imitating
JMComic-qt/picacg-qt: Python GUI packaging plus runtime wrappingLoveIwara: source-built Flutter GUI with offline pub dependencies, system SQLite, libmpv runtime wrapping, and upstream desktop integrationsr-vulkan: model composition throughsr-vulkan-modelstruenas-mcp:buildGoModuleMCP server with a single main binarypctx/wakaru: Rust workspace crates pinned to release tags, narrowed withcargoBuildFlags = [ "-p" <bin-crate> ]jadx-headless-mcp: Kotlin/Gradle source build with adeps.jsonlockfile and a wrappedinstallDistlauncherfetchPixiv: helper-style library export usingfetchurlfallback URLs
Hash techniques
Build once with a fake hash
hash = lib.fakeHash;
Then rebuild and copy the real hash from the failure output.
Prefetch helpers
nix-prefetch-url --unpack <url>
nix-prefetch-github owner repo --rev v1.0.0
Checklist
- [ ] Export wiring updated in
default.nixorlib/default.nixif needed - [ ] Runtime behavior checked for wrapped GUI / CLI tools
- [ ] Docs updated if package inventory or repo behavior changed