b9c0d93670
This changes the practice for building kernel modules: now we expect that the appropriate Kconfig symbols are set to =m in config.kernel.config, and then use pkgs.kmodloader to create a service that loads and unloads all the modules depended on by a particular requirement. Note that modules won't be installed on the target device just by virue of having been built: only the modules that are referenced by a kmodloader package will be in the closure. An example may make this clearer: see modules/firewall/default.nix in this commit. Why? If you have a compiled Linux kernel source tree and you change some symbol from "is not set" to m and then run make modules, you cannot in general expect that newly compiled module to work. This is because there are places in the build of the main kernel where it looks to see which modules _may_ be defined and uses that information to accommodate them. For example in an in-kernel build of https://github.com/torvalds/linux/blob/master/net/netfilter/core.c#L689 some symbols are defined only if CONFIG_NF_CONNTRACK is set, meaning this code won't work if we have it unset initially then try later to enable it and build modules only. Or see https://github.com/torvalds/linux/blob/master/include/linux/netdevice.h#L160
111 lines
4.1 KiB
Nix
111 lines
4.1 KiB
Nix
{
|
|
callPackage
|
|
, lib
|
|
}:
|
|
let
|
|
typeChecked = caller: type: value:
|
|
let
|
|
inherit (lib) types mergeDefinitions;
|
|
defs = [{ file = caller; inherit value; }];
|
|
type' = types.submodule { options = type; };
|
|
in (mergeDefinitions [] type' defs).mergedValue;
|
|
in {
|
|
liminix = {
|
|
builders = {
|
|
squashfs = callPackage ./liminix-tools/builders/squashfs.nix {};
|
|
dtb = callPackage ./kernel/dtb.nix {};
|
|
uimage = callPackage ./kernel/uimage.nix {};
|
|
kernel = callPackage ./kernel {};
|
|
};
|
|
callService = path : parameters :
|
|
let pkg = callPackage path {};
|
|
checkTypes = t : p : typeChecked (builtins.toString path) t p;
|
|
in {
|
|
inherit parameters;
|
|
build = { dependencies ? [], ... } @ args :
|
|
let
|
|
s = pkg (checkTypes parameters
|
|
(builtins.removeAttrs args ["dependencies"]));
|
|
in s.overrideAttrs (o: {
|
|
dependencies = (builtins.map (d: d.name) dependencies) ++ o.dependencies;
|
|
buildInputs = dependencies ++ o.buildInputs;
|
|
});
|
|
};
|
|
lib = {
|
|
types =
|
|
let inherit (lib) types isDerivation;
|
|
in rec {
|
|
service = types.package // {
|
|
name = "service";
|
|
description = "s6-rc service";
|
|
check = x: isDerivation x && x ? serviceType;
|
|
};
|
|
interface = service;
|
|
serviceDefn = types.attrs // {
|
|
name = "service-defn";
|
|
description = "parametrisable s6-rc service definition";
|
|
check = x: lib.isAttrs x && x ? parameters && x ? build;
|
|
};
|
|
};
|
|
inherit typeChecked;
|
|
};
|
|
networking = callPackage ./liminix-tools/networking {};
|
|
services = callPackage ./liminix-tools/services {};
|
|
};
|
|
|
|
# please keep the rest of this list alphabetised :-)
|
|
|
|
anoia = callPackage ./anoia {};
|
|
fennel = callPackage ./fennel {};
|
|
fennelrepl = callPackage ./fennelrepl {};
|
|
firewallgen = callPackage ./firewallgen {};
|
|
firmware-utils = callPackage ./firmware-utils {};
|
|
gen_init_cpio = callPackage ./gen_init_cpio {};
|
|
go-l2tp = callPackage ./go-l2tp {};
|
|
hi = callPackage ./hi {};
|
|
ifwait = callPackage ./ifwait {};
|
|
initramfs-peek = callPackage ./initramfs-peek {};
|
|
kernel-backport = callPackage ./kernel-backport {};
|
|
kernel-modules = callPackage ./kernel-modules {};
|
|
kmodloader = callPackage ./kmodloader {};
|
|
levitate = callPackage ./levitate {};
|
|
libubootenv = callPackage ./libubootenv {};
|
|
linotify = callPackage ./linotify {};
|
|
|
|
# we need to build real lzma instead of using xz, because the lzma
|
|
# decoder in u-boot doesn't understand streaming lzma archives
|
|
# ("Stream with EOS marker is not supported") and xz can't create
|
|
# non-streaming ones. See
|
|
# https://sourceforge.net/p/squashfs/mailman/message/26599379/
|
|
lzma = callPackage ./lzma {};
|
|
|
|
mac80211 = callPackage ./mac80211 {};
|
|
min-collect-garbage = callPackage ./min-collect-garbage {};
|
|
min-copy-closure = callPackage ./min-copy-closure {};
|
|
netlink-lua = callPackage ./netlink-lua {};
|
|
odhcp-script = callPackage ./odhcp-script {};
|
|
odhcp6c = callPackage ./odhcp6c {};
|
|
openwrt = callPackage ./openwrt {};
|
|
ppp = callPackage ./ppp {};
|
|
pppoe = callPackage ./pppoe {};
|
|
preinit = callPackage ./preinit {};
|
|
pseudofile = callPackage ./pseudofile {};
|
|
routeros = callPackage ./routeros {};
|
|
run-liminix-vm = callPackage ./run-liminix-vm {};
|
|
s6-init-bin = callPackage ./s6-init-bin {};
|
|
s6-rc-database = callPackage ./s6-rc-database {};
|
|
|
|
# schnapps is written by Turris and provides a high-level interface
|
|
# to btrfs snapshots. It may be useful on the Turris Omnia to
|
|
# install Liminix while retaining the ability to rollback to the
|
|
# vendor OS, or even to derisk Liminix updates on that device
|
|
schnapps = callPackage ./schnapps {};
|
|
|
|
serviceFns = callPackage ./service-fns {};
|
|
swconfig = callPackage ./swconfig {};
|
|
systemconfig = callPackage ./systemconfig {};
|
|
tufted = callPackage ./tufted {};
|
|
writeAshScript = callPackage ./write-ash-script {};
|
|
writeFennel = callPackage ./write-fennel {};
|
|
writeFennelScript = callPackage ./write-fennel-script {};
|
|
}
|