nix: Use an overlay

This commit is contained in:
Will Fancher 2025-09-28 15:16:35 -04:00
parent 252a37e2cb
commit b3787208d8
2 changed files with 35 additions and 20 deletions

View File

@ -42,6 +42,12 @@
}:
let
systems = nixpkgs.lib.filter (s: nixpkgs.lib.hasSuffix "-linux" s) nixpkgs.lib.systems.flakeExposed;
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
rustfmtToml = builtins.fromTOML (builtins.readFile ./rustfmt.toml);
rev = self.shortRev or self.dirtyShortRev or (nixpkgs.lib.substring 0 8 self.lastModifiedDate);
version = "${cargoToml.package.version}+${rev}";
in
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ inputs.treefmt-nix.flakeModule ];
@ -55,6 +61,8 @@
inherit systems;
flake.overlays.default = import ./overlay.nix { inherit inputs version; };
perSystem =
{
self',
@ -68,12 +76,6 @@
inherit system;
overlays = [ (import rust-overlay) ];
};
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
rustfmtToml = builtins.fromTOML (builtins.readFile ./rustfmt.toml);
rev = self.shortRev or self.dirtyShortRev or (lib.substring 0 8 self.lastModifiedDate);
version = "${cargoToml.package.version}+${rev}";
in
{
packages =
@ -84,24 +86,17 @@
localSystem = system;
pkgs' = import nixpkgs {
inherit crossSystem localSystem;
overlays = [ (import rust-overlay) ];
overlays = [
(import rust-overlay)
self.overlays.default
];
};
withCrossName =
set: lib.mapAttrs' (name: value: lib.nameValuePair "${name}-${crossSystem}" value) set;
craneBuild = pkgs'.callPackage ./crane-build.nix { inherit crane version; };
crossPackages = {
"bcachefs-tools" = craneBuild.package;
"bcachefs-tools-fuse" = craneBuild.packageFuse;
"bcachefs-module-linux-latest" =
pkgs'.linuxPackages_latest.callPackage craneBuild.package.kernelModule
{ };
"bcachefs-module-linux-testing" =
pkgs'.linuxPackages_testing.callPackage craneBuild.package.kernelModule
{ };
};
in
(withCrossName crossPackages) // lib.optionalAttrs (crossSystem == localSystem) crossPackages;
(withCrossName pkgs'.bcachefsPackages)
// lib.optionalAttrs (crossSystem == localSystem) pkgs'.bcachefsPackages;
packages = lib.mergeAttrsList (map packagesForSystem systems);
in
packages

20
overlay.nix Normal file
View File

@ -0,0 +1,20 @@
{ inputs, version }:
final: prev:
let
craneBuild = prev.callPackage ./crane-build.nix {
inherit version;
inherit (inputs) crane;
};
in
{
bcachefsPackages = {
"bcachefs-tools" = craneBuild.package;
"bcachefs-tools-fuse" = craneBuild.packageFuse;
"bcachefs-module-linux-latest" =
final.linuxPackages_latest.callPackage craneBuild.package.kernelModule
{ };
"bcachefs-module-linux-testing" =
final.linuxPackages_testing.callPackage craneBuild.package.kernelModule
{ };
};
}