1 { pkgs, lib, config, host, modulesPath, ... }:
4 "${modulesPath}/installer/sd-card/sd-image.nix"
7 # Too CPU hungry for this hardware, for too little Mio saved
8 nix.autoOptimiseStore = false;
10 powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand";
12 boot.supportedFilesystems = [
23 # The serial ports listed here are:
24 # - ttyS0: for Tegra (Jetson TK1)
25 # - ttymxc0: for i.MX6 (Wandboard)
26 # - ttyAMA0: for Allwinner (pcDuino3 Nano) and QEMU's -machine virt
27 # - ttyO0: for OMAP (BeagleBone Black)
28 # - ttySAC2: for Exynos (ODROID-XU3)
29 boot.consoleLogLevel = lib.mkDefault 7;
31 "console=ttyS0,115200n8"
32 "console=ttymxc0,115200n8"
33 "console=ttyAMA0,115200n8"
34 "console=ttyO0,115200n8"
35 "console=ttySAC2,115200n8"
39 #nixpkgs.config.allowUnfree = true;
40 nixpkgs.crossSystem = lib.systems.examples.armv7l-hf-multiplatform;
43 # https://linux-sunxi.org/Mali_Open_Source_Driver#Configuration_and_Build
44 mesa = super.mesa.override {
46 eglPlatforms = ["x11"];
47 enableGalliumNine = false;
48 galliumDrivers = ["lima" "panfrost" "kmsro" "swrast"];
53 linuxPackages_latest_Cubieboard2 = super.linuxPackages_latest.extend (kself: ksuper: {
54 kernel = ksuper.kernel.override {
55 defconfig = "sunxi_defconfig";
56 structuredExtraConfig = with lib.kernel; {
63 EXT4_USE_FOR_EXT2 = yes;
68 TCP_CONG_BBR = module;
70 IPV6_ROUTER_PREF = yes;
71 IPV6_ROUTE_INFO = yes;
72 IPV6_OPTIMISTIC_DAD = yes;
75 INET6_ESP_OFFLOAD = module;
77 INET6_IPCOMP = module;
80 INET6_XFRM_TUNNEL = module;
81 INET6_TUNNEL = module;
85 IPV6_NDISC_NODETYPE = yes;
87 IPV6_MULTIPLE_TABLES = yes;
90 IPV6_MROUTE_MULTIPLE_TABLES = yes;
92 IPV6_SEG6_LWTUNNEL = yes;
94 IPV6_RPL_LWTUNNEL = yes;
95 # CONFIG_MPTCP is not set
96 # CONFIG_NETWORK_SECMARK is not set
97 NET_PTP_CLASSIFY = yes;
98 # CONFIG_NETWORK_PHY_TIMESTAMPING is not set
100 NETFILTER_ADVANCED = yes;
103 # Core Netfilter Configuration
105 NETFILTER_INGRESS = yes;
106 NETFILTER_NETLINK = module;
107 NETFILTER_FAMILY_ARP = yes;
108 NETFILTER_NETLINK_HOOK = module;
109 NETFILTER_NETLINK_ACCT = module;
110 NETFILTER_NETLINK_QUEUE = module;
111 NETFILTER_NETLINK_LOG = module;
112 NETFILTER_NETLINK_OSF = module;
113 NF_CONNTRACK = module;
114 NF_LOG_SYSLOG = module;
115 NETFILTER_CONNCOUNT = module;
116 NF_CONNTRACK_MARK = yes;
117 NF_CONNTRACK_ZONES = yes;
118 NF_CONNTRACK_PROCFS = yes;
119 NF_CONNTRACK_EVENTS = yes;
120 NF_CONNTRACK_TIMEOUT = yes;
121 NF_CONNTRACK_TIMESTAMP = yes;
122 NF_CONNTRACK_LABELS = yes;
123 NF_CT_PROTO_DCCP = yes;
124 NF_CT_PROTO_SCTP = yes;
125 NF_CT_PROTO_UDPLITE = yes;
126 # CONFIG_NF_CONNTRACK_AMANDA is not set
127 # CONFIG_NF_CONNTRACK_FTP is not set
128 # CONFIG_NF_CONNTRACK_H323 is not set
129 # CONFIG_NF_CONNTRACK_IRC is not set
130 # CONFIG_NF_CONNTRACK_NETBIOS_NS is not set
131 # CONFIG_NF_CONNTRACK_SNMP is not set
132 # CONFIG_NF_CONNTRACK_PPTP is not set
133 # CONFIG_NF_CONNTRACK_SANE is not set
134 # CONFIG_NF_CONNTRACK_SIP is not set
135 # CONFIG_NF_CONNTRACK_TFTP is not set
136 NF_CT_NETLINK = module;
137 NF_CT_NETLINK_TIMEOUT = module;
138 NF_CT_NETLINK_HELPER = module;
139 NETFILTER_NETLINK_GLUE_CT = yes;
141 NF_NAT_REDIRECT = yes;
142 NF_NAT_MASQUERADE = yes;
143 NETFILTER_SYNPROXY = module;
145 NF_TABLES_INET = yes;
146 NF_TABLES_NETDEV = yes;
149 NFT_COUNTER = module;
150 NFT_CONNLIMIT = module;
161 NFT_REJECT_INET = module;
165 NFT_FIB_INET = module;
170 NFT_SYNPROXY = module;
171 NF_DUP_NETDEV = module;
172 NFT_DUP_NETDEV = module;
173 NFT_FWD_NETDEV = module;
174 NFT_FIB_NETDEV = module;
175 NFT_REJECT_NETDEV = module;
176 # CONFIG_NF_FLOW_TABLE is not set
177 NETFILTER_XTABLES = module;
180 # Xtables combined modules
182 NETFILTER_XT_MARK = module;
183 NETFILTER_XT_CONNMARK = module;
184 NETFILTER_XT_SET = module;
189 NETFILTER_XT_TARGET_CHECKSUM = module;
190 NETFILTER_XT_TARGET_CLASSIFY = module;
191 NETFILTER_XT_TARGET_CONNMARK = module;
192 NETFILTER_XT_TARGET_CT = module;
193 NETFILTER_XT_TARGET_DSCP = module;
194 NETFILTER_XT_TARGET_HL = module;
195 NETFILTER_XT_TARGET_HMARK = module;
196 NETFILTER_XT_TARGET_IDLETIMER = module;
197 NETFILTER_XT_TARGET_LED = module;
198 NETFILTER_XT_TARGET_LOG = module;
199 NETFILTER_XT_TARGET_MARK = module;
200 NETFILTER_XT_NAT = module;
201 NETFILTER_XT_TARGET_NETMAP = module;
202 NETFILTER_XT_TARGET_NFLOG = module;
203 NETFILTER_XT_TARGET_NFQUEUE = module;
204 NETFILTER_XT_TARGET_NOTRACK = module;
205 NETFILTER_XT_TARGET_RATEEST = module;
206 NETFILTER_XT_TARGET_REDIRECT = module;
207 NETFILTER_XT_TARGET_MASQUERADE = module;
208 NETFILTER_XT_TARGET_TEE = module;
209 NETFILTER_XT_TARGET_TPROXY = module;
210 NETFILTER_XT_TARGET_TRACE = module;
211 NETFILTER_XT_TARGET_TCPMSS = module;
212 NETFILTER_XT_TARGET_TCPOPTSTRIP = module;
217 NETFILTER_XT_MATCH_ADDRTYPE = module;
218 NETFILTER_XT_MATCH_BPF = module;
219 NETFILTER_XT_MATCH_CGROUP = module;
220 NETFILTER_XT_MATCH_CLUSTER = module;
221 NETFILTER_XT_MATCH_COMMENT = module;
222 NETFILTER_XT_MATCH_CONNBYTES = module;
223 NETFILTER_XT_MATCH_CONNLABEL = module;
224 NETFILTER_XT_MATCH_CONNLIMIT = module;
225 NETFILTER_XT_MATCH_CONNMARK = module;
226 NETFILTER_XT_MATCH_CONNTRACK = module;
227 NETFILTER_XT_MATCH_CPU = module;
228 NETFILTER_XT_MATCH_DCCP = module;
229 NETFILTER_XT_MATCH_DEVGROUP = module;
230 NETFILTER_XT_MATCH_DSCP = module;
231 NETFILTER_XT_MATCH_ECN = module;
232 NETFILTER_XT_MATCH_ESP = module;
233 NETFILTER_XT_MATCH_HASHLIMIT = module;
234 NETFILTER_XT_MATCH_HELPER = module;
235 NETFILTER_XT_MATCH_HL = module;
236 NETFILTER_XT_MATCH_IPCOMP = module;
237 NETFILTER_XT_MATCH_IPRANGE = module;
238 NETFILTER_XT_MATCH_L2TP = module;
239 NETFILTER_XT_MATCH_LENGTH = module;
240 NETFILTER_XT_MATCH_LIMIT = module;
241 NETFILTER_XT_MATCH_MAC = module;
242 NETFILTER_XT_MATCH_MARK = module;
243 NETFILTER_XT_MATCH_MULTIPORT = module;
244 NETFILTER_XT_MATCH_NFACCT = module;
245 NETFILTER_XT_MATCH_OSF = module;
246 NETFILTER_XT_MATCH_OWNER = module;
247 # CONFIG_NETFILTER_XT_MATCH_POLICY is not set
248 NETFILTER_XT_MATCH_PKTTYPE = module;
249 NETFILTER_XT_MATCH_QUOTA = module;
250 NETFILTER_XT_MATCH_RATEEST = module;
251 NETFILTER_XT_MATCH_REALM = module;
252 NETFILTER_XT_MATCH_RECENT = module;
253 NETFILTER_XT_MATCH_SCTP = module;
254 NETFILTER_XT_MATCH_SOCKET = module;
255 NETFILTER_XT_MATCH_STATE = module;
256 NETFILTER_XT_MATCH_STATISTIC = module;
257 NETFILTER_XT_MATCH_STRING = module;
258 NETFILTER_XT_MATCH_TCPMSS = module;
259 NETFILTER_XT_MATCH_TIME = module;
260 NETFILTER_XT_MATCH_U32 = module;
261 # end of Core Netfilter Configuration
264 IP_SET_MAX.freeform = "256";
265 IP_SET_BITMAP_IP = module;
266 IP_SET_BITMAP_IPMAC = module;
267 IP_SET_BITMAP_PORT = module;
268 IP_SET_HASH_IP = module;
269 IP_SET_HASH_IPMARK = module;
270 IP_SET_HASH_IPPORT = module;
271 IP_SET_HASH_IPPORTIP = module;
272 IP_SET_HASH_IPPORTNET = module;
273 IP_SET_HASH_IPMAC = module;
274 IP_SET_HASH_MAC = module;
275 IP_SET_HASH_NETPORTNET = module;
276 IP_SET_HASH_NET = module;
277 IP_SET_HASH_NETNET = module;
278 IP_SET_HASH_NETPORT = module;
279 IP_SET_HASH_NETIFACE = module;
280 IP_SET_LIST_SET = module;
281 # CONFIG_IP_VS is not set
284 # IP: Netfilter Configuration
286 NF_DEFRAG_IPV4 = module;
287 NF_SOCKET_IPV4 = module;
288 NF_TPROXY_IPV4 = module;
289 NF_TABLES_IPV4 = yes;
290 NFT_REJECT_IPV4 = module;
291 NFT_DUP_IPV4 = module;
292 NFT_FIB_IPV4 = module;
293 # CONFIG_NF_TABLES_ARP is not set
294 NF_DUP_IPV4 = module;
295 # CONFIG_NF_LOG_ARP is not set
296 # CONFIG_NF_LOG_IPV4 is not set
297 NF_REJECT_IPV4 = module;
298 IP_NF_IPTABLES = module;
299 IP_NF_MATCH_AH = module;
300 IP_NF_MATCH_ECN = module;
301 IP_NF_MATCH_RPFILTER = module;
302 IP_NF_MATCH_TTL = module;
303 IP_NF_FILTER = module;
304 IP_NF_TARGET_REJECT = module;
305 IP_NF_TARGET_SYNPROXY = module;
307 IP_NF_TARGET_MASQUERADE = module;
308 IP_NF_TARGET_NETMAP = module;
309 IP_NF_TARGET_REDIRECT = module;
310 IP_NF_MANGLE = module;
311 IP_NF_TARGET_CLUSTERIP = module;
312 IP_NF_TARGET_ECN = module;
313 IP_NF_TARGET_TTL = module;
314 # CONFIG_IP_NF_RAW is not set
315 # CONFIG_IP_NF_ARPTABLES is not set
316 # end of IP: Netfilter Configuration
319 # IPv6: Netfilter Configuration
321 NF_SOCKET_IPV6 = module;
322 NF_TPROXY_IPV6 = module;
323 NF_TABLES_IPV6 = yes;
324 NFT_REJECT_IPV6 = module;
325 NFT_DUP_IPV6 = module;
326 NFT_FIB_IPV6 = module;
327 NF_DUP_IPV6 = module;
328 NF_REJECT_IPV6 = module;
329 NF_LOG_IPV6 = module;
330 IP6_NF_IPTABLES = module;
331 IP6_NF_MATCH_AH = module;
332 IP6_NF_MATCH_EUI64 = module;
333 IP6_NF_MATCH_FRAG = module;
334 IP6_NF_MATCH_OPTS = module;
335 IP6_NF_MATCH_HL = module;
336 IP6_NF_MATCH_IPV6HEADER = module;
337 IP6_NF_MATCH_MH = module;
338 IP6_NF_MATCH_RPFILTER = module;
339 IP6_NF_MATCH_RT = module;
340 IP6_NF_MATCH_SRH = module;
341 IP6_NF_TARGET_HL = module;
342 IP6_NF_FILTER = module;
343 IP6_NF_TARGET_REJECT = module;
344 IP6_NF_TARGET_SYNPROXY = module;
345 IP6_NF_MANGLE = module;
348 IP6_NF_TARGET_MASQUERADE = module;
349 IP6_NF_TARGET_NPT = module;
350 # end of IPv6: Netfilter Configuration
352 NF_DEFRAG_IPV6 = module;
371 F2FS_FS = lib.mkForce no;
394 MISC_FILESYSTEMS = no;
408 STAGING = lib.mkForce no;
417 DRM_STM = lib.mkForce no;
419 INPUT_TOUCHSCREEN = no;
420 MEDIA_ANALOG_TV_SUPPORT = lib.mkForce no;
421 MEDIA_DIGITAL_TV_SUPPORT = lib.mkForce no;
424 MPTCP = lib.mkForce no;
426 NF_TABLES_BRIDGE = lib.mkForce no;
429 PARAVIRT = lib.mkForce no;
431 USB_GSPCA = lib.mkForce no;
432 VIDEO_STK1160_COMMON = lib.mkForce no;
433 XEN = lib.mkForce no;
436 #ignoreConfigErrors = true;
441 boot.cleanTmpDir = true;
442 boot.tmpOnTmpfs = lib.mkForce false;
443 # TODO: is that needed?
444 hardware.enableRedistributableFirmware = true;
446 postBuildCommands = ''
447 dd if=${pkgs.ubootCubieboard2}/u-boot-sunxi-with-spl.bin of=$img bs=1024 seek=8 conv=notrunc
449 compressImage = true;
452 populateFirmwareCommands = "";
453 populateRootCommands = ''
454 mkdir -p ./files/boot
455 ${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot
458 boot.loader.grub.enable = false;
459 boot.loader.generic-extlinux-compatible.enable = true;
460 # nix -L build .#nixosConfigurations.${hostName}.config.boot.kernelPackages.kernel.configfile
461 boot.kernelPackages = lib.mkForce pkgs.linuxPackages_latest_Cubieboard2;
462 boot.initrd.availableKernelModules = lib.mkForce [