[Nix-dev] Nix Laziness

Judson Lester nyarly at gmail.com
Sun Aug 28 01:01:39 CEST 2016


I'm trying to get BCC installed on a NixOS installation.

The challenges involved are that BCC isn't in the nixos channel (afaik,
because it hasn't yet been tested with nixos...), BCC relies on kernel
headers and the kernel configuration to do its job (which is to
live-compile kernel modules and install them - made safe by eBPF), and that
BCC requires BPF related configuration enabled in the kernel to work.

I've added this to my nix-defexpr directory:

{ system ? builtins.currentSystem, ... }:
let
  nixpkgs = import ./channels/nixpkgs { inherit system; };
  nixos_cfg = nixpkgs.callPackage /etc/nixos/configuration.nix {};

  nixos_overrides = nixos_cfg.nixpkgs.config.packageOverrides;
  kernelConfigs = pkgs: pkgs // nixos_overrides pkgs // rec {
    linuxPackages = pkgs.linuxPackages // {
      kernel = pkgs.linuxPackages.kernel // nixos_overrides
pkgs.linuxPackages.kernel;
    };
  };


  nixos = kernelConfigs (import ./channels_root/nixos {inherit system; });
in
  {
    inherit nixos;
    inherit nixos_cfg;
    bcc = (nixpkgs.linuxPackagesFor nixos.linuxPackages.kernel
nixos.linuxPackages).bcc;
  }
and in configuration.nix:

  nixpkgs.config = {
    packageOverrides = pkgs: rec {
      stdenv = pkgs.stdenv // {
        platform = pkgs.stdenv.platform // {
          kernelExtraConfig = ''
            BPF y
            BPF_SYSCALL y
            NET_CLS_BPF m
            NET_ACT_BPF m
            BPF_JIT y
            HAVE_BPF_JIT y
            BPF_EVENTS y
          '';
        };
      };
    };
  };


I really like the *idea* here, in that in theory I should be able to use
the bcc expression described in an up to date nixpkgs, with the same kernel
configuration I'm using for NixOS.

What I'm finding through exploration with nix-repl is that the changes I've
made don't effect the outPath (or the derivation) of e.g. nixos.linux, and
therefore have no impact on the bcc expression.

It seems like before the kernelConfig function gets called, the base nixos
expression has already resolved everything, so I'm too late to update the
configuration described in common-config.nix. I don't understand why this
would be or how to address it.

Maybe I need to try something fundamentally different, but I don't want to
just flail around until something seems to work - I'd like to improve my
understanding of Nix.

Judson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20160827/3dc80f95/attachment.html>


More information about the nix-dev mailing list