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:
Else Someone 2026-03-21 02:02:55 +02:00
parent c42eaef554
commit cbce1ae3a2
4 changed files with 87 additions and 25 deletions

View file

@ -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 = {