This repository has been archived on 2026-07-31. You can view files and clone it. You cannot open issues or pull requests or push a commit.
ash-bot 20b81430d3
CI / check (pull_request) Successful in 15s
CI / build (pull_request) Successful in 13m35s
CI / check (push) Successful in 21s
CI / build (push) Successful in 22m14s
deprecate: superseded by upstream flake (hgaiser/moonshine#129)
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
2026-07-30 05:10:06 -07:00

moonshine-nix — DEPRECATED

This repo is archived. Upstream Moonshine now ships its own flake (hgaiser/moonshine#129): nix build github:hgaiser/moonshine builds the server, moonshine-bench, and the WSI layer, and a full services.moonshine NixOS module covers the systemd unit, udev rules, kernel modules, and firewall. Vendoring there is derived from Cargo.lock (importCargoLock + allowBuiltinFetchGit), so none of the hand-maintained lockfile/outputHashes machinery below is needed anymore.

Migrate: point your flake input at github:hgaiser/moonshine and use its packages / nixosModules outputs. 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 — the moonshine-bench benchmarking 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.

  1. inputtino-sys vendor flattening. inputtino-sys's build.rs does PathBuf::from("../../../") to reach the inputtino C++ source at the git repo root. fetchCargoVendor only vendors the crate subtree (bindings/rust/inputtino-sys), so that path lands outside the vendor dir and the cmake step can't find CMakeLists.txt. We fetch the full inputtino checkout separately and patch the vendored build.rs (in preBuild) to read the source from $INPUTTINO_SOURCE.

  2. libc++ link. inputtino-sys unconditionally emits rustc-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 vendored build.rs to avoid cannot 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 with nix-prefetch-url: not found — in that window the src hash must be refreshed by hand (see below). Earlier revisions removed the postUpgradeTasks block 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 first fetchFromGitHub block — inputtinoSrc, pinned by Cargo.lock, is untouched), or
  • run nix build .#moonshine and copy the got: SRI hash the hash-mismatch error prints into the src block.

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:

  1. Copy upstream's new Cargo.lock over ./Cargo.lock.
  2. Run nix build .#moonshine; copy each got: SRI hash the error prints into the matching outputHashes entry in default.nix (also refresh the src hash as above).
  3. 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.

S
Description
Nix packaging for Moonshine (headless Moonlight streaming server) — build-from-source derivation, promotable to nixpkgs
Readme
240 KiB
0 Stars 2 Watchers 0 Forks
Languages
Nix 100%