2023-08-09 22:27:37 +01:00
|
|
|
## Base options
|
|
|
|
## ============
|
|
|
|
|
|
|
|
|
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-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
|
|
|
|
2023-07-14 20:22:29 +01:00
|
|
|
type_service = pkgs.liminix.lib.types.service;
|
2022-09-26 11:46:09 +01:00
|
|
|
|
2022-09-25 11:22:15 +01:00
|
|
|
in {
|
2023-08-11 18:15:17 +01:00
|
|
|
imports = [
|
2023-08-12 20:11:43 +01:00
|
|
|
./kernel.nix # kernel is a separate module for doc purposes
|
2023-08-11 18:15:17 +01:00
|
|
|
];
|
2022-09-25 11:22:15 +01:00
|
|
|
options = {
|
2022-09-27 16:17:55 +01:00
|
|
|
defaultProfile = {
|
|
|
|
packages = mkOption {
|
|
|
|
type = types.listOf types.package;
|
2023-08-12 20:11:43 +01:00
|
|
|
description = ''
|
|
|
|
List of packages which are available in a login shell. (This
|
|
|
|
is analogous to systemPackages in NixOS, but we don't symlink into
|
|
|
|
/run/current-system, we just add the paths in /etc/profile
|
|
|
|
'';
|
2022-09-27 16:17:55 +01:00
|
|
|
};
|
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
|
|
|
};
|
2023-08-12 20:11:43 +01:00
|
|
|
filesystem = mkOption {
|
|
|
|
type = types.anything;
|
|
|
|
description = ''
|
|
|
|
Skeleton filesystem, represented as nested attrset. Consult the
|
|
|
|
source code if you need to add to this
|
|
|
|
'';
|
|
|
|
# internal = true; # probably a good case to make this internal
|
|
|
|
};
|
2023-04-10 19:59:09 +01:00
|
|
|
rootfsType = mkOption {
|
|
|
|
default = "squashfs";
|
2023-11-06 21:52:31 +00:00
|
|
|
type = types.enum [
|
|
|
|
"ext4"
|
|
|
|
"jffs2"
|
|
|
|
"squashfs"
|
|
|
|
"ubifs"
|
|
|
|
];
|
2023-04-10 19:59:09 +01:00
|
|
|
};
|
2023-02-18 15:13:19 +00:00
|
|
|
boot = {
|
|
|
|
commandLine = mkOption {
|
|
|
|
type = types.listOf types.nonEmptyStr;
|
|
|
|
default = [];
|
2023-08-12 20:11:43 +01:00
|
|
|
description = "Kernel command line";
|
2023-02-18 15:13:19 +00:00
|
|
|
};
|
2023-10-08 22:35:30 +01:00
|
|
|
imageFormat = mkOption {
|
|
|
|
type = types.enum ["fit" "uimage"];
|
|
|
|
default = "uimage";
|
|
|
|
};
|
2023-03-18 14:45:51 +00:00
|
|
|
tftp = {
|
2023-08-12 20:11:43 +01:00
|
|
|
loadAddress = mkOption {
|
2023-11-12 18:37:33 +00:00
|
|
|
type = types.ints.unsigned;
|
2023-08-12 20:11:43 +01:00
|
|
|
description = ''
|
|
|
|
RAM address at which to load data when transferring via
|
|
|
|
TFTP. This is not the address of the flash storage,
|
|
|
|
nor the kernel load address: it should be set to some part
|
|
|
|
of RAM that's not used for anything else and suitable for
|
|
|
|
temporary storage.
|
|
|
|
'';
|
|
|
|
};
|
2023-03-18 14:45:51 +00:00
|
|
|
# These names match the uboot environment variables. I reserve
|
|
|
|
# the right to change them if I think of better ones.
|
2023-08-12 20:11:43 +01:00
|
|
|
ipaddr = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
Our IP address to use when creating scripts to
|
|
|
|
boot or flash from U-Boot. Not relevant in normal operation
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
serverip = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
IP address of the TFTP server. Not relevant in normal operation
|
|
|
|
'';
|
|
|
|
};
|
2023-03-18 14:45:51 +00:00
|
|
|
};
|
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
|
|
|
|
2022-10-07 00:21:04 +01:00
|
|
|
boot.commandLine = [
|
2023-09-20 17:27:04 +01:00
|
|
|
"panic=10 oops=panic init=/bin/init loglevel=8"
|
2023-04-26 22:16:15 +01:00
|
|
|
"root=${config.hardware.rootDevice}"
|
2023-04-10 19:59:09 +01:00
|
|
|
"rootfstype=${config.rootfsType}"
|
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";
|
2023-03-18 14:46:50 +00:00
|
|
|
dir = "/home/root/";
|
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 {};
|
|
|
|
};
|
2023-05-21 17:08:32 +01:00
|
|
|
etc = let
|
2022-09-26 20:45:00 +01:00
|
|
|
profile = symlink
|
|
|
|
(pkgs.writeScript ".profile" ''
|
2023-05-21 17:08:32 +01:00
|
|
|
PATH=${lib.makeBinPath config.defaultProfile.packages}:/bin
|
2022-09-26 20:45:00 +01:00
|
|
|
export PATH
|
2023-05-21 17:08:32 +01:00
|
|
|
'');
|
|
|
|
in dir {
|
|
|
|
inherit profile;
|
|
|
|
ashrc = profile;
|
2022-09-26 20:45:00 +01:00
|
|
|
};
|
2023-05-21 17:08:32 +01:00
|
|
|
|
2022-09-27 14:06:07 +01:00
|
|
|
proc = dir {};
|
|
|
|
run = dir {};
|
|
|
|
sys = dir {};
|
2024-01-04 23:22:02 +00:00
|
|
|
tmp = dir {};
|
2022-09-26 20:45:00 +01:00
|
|
|
};
|
|
|
|
};
|
2022-09-25 11:22:15 +01:00
|
|
|
}
|