-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89e029b
commit 855157b
Showing
2 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{ | ||
description = "Install Asustor kernel modules on NixOS"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; | ||
}; | ||
|
||
outputs = { self, nixpkgs }: | ||
let | ||
system = "x86_64-linux"; | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
module = | ||
({ stdenv, lib, kernel, kmod, ... }: | ||
|
||
stdenv.mkDerivation rec { | ||
name = "asustor-platform-driver-${version}-${kernel.version}"; | ||
version = "0.1"; | ||
|
||
src = ./.; | ||
|
||
hardeningDisable = [ "pic" "format" ]; | ||
# Install kmod for depmod dependency if we need it | ||
#nativeBuildInputs = kernel.moduleBuildDependencies ++ [ kmod ]; | ||
nativeBuildInputs = kernel.moduleBuildDependencies; | ||
|
||
buildFlags = [ | ||
"KERNEL_MODULES=${kernel.dev}/lib/modules/${kernel.modDirVersion}" | ||
]; | ||
installFlags = [ | ||
"KERNEL_MODULES=${placeholder "out"}/lib/modules/${kernel.modDirVersion}" | ||
]; | ||
|
||
# TODO: check if we need depmod. | ||
preConfigure = '' | ||
sed -i 's|depmod|#depmod|' Makefile | ||
''; | ||
|
||
meta = with lib; { | ||
description = "A kernel module to support Asustor devices"; | ||
homepage = "https://github.com/mafredri/asustor-platform-driver"; | ||
license = licenses.gpl3; | ||
maintainers = [ ]; | ||
platforms = platforms.linux; | ||
}; | ||
}); | ||
in | ||
{ | ||
packages.${system}.default = pkgs.callPackage ./default.nix { }; | ||
nixosModules.default = ({ config, lib, ... }: | ||
let | ||
asustor-platform-driver = config.boot.kernelPackages.callPackage module { }; | ||
in | ||
{ | ||
options = { | ||
hardware.asustor.enable = lib.mkEnableOption "Enable the Asustor kernel module"; | ||
}; | ||
config = lib.mkIf config.hardware.asustor.enable { | ||
boot.extraModulePackages = [ asustor-platform-driver ]; | ||
}; | ||
}); | ||
formatter.${system} = pkgs.nixpkgs-fmt; | ||
}; | ||
} |