2023-08-09 23:27:37 +02:00
|
|
|
## Base options
|
|
|
|
## ============
|
|
|
|
|
|
|
|
|
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;
|
2023-03-07 23:02:24 +01:00
|
|
|
inherit (pkgs.liminix.networking) address interface;
|
|
|
|
inherit (pkgs.liminix.services) bundle;
|
2022-09-26 19:27:43 +02:00
|
|
|
|
2023-07-14 21:22:29 +02:00
|
|
|
type_service = pkgs.liminix.lib.types.service;
|
2022-09-26 12:46:09 +02:00
|
|
|
|
2022-09-25 12:22:15 +02:00
|
|
|
in {
|
2023-08-11 19:15:17 +02:00
|
|
|
imports = [
|
|
|
|
./kernel.nix # this is a separate module for doc purposes
|
|
|
|
];
|
2022-09-25 12:22:15 +02:00
|
|
|
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; };
|
2023-04-10 20:59:09 +02:00
|
|
|
rootfsType = mkOption {
|
|
|
|
default = "squashfs";
|
|
|
|
type = types.str;
|
|
|
|
};
|
2023-02-18 16:13:19 +01:00
|
|
|
boot = {
|
|
|
|
commandLine = mkOption {
|
|
|
|
type = types.listOf types.nonEmptyStr;
|
|
|
|
default = [];
|
|
|
|
};
|
2023-03-18 15:45:51 +01:00
|
|
|
tftp = {
|
|
|
|
loadAddress = mkOption { type = types.str; };
|
|
|
|
# These names match the uboot environment variables. I reserve
|
|
|
|
# the right to change them if I think of better ones.
|
|
|
|
ipaddr = mkOption { type = types.str; };
|
|
|
|
serverip = mkOption { type = types.str; };
|
|
|
|
};
|
2023-02-10 19:20:01 +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;
|
2023-03-10 19:40:45 +01:00
|
|
|
[ s6 s6-init-bin execline s6-linux-init s6-rc ];
|
2022-09-28 22:31:15 +02:00
|
|
|
|
2023-03-07 23:02:24 +01: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-07 01:21:04 +02:00
|
|
|
boot.commandLine = [
|
2023-04-10 20:59:09 +02:00
|
|
|
"console=ttyS0,115200 panic=10 oops=panic init=/bin/init loglevel=8"
|
2023-04-26 23:16:15 +02:00
|
|
|
"root=${config.hardware.rootDevice}"
|
2023-04-10 20:59:09 +02:00
|
|
|
"rootfstype=${config.rootfsType}"
|
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";
|
2023-03-18 15:46:50 +01:00
|
|
|
dir = "/home/root/";
|
2023-03-04 01:24:48 +01:00
|
|
|
passwd = lib.mkDefault "";
|
2022-09-28 22:31:15 +02:00
|
|
|
shell = "/bin/sh";
|
|
|
|
};
|
2023-02-25 21:33:18 +01:00
|
|
|
groups = {
|
|
|
|
root = {
|
|
|
|
gid = 0; usernames = ["root"];
|
|
|
|
};
|
2023-02-25 23:53:06 +01:00
|
|
|
system = {
|
|
|
|
gid = 1; usernames = ["root"];
|
|
|
|
};
|
2022-09-28 22:31:15 +02:00
|
|
|
};
|
|
|
|
|
2022-09-27 17:33:58 +02:00
|
|
|
filesystem = dir {
|
2022-09-27 15:06:07 +02: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 {};
|
|
|
|
};
|
2023-05-21 18:08:32 +02:00
|
|
|
etc = let
|
2022-09-26 21:45:00 +02:00
|
|
|
profile = symlink
|
|
|
|
(pkgs.writeScript ".profile" ''
|
2023-05-21 18:08:32 +02:00
|
|
|
PATH=${lib.makeBinPath config.defaultProfile.packages}:/bin
|
2022-09-26 21:45:00 +02:00
|
|
|
export PATH
|
2023-05-21 18:08:32 +02:00
|
|
|
'');
|
|
|
|
in dir {
|
|
|
|
inherit profile;
|
|
|
|
ashrc = profile;
|
2022-09-26 21:45:00 +02:00
|
|
|
};
|
2023-05-21 18:08:32 +02:00
|
|
|
|
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
|
|
|
}
|