mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-12-08 00:00:12 +03:00
nix: Build kernel module
This commit is contained in:
parent
365c84997f
commit
d3ced65a68
@ -74,6 +74,15 @@ let
|
||||
// {
|
||||
inherit cargoArtifacts;
|
||||
|
||||
outputs = [
|
||||
"out"
|
||||
"dkms"
|
||||
];
|
||||
|
||||
makeFlags = args.makeFlags ++ [
|
||||
"DKMSDIR=${placeholder "dkms"}"
|
||||
];
|
||||
|
||||
enableParallelBuilding = true;
|
||||
buildPhaseCargoCommand = ''
|
||||
make ''${enableParallelBuilding:+-j''${NIX_BUILD_CORES}} $makeFlags
|
||||
@ -81,13 +90,15 @@ let
|
||||
doNotPostBuildInstallCargoBinaries = true;
|
||||
enableParallelInstalling = true;
|
||||
installPhaseCommand = ''
|
||||
make ''${enableParallelInstalling:+-j''${NIX_BUILD_CORES}} $makeFlags install
|
||||
make ''${enableParallelInstalling:+-j''${NIX_BUILD_CORES}} $makeFlags install install_dkms
|
||||
'';
|
||||
|
||||
doInstallCheck = true;
|
||||
nativeInstallCheckInputs = [ versionCheckHook ];
|
||||
versionCheckProgramArg = "version";
|
||||
|
||||
passthru.kernelModule = import ./module-build.nix package;
|
||||
|
||||
meta = {
|
||||
description = "Userspace tools for bcachefs";
|
||||
license = lib.licenses.gpl2Only;
|
||||
|
||||
@ -93,6 +93,12 @@
|
||||
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;
|
||||
@ -109,6 +115,8 @@
|
||||
bcachefs-tools-aarch64-linux
|
||||
bcachefs-tools-fuse
|
||||
bcachefs-tools-fuse-i686-linux
|
||||
bcachefs-module-linux-latest
|
||||
bcachefs-module-linux-testing
|
||||
;
|
||||
inherit (pkgs.callPackage ./crane-build.nix { inherit crane version; })
|
||||
# cargo-clippy
|
||||
|
||||
67
module-build.nix
Normal file
67
module-build.nix
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
Copyright (c) 2003-2025 Eelco Dolstra and the Nixpkgs/NixOS contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
bcachefs-tools:
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
kernelModuleMakeFlags,
|
||||
kernel,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
pname = "bcachefs";
|
||||
version = "${kernel.version}-${bcachefs-tools.version}";
|
||||
|
||||
__structuredAttrs = true;
|
||||
|
||||
src = bcachefs-tools.dkms;
|
||||
|
||||
nativeBuildInputs = kernel.moduleBuildDependencies;
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
makeFlags = kernelModuleMakeFlags ++ [
|
||||
"KDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
|
||||
"INSTALL_MOD_PATH=${placeholder "out"}"
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build M=$(pwd) modules_install "''${makeFlags[@]}" "''${installFlags[@]}"
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
inherit (bcachefs-tools.passthru) tests;
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "out-of-tree bcachefs kernel module";
|
||||
|
||||
inherit (bcachefs-tools.meta)
|
||||
license
|
||||
maintainers
|
||||
;
|
||||
};
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user