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.
This commit is contained in:
parent
c42eaef554
commit
cbce1ae3a2
4 changed files with 87 additions and 25 deletions
41
scope.nix
Normal file
41
scope.nix
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
{ 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"; };
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue