clan-sidebus/scope.nix
Else Someone cbce1ae3a2 default.nix: init
Move recipes from flake.nix:s `packages` to a `callPackage`-able scope.nix.
This way out-of-tree projects can reuse the `buildRustPackage`
definitions (e.g. the in-sync `cargoLock` hashes) without depending on
the unsupported flakes feature.
2026-03-21 02:03:02 +02:00

41 lines
1.2 KiB
Nix

{ lib, newScope }:
lib.makeScope newScope (self: {
forgetScope = lib.flip lib.removeAttrs [
"override"
"overrideDerivation"
"overrideScope"
"newScope"
"packages"
"forgetScope"
];
buildEnvVars = self.forgetScope (
self.callPackage (
{ xdg-desktop-portal, virtiofsd }:
{
BIN_XDG_PERMISSION_STORE = "${xdg-desktop-portal}/libexec/xdg-permission-store";
BIN_XDG_DOCUMENT_PORTAL = "${xdg-desktop-portal}/libexec/xdg-document-portal";
BIN_VIRTIOFSD = "${virtiofsd}/bin/virtiofsd";
}
) { }
);
rustPackage =
{
crate,
cargoToml ? builtins.fromTOML (builtins.readFile ./${crate}/Cargo.toml),
rustPlatform,
buildEnvVars,
}:
rustPlatform.buildRustPackage {
inherit (cargoToml.package) name version;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
cargoLock.outputHashes = {
"busd-0.5.0" = "sha256-IZZ2MeEmUbzRrH6SUz0pnecMH4f8Mh54WdhI4q44YfI=";
};
buildAndTestSubdir = crate;
env = buildEnvVars;
};
sidebus-agent = self.callPackage self.rustPackage { crate = "sidebus-agent"; };
sidebus-broker = self.callPackage self.rustPackage { crate = "sidebus-broker"; };
})