base.nix (4157B)
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 imageFormat = mkOption { 62 type = types.enum ["fit" "uimage"]; 63 default = "uimage"; 64 }; 65 tftp = { 66 loadAddress = mkOption { 67 type = types.ints.unsigned; 68 description = '' 69 RAM address at which to load data when transferring via 70 TFTP. This is not the address of the flash storage, 71 nor the kernel load address: it should be set to some part 72 of RAM that's not used for anything else and suitable for 73 temporary storage. 74 ''; 75 }; 76 # These names match the uboot environment variables. I reserve 77 # the right to change them if I think of better ones. 78 ipaddr = mkOption { 79 type = types.str; 80 description = '' 81 Our IP address to use when creating scripts to 82 boot or flash from U-Boot. Not relevant in normal operation 83 ''; 84 }; 85 serverip = mkOption { 86 type = types.str; 87 description = '' 88 IP address of the TFTP server. Not relevant in normal operation 89 ''; 90 }; 91 }; 92 }; 93 }; 94 config = { 95 defaultProfile.packages = with pkgs; 96 [ s6 s6-init-bin execline s6-linux-init s6-rc ]; 97 98 boot.commandLine = [ 99 "panic=10 oops=panic init=/bin/init loglevel=8" 100 "root=${config.hardware.rootDevice}" 101 "rootfstype=${config.rootfsType}" 102 "fw_devlink=off" 103 ] ++ lib.optional (config.rootOptions != null) "rootflags=${config.rootOptions}"; 104 105 users.root = { 106 uid = 0; gid= 0; gecos = "Root of all evaluation"; 107 dir = "/home/root/"; 108 passwd = lib.mkDefault ""; 109 shell = "/bin/sh"; 110 }; 111 groups = { 112 root = { 113 gid = 0; usernames = ["root"]; 114 }; 115 system = { 116 gid = 1; usernames = ["root"]; 117 }; 118 }; 119 120 filesystem = dir { 121 dev = 122 let node = type: major: minor: mode : { inherit type major minor mode; }; 123 in dir { 124 null = node "c" "1" "3" "0666"; 125 zero = node "c" "1" "5" "0666"; 126 tty = node "c" "5" "0" "0666"; 127 console = node "c" "5" "1" "0600"; 128 pts = dir {}; 129 }; 130 etc = let 131 profile = symlink 132 (pkgs.writeScript ".profile" '' 133 PATH=${lib.makeBinPath config.defaultProfile.packages}:/bin 134 export PATH 135 ''); 136 in dir { 137 inherit profile; 138 ashrc = profile; 139 }; 140 141 proc = dir {}; 142 run = dir {}; 143 sys = dir {}; 144 tmp = dir {}; 145 }; 146 }; 147 }