Upstream now ships flake.nix + nix/package.nix + a services.moonshine NixOS module, with vendoring derived from Cargo.lock, so the vendored lockfile/outputHashes/Renovate machinery here is no longer needed. - README: deprecation notice with migration pointer - AGENTS.md: mark repo deprecated - remove renovate.json5 and .renovate/ postUpgradeTask scripts so the self-hosted Renovate runner stops opening bumps
moonshine-nix — DEPRECATED
This repo is archived. Upstream Moonshine now ships its own flake (hgaiser/moonshine#129):
nix build github:hgaiser/moonshinebuilds the server,moonshine-bench, and the WSI layer, and a fullservices.moonshineNixOS module covers the systemd unit, udev rules, kernel modules, and firewall. Vendoring there is derived fromCargo.lock(importCargoLock+allowBuiltinFetchGit), so none of the hand-maintained lockfile/outputHashesmachinery below is needed anymore.Migrate: point your flake input at
github:hgaiser/moonshineand use itspackages/nixosModulesoutputs. This repo is kept for history only.
Nix packaging for Moonshine — a headless streaming server for Moonlight clients, written in Rust. Each stream runs in its own isolated Wayland compositor, so the host desktop stays usable (or the box can run headless with no HDMI dummy plug).
This flake exists so the build-from-source derivation can be maintained
separately from any consuming config and, eventually, promoted upstream into
nixpkgs (pkgs/by-name/mo/moonshine/package.nix). default.nix is written as a
plain buildRustPackage function that drops straight into nixpkgs with no
flake-specific machinery.
Usage
nix run github:johnogle/moonshine-nix#moonshine -- /path/to/config.toml
# or
nix build github:johnogle/moonshine-nix#moonshine
./result/bin/moonshine --version
As an overlay:
inputs.moonshine.url = "github:johnogle/moonshine-nix";
inputs.moonshine.inputs.nixpkgs.follows = "nixpkgs";
# then: pkgs.moonshine
What's packaged
The Rust workspace has three members, all built (--workspace):
moonshine— the server binary.moonshine-tools— themoonshine-benchbenchmarking tool.moonshine-wsi— a Vulkan cdylib layer (libmoonshine_wsi.so) that intercepts presentation and routes frames to Moonshine's compositor.
Upstream's dist/ support files (udev rules, kernel module-load config, Vulkan
layer manifest, systemd moonshine@.service template, launcher script) are
installed and have their hardcoded /usr paths substituted to the Nix store.
Packaging quirks
Both are handled in default.nix and documented inline.
-
inputtino-sys vendor flattening.
inputtino-sys'sbuild.rsdoesPathBuf::from("../../../")to reach the inputtino C++ source at the git repo root.fetchCargoVendoronly vendors the crate subtree (bindings/rust/inputtino-sys), so that path lands outside the vendor dir and the cmake step can't findCMakeLists.txt. We fetch the full inputtino checkout separately and patch the vendoredbuild.rs(inpreBuild) to read the source from$INPUTTINO_SOURCE. -
libc++ link.
inputtino-sysunconditionally emitsrustc-link-lib=c++(libc++), which doesn't exist on a gcc/NixOS build (inputtino's C++ is built with gcc, so it already pulls libstdc++). We drop that directive from the vendoredbuild.rsto avoidcannot find -lc++at the final link.
Renovate (upstream tracking)
renovate.json5 + .renovate/update-hash.sh make Renovate open a PR when
hgaiser/moonshine cuts a new GitHub release. A regex custom manager bumps
version in default.nix (a # renovate: marker sits above the line);
rev is templated as v${version}, so the version bump repoints the fetch,
and the sh .renovate/update-hash.sh postUpgradeTask recomputes the
fetchFromGitHub src SRI hash (nix-prefetch-url --unpack + nix hash to-sri;
fetchzip hashes the unpacked tree). It only rewrites the first
fetchFromGitHub block — inputtinoSrc (pinned by Cargo.lock) is untouched.
A second postUpgradeTask, sh .renovate/update-cargo-lock.sh, refreshes the
vendored ./Cargo.lock from the release tag and recomputes the
cargoLock.outputHashes for the git-only crates (git clone minus .git +
nix hash path --sri, which matches fetchgit byte-for-byte, submodules
included), so dependency-changing releases also land green without a manual
round-trip (this was the recurring failure: PR #12).
The task needs nix/nix-prefetch-url on the runner. The stock
renovate/renovate:<version>-full image (containerbase-based) does not ship
nix despite the -full suffix, so the self-hosted runner now uses a custom
child image — registry.johnogle.info/renovate, a child of
renovate/renovate:<version>-full with nix layered on, built from the
ash-bot/renovate-container repo (see k3s-cluster-config PR #751). The command
shape sh .renovate/... matches the runner's global allowedCommands regex.
This automation is only live once the custom image is deployed. Until k3s-cluster-config PR #751 is merged (which switches the HelmRelease image to
registry.johnogle.info/renovate), the runner still lacks nix and the postUpgradeTask fails withnix-prefetch-url: not found— in that window the src hash must be refreshed by hand (see below). Earlier revisions removed thepostUpgradeTasksblock for exactly this reason (PR #6); this commit restores it now that a nix-bearing image exists.
Refreshing the src hash (manual fallback)
If the custom nix image is not yet deployed (or a bump needs finishing by
hand), refresh the fetchFromGitHub src hash on any nix-bearing machine:
- run the helper:
sh .renovate/update-hash.sh(nix-prefetch-url --unpack+nix hash to-sri; it rewrites only the firstfetchFromGitHubblock —inputtinoSrc, pinned by Cargo.lock, is untouched), or - run
nix build .#moonshineand copy thegot:SRI hash the hash-mismatch error prints into thesrcblock.
Then push — CI goes green and the PR can merge.
Manual step on dependency-changing releases
default.nix commits ./Cargo.lock and the cargoLock.outputHashes for the
git-only crates (ash, smithay, inputtino, inputtino-sys, pixelforge).
When an upstream release bumps any of those git deps, the committed lockfile
and hashes go stale and the Renovate PR fails CI with a hash/version mismatch.
sh .renovate/update-cargo-lock.sh handles this automatically as a
postUpgradeTask; on any nix+git-bearing machine it also works by hand:
it downloads upstream's Cargo.lock for the tag in default.nix, recomputes
each git dep's hash, and rewrites the outputHashes block (plus inputtinoSrc
if Cargo.lock re-pinned the inputtino rev). The old fully-manual fallback:
- Copy upstream's new
Cargo.lockover./Cargo.lock. - Run
nix build .#moonshine; copy eachgot:SRI hash the error prints into the matchingoutputHashesentry indefault.nix(also refresh thesrchash as above). - Push — CI goes green and the PR can merge.
Requirements (runtime)
Linux only; a Vulkan-capable GPU (NVIDIA RTX, AMD RDNA2+, or Intel Arc); Moonlight v6.0.0+ on the client. See upstream's README for pairing and configuration.