Skip to content

Add Nix flake with package and devShell outputs - #1

Draft
faldor20 with Copilot wants to merge 3 commits into
masterfrom
copilot/create-flake-with-devshell
Draft

faldor20 with Copilot wants to merge 3 commits into
masterfrom
copilot/create-flake-with-devshell

Conversation

Copilot AI commented Mar 11, 2026 •

Copy link
Copy Markdown

Adds a flake.nix so jcode can be built and developed via Nix following modern best practices.

Flake outputs

  • packages.default — builds the jcode binary via crane; dependency compilation is a separate cached derivation so incremental rebuilds are fast
  • devShells.default — stable Rust toolchain (rust-analyzer, rustfmt, clippy) plus cargo-watch and cargo-edit; RUST_SRC_PATH wired for IDE integration
  • checks — clippy (deny warnings) + cargo fmt, runnable with nix flake check

Supporting changes

  • Cargo.lock committed — required for crane to vendor deps offline in the Nix sandbox; conventional for binary crates anyway
  • .gitignore — removed Cargo.lock entry

Build env vars

build.rs probes git at compile time. The flake sets static overrides so the sandbox build succeeds:

JCODE_BUILD_GIT_HASH = "nix-build";
JCODE_BUILD_GIT_DATE = "1970-01-01 00:00:00 +0000";
JCODE_BUILD_GIT_DIRTY = "0";
JCODE_BUILD_GIT_TAG  = "v${cargoToml.package.version}";
JCODE_RELEASE_BUILD  = "1";

System deps

Platform Dependencies
Linux openssl, libxcb, libX11
macOS AppKit, Security, SystemConfiguration

Usage

nix build          # build jcode
nix develop        # enter dev shell
nix flake check    # clippy + fmt

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/1jehuang/mermaid-rs-renderer/commits/v0.2.1
    • Triggering command: /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/bin/cargo /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/bin/cargo generate-lockfile (http block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add flake with package and devshell outputs Add Nix flake with package and devShell outputs Mar 11, 2026
Add the Linux linker tools and keep compile-time prompt assets in the filtered source so nix builds succeed inside the sandbox. This keeps the flake aligned with the repo's Cargo linker config and embedded prompt files.
zombi3butt pushed a commit to zombi3butt/jcode that referenced this pull request May 22, 2026
Adds a Nix flake at the repo root so users on NixOS / nix-darwin /
home-manager can:

  nix run     github:quangdang46/jcode
  nix profile install github:quangdang46/jcode
  nix develop github:quangdang46/jcode

The flake uses crane (https://github.com/ipetkov/crane) for cached
dep-only builds + a final binary build, mirroring the structure
referenced in faldor20#1. Outputs:

- packages.default / packages.jcode — release binary.
- devShells.default — Rust nightly + cargo-nextest, cargo-watch,
  sccache, rust-analyzer; sets RUSTC_WRAPPER=sccache automatically.
- apps.default — runnable jcode entry point for `nix run`.
- checks.jcode-clippy + checks.jcode-fmt — the same guardrails CI
  enforces, runnable via `nix flake check`.

build.rs reads git metadata (JCODE_GIT_HASH, JCODE_GIT_DATE). Nix
typically strips .git/, so the flake passes deterministic values
derived from `self.rev` / `self.lastModifiedDate`.

System dependencies covered:
  Linux: openssl, libxcb, xorg.libX11, libusb1
  macOS: AppKit, Security, SystemConfiguration, CoreFoundation, Metal

README.md gets a new "Nix flake" section between Homebrew and
"Verifying release artifacts".

Closes 1jehuang#95
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants