Configure devenv to build output

This commit is contained in:
Alexander
2026-07-03 22:13:16 +02:00
parent f28091257e
commit 5f79b3c2b0
+32 -5
View File
@@ -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;
};
}