diff --git a/flake.nix b/flake.nix index 63c68160..2a73ab8b 100644 --- a/flake.nix +++ b/flake.nix @@ -42,6 +42,7 @@ constituents = builtins.attrValues self.packages.${system}; }; } + // (import ./pkgs/tests {inherit pkgs self;}) // (import ./ioc/tests {inherit pkgs self;}) // (import ./nixos/tests/all-tests.nix {inherit nixpkgs pkgs self system;}); diff --git a/pkgs/default.nix b/pkgs/default.nix index c7260268..a285c58d 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -19,6 +19,15 @@ in }) ]; + linuxKernel = + prev.linuxKernel + // { + packagesFor = kernel: + (prev.linuxKernel.packagesFor kernel).extend (final: _prev: { + mrf = final.callPackage ./epnix/kernel-modules/mrf {}; + }); + }; + epnix = recurseExtensible (self: { # EPICS base diff --git a/pkgs/epnix/kernel-modules/mrf/default.nix b/pkgs/epnix/kernel-modules/mrf/default.nix new file mode 100644 index 00000000..2da2ef49 --- /dev/null +++ b/pkgs/epnix/kernel-modules/mrf/default.nix @@ -0,0 +1,43 @@ +{ + stdenv, + lib, + kernel, + epnix, +}: +stdenv.mkDerivation (finalAttrs: { + pname = "mrf-driver"; + + inherit (epnix.support.mrfioc2) version src; + + # Needed for kernel modules + hardeningDisable = ["format" "pic"]; + + nativeBuildInputs = kernel.moduleBuildDependencies; + + enableParallelBuilding = true; + + setSourceRoot = '' + export sourceRoot="$(pwd)/${finalAttrs.src.name}/mrmShared/linux"; + ''; + + makeFlags = + kernel.makeFlags + ++ [ + "-C" + "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" + "KERNELRELEASE=${kernel.modDirVersion}" + "INSTALL_MOD_PATH=$(out)" + "VERSION=${finalAttrs.version}" + "M=$(sourceRoot)" + # Uncomment this line to enable debugging + # "KCFLAGS=-DDBG" + ]; + + buildFlags = ["modules"]; + installTargets = ["modules_install"]; + + meta = { + description = "MRF kernel driver"; + inherit (epnix.support.mrfioc2.meta) homepage license maintainers; + }; +}) diff --git a/pkgs/tests/default.nix b/pkgs/tests/default.nix new file mode 100644 index 00000000..bb76486b --- /dev/null +++ b/pkgs/tests/default.nix @@ -0,0 +1,8 @@ +# For packages that are not directly exposed to the user, +# but should still work. +# +# For example kernel modules, which depend on the kernel version, +# or Python libraries, which depend on the Python version. +{pkgs, ...}: { + mrf-driver-default-linux = pkgs.linuxPackages.mrf; +}