2022-09-27 16:17:55 +01:00
|
|
|
{ lib, pkgs, config, ...}:
|
2022-09-26 11:46:09 +01:00
|
|
|
let
|
|
|
|
inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ;
|
2022-09-26 18:27:43 +01:00
|
|
|
inherit (pkgs.pseudofile) dir symlink;
|
2023-03-10 18:40:45 +00:00
|
|
|
# inherit (pkgs) busybox;
|
2023-03-07 22:02:24 +00:00
|
|
|
inherit (pkgs.liminix.networking) address interface;
|
|
|
|
inherit (pkgs.liminix.services) bundle;
|
2022-09-26 18:27:43 +01:00
|
|
|
|
2022-09-26 11:46:09 +01:00
|
|
|
type_service = types.package // {
|
|
|
|
name = "service";
|
|
|
|
description = "s6-rc service";
|
|
|
|
check = x: isDerivation x && hasAttr "serviceType" x;
|
|
|
|
};
|
|
|
|
|
2022-09-25 11:22:15 +01:00
|
|
|
in {
|
|
|
|
options = {
|
2022-09-27 16:17:55 +01:00
|
|
|
# analogous to nixos systemPackages, but we don't symlink into
|
|
|
|
# /run/current-system, we just add the paths in /etc/profile
|
|
|
|
defaultProfile = {
|
|
|
|
packages = mkOption {
|
|
|
|
type = types.listOf types.package;
|
|
|
|
};
|
2022-09-25 11:22:15 +01:00
|
|
|
};
|
|
|
|
services = mkOption {
|
2022-09-26 11:46:09 +01:00
|
|
|
type = types.attrsOf type_service;
|
2022-09-25 11:22:15 +01:00
|
|
|
};
|
2022-09-27 16:33:58 +01:00
|
|
|
filesystem = mkOption { type = types.anything; };
|
2022-09-26 12:11:26 +01:00
|
|
|
kernel = {
|
2023-02-10 17:54:33 +00:00
|
|
|
src = mkOption { type = types.package; } ;
|
|
|
|
extraPatchPhase = mkOption {
|
|
|
|
default = "true";
|
|
|
|
type = types.lines;
|
|
|
|
} ;
|
2022-09-26 12:11:26 +01:00
|
|
|
config = mkOption {
|
|
|
|
# mostly the values are y n or m, but sometimes
|
|
|
|
# other strings are also used
|
|
|
|
type = types.attrsOf types.nonEmptyStr;
|
|
|
|
};
|
2022-09-25 11:22:15 +01:00
|
|
|
};
|
2023-02-18 15:13:19 +00:00
|
|
|
boot = {
|
|
|
|
commandLine = mkOption {
|
|
|
|
type = types.listOf types.nonEmptyStr;
|
|
|
|
default = [];
|
|
|
|
};
|
2023-02-10 18:20:01 +00:00
|
|
|
};
|
2022-09-25 11:22:15 +01:00
|
|
|
};
|
2022-09-26 20:45:00 +01:00
|
|
|
config = {
|
2022-09-27 16:17:55 +01:00
|
|
|
defaultProfile.packages = with pkgs;
|
2023-03-10 18:40:45 +00:00
|
|
|
[ s6 s6-init-bin execline s6-linux-init s6-rc ];
|
2022-09-28 21:31:15 +01:00
|
|
|
|
2023-03-07 22:02:24 +00:00
|
|
|
hardware.networkInterfaces = {
|
|
|
|
lo =
|
|
|
|
let iface = interface { type = "loopback"; device = "lo";};
|
|
|
|
in bundle {
|
|
|
|
name = "loopback";
|
|
|
|
contents = [
|
|
|
|
(address iface { family = "inet4"; address ="127.0.0.1"; prefixLength = 8;})
|
|
|
|
(address iface { family = "inet6"; address ="::1"; prefixLength = 128;})
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-10-05 21:50:10 +01:00
|
|
|
kernel = rec {
|
|
|
|
config = {
|
|
|
|
IKCONFIG = "y";
|
|
|
|
IKCONFIG_PROC = "y";
|
|
|
|
PROC_FS = "y";
|
2022-10-09 09:55:30 +01:00
|
|
|
|
|
|
|
MODULES = "y";
|
2023-02-22 18:20:56 +00:00
|
|
|
MODULE_SIG = "y";
|
|
|
|
DEBUG_FS = "y";
|
2022-10-09 09:55:30 +01:00
|
|
|
|
2022-10-18 22:28:07 +01:00
|
|
|
# basic networking protocols
|
|
|
|
NET = "y";
|
2022-10-18 15:48:37 +01:00
|
|
|
UNIX = "y";
|
2022-10-18 18:56:29 +01:00
|
|
|
INET = "y";
|
|
|
|
IPV6 = "y";
|
2022-10-18 22:28:07 +01:00
|
|
|
PACKET = "y"; # for ppp, tcpdump ...
|
|
|
|
SYSVIPC= "y";
|
2022-10-18 15:48:37 +01:00
|
|
|
|
2022-10-07 00:21:04 +01:00
|
|
|
# s6-linux-init mounts this on /dev
|
|
|
|
DEVTMPFS = "y";
|
2022-10-07 23:26:24 +01:00
|
|
|
# some or all of these may be fix for "tmpfs: Unknown parameter 'mode'" error
|
|
|
|
TMPFS = "y";
|
|
|
|
TMPFS_POSIX_ACL = "y";
|
|
|
|
TMPFS_XATTR = "y";
|
2023-03-01 18:11:38 +00:00
|
|
|
|
|
|
|
FW_LOADER = "y";
|
|
|
|
FW_LOADER_COMPRESS = "y";
|
|
|
|
# We don't have a user helper, so we get multiple 60s pauses
|
|
|
|
# at boot time unless we disable trying to call it.
|
|
|
|
# https://lkml.org/lkml/2013/8/5/175
|
|
|
|
FW_LOADER_USER_HELPER = "n";
|
2022-10-05 21:50:10 +01:00
|
|
|
};
|
2022-10-02 10:03:17 +01:00
|
|
|
};
|
2022-10-07 00:21:04 +01:00
|
|
|
boot.commandLine = [
|
2023-03-10 00:50:28 +00:00
|
|
|
"console=ttyS0,115200 panic=10 oops=panic init=/bin/init loglevel=8 rootfstype=squashfs"
|
2022-10-15 16:11:40 +01:00
|
|
|
"fw_devlink=off"
|
2022-10-07 00:21:04 +01:00
|
|
|
];
|
2022-09-28 21:31:15 +01:00
|
|
|
users.root = {
|
|
|
|
uid = 0; gid= 0; gecos = "Root of all evaluation";
|
|
|
|
dir = "/";
|
2023-03-04 00:24:48 +00:00
|
|
|
passwd = lib.mkDefault "";
|
2022-09-28 21:31:15 +01:00
|
|
|
shell = "/bin/sh";
|
|
|
|
};
|
2023-02-25 20:33:18 +00:00
|
|
|
groups = {
|
|
|
|
root = {
|
|
|
|
gid = 0; usernames = ["root"];
|
|
|
|
};
|
2023-02-25 22:53:06 +00:00
|
|
|
system = {
|
|
|
|
gid = 1; usernames = ["root"];
|
|
|
|
};
|
2022-09-28 21:31:15 +01:00
|
|
|
};
|
|
|
|
|
2022-09-27 16:33:58 +01:00
|
|
|
filesystem = dir {
|
2022-09-27 14:06:07 +01:00
|
|
|
dev =
|
|
|
|
let node = type: major: minor: mode : { inherit type major minor mode; };
|
|
|
|
in dir {
|
|
|
|
null = node "c" "1" "3" "0666";
|
|
|
|
zero = node "c" "1" "5" "0666";
|
|
|
|
tty = node "c" "5" "0" "0666";
|
|
|
|
console = node "c" "5" "1" "0600";
|
|
|
|
pts = dir {};
|
|
|
|
};
|
2022-09-26 20:45:00 +01:00
|
|
|
etc = dir {
|
|
|
|
profile = symlink
|
|
|
|
(pkgs.writeScript ".profile" ''
|
2023-03-10 18:40:45 +00:00
|
|
|
PATH=${lib.makeBinPath config.defaultProfile.packages}:/bin
|
2022-09-26 20:45:00 +01:00
|
|
|
export PATH
|
|
|
|
'');
|
|
|
|
};
|
2022-09-27 14:06:07 +01:00
|
|
|
proc = dir {};
|
|
|
|
run = dir {};
|
|
|
|
sys = dir {};
|
2022-09-26 20:45:00 +01:00
|
|
|
};
|
|
|
|
};
|
2022-09-25 11:22:15 +01:00
|
|
|
}
|