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
34
flake.nix
34
flake.nix
|
|
@ -3,6 +3,10 @@
|
|||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
|
||||
flake-compat = {
|
||||
url = "https://git.lix.systems/lix-project/flake-compat/archive/main.tar.gz";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
|
|
@ -16,27 +20,7 @@
|
|||
perSystem =
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
buildEnvVars = {
|
||||
BIN_XDG_PERMISSION_STORE = "${pkgs.xdg-desktop-portal}/libexec/xdg-permission-store";
|
||||
BIN_XDG_DOCUMENT_PORTAL = "${pkgs.xdg-desktop-portal}/libexec/xdg-document-portal";
|
||||
BIN_VIRTIOFSD = "${pkgs.virtiofsd}/bin/virtiofsd";
|
||||
};
|
||||
|
||||
rustPackage =
|
||||
crate:
|
||||
let
|
||||
cargoToml = builtins.fromTOML (builtins.readFile ./${crate}/Cargo.toml);
|
||||
in
|
||||
pkgs.rustPlatform.buildRustPackage {
|
||||
inherit (cargoToml.package) name version;
|
||||
src = ./.;
|
||||
cargoLock.lockFile = ./Cargo.lock;
|
||||
cargoLock.outputHashes = {
|
||||
"busd-0.5.0" = "sha256-IZZ2MeEmUbzRrH6SUz0pnecMH4f8Mh54WdhI4q44YfI=";
|
||||
};
|
||||
buildAndTestSubdir = crate;
|
||||
env = buildEnvVars;
|
||||
};
|
||||
scope = pkgs.callPackage ./scope.nix { };
|
||||
in
|
||||
{
|
||||
devShells.default = pkgs.mkShell {
|
||||
|
|
@ -46,11 +30,11 @@
|
|||
rust-analyzer
|
||||
clippy
|
||||
];
|
||||
env = buildEnvVars;
|
||||
env = scope.buildEnvVars;
|
||||
};
|
||||
packages = {
|
||||
inherit (scope) sidebus-agent sidebus-broker;
|
||||
};
|
||||
|
||||
packages.sidebus-agent = rustPackage "sidebus-agent";
|
||||
packages.sidebus-broker = rustPackage "sidebus-broker";
|
||||
};
|
||||
|
||||
flake = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue