base.nix (4479B)
1 ## Base options 2 ## ============ 3 4 5 { lib, pkgs, config, ...}: 6 let 7 inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ; 8 inherit (pkgs.pseudofile) dir symlink; 9 inherit (pkgs.liminix.networking) address interface; 10 inherit (pkgs.liminix.services) bundle; 11 12 type_service = pkgs.liminix.lib.types.service; 13 14 in { 15 imports = [ 16 ./kernel # kernel is a separate module for doc purposes 17 ]; 18 options = { 19 defaultProfile = { 20 packages = mkOption { 21 type = types.listOf types.package; 22 description = '' 23 List of packages which are available in a login shell. (This 24 is analogous to systemPackages in NixOS, but we don't symlink into 25 /run/current-system, we just add the paths in /etc/profile 26 ''; 27 }; 28 }; 29 services = mkOption { 30 type = types.attrsOf type_service; 31 }; 32 filesystem = mkOption { 33 type = types.anything; 34 description = '' 35 Skeleton filesystem, represented as nested attrset. Consult the 36 source code if you need to add to this 37 ''; 38 # internal = true; # probably a good case to make this internal 39 }; 40 rootfsType = mkOption { 41 default = "squashfs"; 42 type = types.enum [ 43 "btrfs" 44 "ext4" 45 "jffs2" 46 "squashfs" 47 "ubifs" 48 ]; 49 }; 50 rootOptions = mkOption { 51 type = types.nullOr types.str; 52 default = null; 53 }; 54 55 boot = { 56 commandLine = mkOption { 57 type = types.listOf types.nonEmptyStr; 58 default = []; 59 description = "Kernel command line"; 60 }; 61 commandLineDtbNode = mkOption { 62 type = types.enum [ "bootargs" "bootargs-override" ]; 63 default = "bootargs"; 64 description = "Kernel command line's devicetree node"; 65 }; 66 imageType = mkOption { 67 type = types.enum [ "primary" "secondary" ]; 68 default = "primary"; 69 }; 70 imageFormat = mkOption { 71 type = types.enum ["fit" "uimage"]; 72 default = "uimage"; 73 }; 74 tftp = { 75 loadAddress = mkOption { 76 type = types.ints.unsigned; 77 description = '' 78 RAM address at which to load data when transferring via 79 TFTP. This is not the address of the flash storage, 80 nor the kernel load address: it should be set to some part 81 of RAM that's not used for anything else and suitable for 82 temporary storage. 83 ''; 84 }; 85 # These names match the uboot environment variables. I reserve 86 # the right to change them if I think of better ones. 87 ipaddr = mkOption { 88 type = types.str; 89 description = '' 90 Our IP address to use when creating scripts to 91 boot or flash from U-Boot. Not relevant in normal operation 92 ''; 93 }; 94 serverip = mkOption { 95 type = types.str; 96 description = '' 97 IP address of the TFTP server. Not relevant in normal operation 98 ''; 99 }; 100 }; 101 }; 102 }; 103 config = { 104 defaultProfile.packages = with pkgs; 105 [ s6 s6-init-bin execline s6-linux-init s6-rc ]; 106 107 boot.commandLine = [ 108 "panic=10 oops=panic init=/bin/init loglevel=8" 109 "root=${config.hardware.rootDevice}" 110 "rootfstype=${config.rootfsType}" 111 "fw_devlink=off" 112 ] ++ lib.optional (config.rootOptions != null) "rootflags=${config.rootOptions}"; 113 114 users.root = { 115 uid = 0; gid= 0; gecos = "Root of all evaluation"; 116 dir = "/home/root/"; 117 passwd = lib.mkDefault ""; 118 shell = "/bin/sh"; 119 }; 120 groups = { 121 root = { 122 gid = 0; usernames = ["root"]; 123 }; 124 system = { 125 gid = 1; usernames = ["root"]; 126 }; 127 }; 128 129 filesystem = dir { 130 dev = 131 let node = type: major: minor: mode : { inherit type major minor mode; }; 132 in dir { 133 null = node "c" "1" "3" "0666"; 134 zero = node "c" "1" "5" "0666"; 135 tty = node "c" "5" "0" "0666"; 136 console = node "c" "5" "1" "0600"; 137 pts = dir {}; 138 }; 139 etc = let 140 profile = symlink 141 (pkgs.writeScript ".profile" '' 142 PATH=${lib.makeBinPath config.defaultProfile.packages}:/bin 143 export PATH 144 ''); 145 in dir { 146 inherit profile; 147 ashrc = profile; 148 }; 149 150 proc = dir {}; 151 run = dir {}; 152 sys = dir {}; 153 tmp = dir {}; 154 }; 155 }; 156 }