Skip to content

I got it working with NixOS #33

Open
@camilosampedro

Description

@camilosampedro

My NAS is a AS6702T.

The way I built it was using:

asustor-module.nix:

{ stdenv, lib, fetchFromGitHub, kernel, kmod }:

stdenv.mkDerivation rec {
  pname = "asustor-platform-driver";
  version = "0.1";

  src = fetchFromGitHub {
    owner = "mafredri";
    repo = "asustor-platform-driver";
    rev = "main";
    hash = "sha256-Woy0KyJOUOaPAv5GzcUlqMdH5b+/zZPo4vqgjhgByH8=";
  };

  buildInputs = [ kmod ];

  sourceRoot = "source/";
  hardeningDisable = [ "pic" "format" ]; # 1
  nativeBuildInputs = [ kmod ] ++ kernel.moduleBuildDependencies; # 2

  makeFlags = [
    "TARGET=${kernel.modDirVersion}"
    "KERNELRELEASE=${kernel.modDirVersion}" # 3
    "KERNEL_BUILD=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" # 4
    "INSTALL_MOD_PATH=$(out)" # 5
    "KERNEL_MODULES=$(out)/lib/modules/${kernel.modDirVersion}"
    "SYSTEM_MAP=$(out)/boot/System.map-${kernel.modDirVersion}" # 6
  ];

  prePatch = ''
    mkdir -p $out/boot/
    ln -s ${kernel}/System.map $out/boot/System.map-${kernel.modDirVersion}
  '';

  preBuild = ''
    substituteInPlace Makefile --replace-fail "/usr/bin/install" "install"
    substituteInPlace Makefile --replace-fail "/lib/modules/" "$(out)/lib/modules/"
    substituteInPlace Makefile --replace-fail "/boot/" "$(out)/boot/"
    substituteInPlace Makefile --replace-fail "/usr/src/asustor-" "$(out)/usr/src/asustor-"
    substituteInPlace Makefile --replace-fail "depmod" "depmod -b '${kernel.dev}'" 
  '';

  meta = {
    description = "A kernel module to create V4L2 loopback devices";
    homepage = "https://github.com/mafredri/asustor-platform-driver";
    license = lib.licenses.gpl2;
    maintainers = [ "camilosampedro" ];
    platforms = lib.platforms.linux;
  };
}

And in home-configurations.nix:

{ config, ... }:

let
  asustor-module =
    config.boot.kernelPackages.callPackage ./asustor-module.nix { };
in {
  boot.extraModulePackages = [ asustor-module ];
}

It must not be the cleanest way, but it seems to work. If I make further changes I can comment on here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions