No more `.dev` on latest kernels?

I’m trying to adapt the gist from that installs droidcam to work on arbitrary kernels (I don’t like this pinning on kernel 4.9), so I tried to import from my configuration.nix the following file (the other nix files being the one from the gist):

{ config, pkgs, lib, ... }:
# Gist from
let v4l2loopback-dc = pkgs.callPackage ./v4l2loopback-dc.nix {
      kernel = config.boot.kernelPackages;
    droidcam = pkgs.callPackage ./droidcam.nix {};
in {
  boot.extraModulePackages = [ v4l2loopback-dc ];
  environment.systemPackages = [ droidcam ];

However it fails with an error:

error: --- EvalError ------------------------------------------------------------------------------------- nix-build
at: (15:19) in file: /etc/nixos/v4l2loopback-dc.nix

    14|   KVER = "${kernel.modDirVersion}";
    15|   KBUILD_DIR = "${}/lib/modules/${kernel.modDirVersion}/build";
      |                   ^

attribute 'dev' missing

I also tried to replace the kernel = ... with kernel = pkgs.linuxPackages_latest;, but the error is the same. Why don’t the new kernels have a .dev attribute? How can I fix this code accordingly?


1 Like

Oh, it seems that the solution is simply to use instead kernel = config.boot.kernelPackages.kernel; (see the leading .kernel). However, I’m not sure if it’s the proper way to configure kernelPackages, as I can’t see lot’s of packages having that structure in nixpkgs. Is there a better way to define a kernel module?

assuming you don’t need this for stage1 boot



  boot.kernelModules = [ "v4l2loopback-dc" ];

and it should work.

If you wanted to override the actual module with a different version, you would change

v4l2loopback-dc = pkgs.callPackage ./v4l2loopback-dc.nix {
      kernel = config.boot.kernelPackages;


v4l2loopback-dc = boot.config.kernelPackages.callPackage ./v4l2loopback-dc.nix { };

To expand on what I mentioned:

pkgs in this case refers to the top-level package set.
boot.config.kernelPackages refers to a nested package set.

This is how the module expression is able to receive a kernel input, as that package does exist within the kernelPackages package set, but doesn’t exist at the top level. Also, with nested package sets is that if they fail to find a dependency at the current package scope, they can always go to the parent scope and search for a dependency there.

feel free to make a PR for the droidcam package.

I got a video which will guide you:

droidcam is not really open to distro packaging, see On packaging this application · Issue #49 · dev47apps/droidcam · GitHub.

I also opened that would make packaging it nicer.

1 Like

Thanks a lot for the clarification @jonringer !

Concerning the packaging @jtojnar how are we supposed to install properly this app without writting an expression for it ? (Even starting from the binaries) Even with buildFHS you can’t install kernel modules I guess (or it should be super dirty)!

You should not really install anything without a package on any distro, unless you want a junkyard for a system.

1 Like

I’ve never seen someone so opposed to people using their software >.>

The problems are real, recall jwz: I would like Debian to stop shipping XScreenSaver. jwz went nuclear but he did have a point.

1 Like

Yes sure, I’m just curious to know if there is a dirty way to run that package if I don’t have time to write a nix expression for it and recompile from source (like can I use steam-run to load kernel modules?).

Btw, thanks a lot for this trick, there is just a typo: boot.config sould be replaced with config.boot.

1 Like