From 5f79b3c2b09f64e922ce4451c2a7497a81a17857 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 3 Jul 2026 22:13:16 +0200 Subject: [PATCH] Configure devenv to build output --- devenv.nix | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/devenv.nix b/devenv.nix index 2204ec1..f0a462d 100644 --- a/devenv.nix +++ b/devenv.nix @@ -6,6 +6,33 @@ ... }: +let + # devenv's `languages.rust.import` only builds single root-package crates + # (it hardcodes `cargoNix.rootCrate.build`). musicfs is a virtual workspace with + # no root package, so we drive crate2nix directly and select the `musicfs-client` + # member out of `workspaceMembers`. src = ./. gives crate2nix the whole workspace, + # so the member's path-dependencies (musicfs-core, musicfs-proto) resolve. + crate2nixTools = pkgs.callPackage "${inputs.crate2nix}/tools.nix" { }; + cargoNix = + pkgs.callPackage + (crate2nixTools.generatedCargoNix { + name = "musicfs"; + src = ./.; + }) + { + # Build with the toolchain configured for this dev environment, + # matching what languages.rust.import does internally. + buildRustCrateForPkgs = + _: + pkgs.buildRustCrate.override { + rustc = config.languages.rust.toolchainPackage; + cargo = config.languages.rust.toolchainPackage; + }; + }; + + # musicfs-client's binary is named `musicfs` (see [[bin]] in its Cargo.toml). + musicfs = cargoNix.workspaceMembers."musicfs-client".build; +in { languages.rust.enable = true; git-hooks.hooks = { @@ -42,7 +69,7 @@ processes.musicfs = { after = [ "devenv:processes:postgres" ]; exec = lib.mkDefault '' - cargo run -p musicfs-client -- \ + ${musicfs}/bin/musicfs \ --source /home/fujin/Music \ --mountpoint /tmp/rust-fuse \ --database "postgresql://fujin@localhost/musicfs?host=$PGHOST" @@ -53,7 +80,7 @@ processes.musicfs = { after = [ "devenv:processes:postgres" ]; exec = '' - cargo run -p musicfs-client -- \ + ${musicfs}/bin/musicfs \ --source /home/fujin/Music \ --mountpoint /tmp/rust-fuse \ --database "postgresql://fujin@localhost/musicfs?host=$PGHOST" @@ -65,7 +92,7 @@ processes.musicfs = { after = [ "devenv:processes:postgres" ]; exec = '' - cargo run -p musicfs-client -- \ + ${musicfs}/bin/musicfs \ --source http://10.185.226.145:50051 \ --mountpoint /tmp/rust-fuse \ --database "postgresql://fujin@localhost/musicfs?host=$PGHOST" @@ -77,7 +104,7 @@ processes.musicfs = { after = [ "devenv:processes:postgres" ]; exec = '' - cargo run -p musicfs-client -- \ + ${musicfs}/bin/musicfs \ --source http://127.0.0.1:50061 \ --mountpoint ./target/e2e/mnt \ --database "postgresql://fujin@localhost/musicfs_e2e?host=$PGHOST" \ @@ -101,6 +128,6 @@ }; outputs = { - rust-app = config.languages.rust.import ./. { }; + musicfs = musicfs; }; }