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