2022-09-27 17:17:55 +02:00
|
|
|
{ lib, pkgs, config, ...}:
|
2022-09-26 12:46:09 +02:00
|
|
|
let
|
|
|
|
inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ;
|
2022-09-26 19:27:43 +02:00
|
|
|
inherit (pkgs.pseudofile) dir symlink;
|
2022-09-27 15:06:07 +02:00
|
|
|
inherit (pkgs) busybox;
|
2022-09-26 19:27:43 +02:00
|
|
|
|
2022-09-26 12:46:09 +02:00
|
|
|
type_service = types.package // {
|
|
|
|
name = "service";
|
|
|
|
description = "s6-rc service";
|
|
|
|
check = x: isDerivation x && hasAttr "serviceType" x;
|
|
|
|
};
|
|
|
|
|
2022-09-25 12:22:15 +02:00
|
|
|
in {
|
|
|
|
options = {
|
2022-09-27 17:17:55 +02: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 12:22:15 +02:00
|
|
|
};
|
|
|
|
services = mkOption {
|
2022-09-26 12:46:09 +02:00
|
|
|
type = types.attrsOf type_service;
|
2022-09-25 12:22:15 +02:00
|
|
|
};
|
2022-09-27 17:33:58 +02:00
|
|
|
filesystem = mkOption { type = types.anything; };
|
2022-09-26 13:11:26 +02:00
|
|
|
kernel = {
|
2023-02-10 18:54:33 +01:00
|
|
|
src = mkOption { type = types.package; } ;
|
|
|
|
extraPatchPhase = mkOption {
|
|
|
|
default = "true";
|
|
|
|
type = types.lines;
|
|
|
|
} ;
|
2022-09-26 13:11:26 +02: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 12:22:15 +02:00
|
|
|
};
|
2022-09-28 22:31:15 +02:00
|
|
|
groups = mkOption {
|
|
|
|
type = types.attrsOf types.anything;
|
|
|
|
};
|
|
|
|
users = mkOption {
|
|
|
|
type = types.attrsOf types.anything;
|
|
|
|
};
|
2023-02-18 16:13:19 +01:00
|
|
|
boot = {
|
|
|
|
dts = {
|
|
|
|
src = mkOption { type = types.path; };
|
|
|
|
includes = mkOption {
|
|
|
|
default = [];
|
|
|
|
type = types.listOf types.path;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
commandLine = mkOption {
|
|
|
|
type = types.listOf types.nonEmptyStr;
|
|
|
|
default = [];
|
|
|
|
};
|
2023-02-10 19:20:01 +01:00
|
|
|
};
|
2023-02-22 19:31:46 +01:00
|
|
|
device = {
|
|
|
|
defaultOutput = mkOption {
|
|
|
|
type = types.nonEmptyStr;
|
|
|
|
};
|
|
|
|
loadAddress = mkOption { default = null; };
|
|
|
|
entryPoint = mkOption { };
|
2023-02-10 18:54:33 +01:00
|
|
|
};
|
2022-09-25 12:22:15 +02:00
|
|
|
};
|
2022-09-26 21:45:00 +02:00
|
|
|
config = {
|
2022-09-27 17:17:55 +02:00
|
|
|
defaultProfile.packages = with pkgs;
|
2022-10-02 11:02:29 +02:00
|
|
|
[ s6 s6-init-bin busybox execline s6-linux-init s6-rc ];
|
2022-09-28 22:31:15 +02:00
|
|
|
|
2022-10-05 22:50:10 +02:00
|
|
|
kernel = rec {
|
|
|
|
config = {
|
|
|
|
IKCONFIG = "y";
|
|
|
|
IKCONFIG_PROC = "y";
|
|
|
|
PROC_FS = "y";
|
2022-10-09 10:55:30 +02:00
|
|
|
|
|
|
|
MODULES = "y";
|
2023-02-22 19:20:56 +01:00
|
|
|
MODULE_SIG = "y";
|
|
|
|
DEBUG_FS = "y";
|
2022-10-09 10:55:30 +02:00
|
|
|
|
2022-10-18 23:28:07 +02:00
|
|
|
# basic networking protocols
|
|
|
|
NET = "y";
|
2022-10-18 16:48:37 +02:00
|
|
|
UNIX = "y";
|
2022-10-18 19:56:29 +02:00
|
|
|
INET = "y";
|
|
|
|
IPV6 = "y";
|
2022-10-18 23:28:07 +02:00
|
|
|
PACKET = "y"; # for ppp, tcpdump ...
|
|
|
|
SYSVIPC= "y";
|
2022-10-18 16:48:37 +02:00
|
|
|
|
2022-10-07 01:21:04 +02:00
|
|
|
# s6-linux-init mounts this on /dev
|
|
|
|
DEVTMPFS = "y";
|
2022-10-08 00:26:24 +02:00
|
|
|
# some or all of these may be fix for "tmpfs: Unknown parameter 'mode'" error
|
|
|
|
TMPFS = "y";
|
|
|
|
TMPFS_POSIX_ACL = "y";
|
|
|
|
TMPFS_XATTR = "y";
|
2022-10-05 22:50:10 +02:00
|
|
|
};
|
2022-10-02 11:03:17 +02:00
|
|
|
};
|
2022-10-07 01:21:04 +02:00
|
|
|
boot.commandLine = [
|
|
|
|
"earlyprintk=serial,ttyS0 console=ttyS0,115200 panic=10 oops=panic init=/bin/init loglevel=8 rootfstype=squashfs"
|
2022-10-15 17:11:40 +02:00
|
|
|
"fw_devlink=off"
|
2022-10-07 01:21:04 +02:00
|
|
|
];
|
2022-09-28 22:31:15 +02:00
|
|
|
users.root = {
|
|
|
|
uid = 0; gid= 0; gecos = "Root of all evaluation";
|
|
|
|
dir = "/";
|
|
|
|
passwd = "";
|
|
|
|
shell = "/bin/sh";
|
|
|
|
};
|
|
|
|
groups.root = {
|
|
|
|
gid = 0; usernames = ["root"];
|
|
|
|
};
|
|
|
|
|
2022-09-27 17:33:58 +02:00
|
|
|
filesystem = dir {
|
2022-09-27 15:06:07 +02:00
|
|
|
bin = dir {
|
|
|
|
sh = symlink "${busybox}/bin/sh";
|
|
|
|
busybox = symlink "${busybox}/bin/busybox";
|
|
|
|
};
|
|
|
|
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 21:45:00 +02:00
|
|
|
etc = dir {
|
|
|
|
profile = symlink
|
|
|
|
(pkgs.writeScript ".profile" ''
|
2022-09-27 17:17:55 +02:00
|
|
|
PATH=${lib.makeBinPath config.defaultProfile.packages}
|
2022-09-26 21:45:00 +02:00
|
|
|
export PATH
|
|
|
|
'');
|
|
|
|
};
|
2022-09-27 15:06:07 +02:00
|
|
|
proc = dir {};
|
|
|
|
run = dir {};
|
|
|
|
sys = dir {};
|
2022-09-26 21:45:00 +02:00
|
|
|
};
|
|
|
|
};
|
2022-09-25 12:22:15 +02:00
|
|
|
}
|