Commit Graph

305 Commits (main)

Author SHA1 Message Date
Daniel Barlow 3df34428d6 remove unneeded login and getty applets 2023-11-23 20:01:13 +00:00
Daniel Barlow 62c788eb86 add hook to run maintenance mode instead of rebooting 2023-11-22 00:05:55 +00:00
Daniel Barlow bab6d346a8 add .../s6/bin to PATH for shutdownd 2023-11-22 00:05:03 +00:00
Daniel Barlow a202ae476a extract console redirection stuff from "quit" function
so we can use it for scripts that don't reboot at their end
2023-11-21 23:32:37 +00:00
Daniel Barlow 7c9297f91d use shotdown instead of hpr in .s6-svscan/SIGFOO
this is to bring them into line with what more recent
s6-init-linux-maker creates
2023-11-21 23:19:00 +00:00
Daniel Barlow a0bd250963 switch from getty to root shell on console
this just makes things marginally simpler
2023-11-21 23:09:48 +00:00
Daniel Barlow e5223f093f kernel.src may be a path not just a package
this makes it easier to hack the kernel locally and test things
2023-11-18 14:21:18 +00:00
Daniel Barlow f9f4d97bb8 convert flash params to int 2023-11-12 20:39:06 +00:00
Daniel Barlow abfb35a231 and entryPoint 2023-11-12 18:50:47 +00:00
Daniel Barlow 315907de98 convert hardware loadAddress to int 2023-11-12 18:47:31 +00:00
Daniel Barlow 185117843b convert tftp.loadAddress from string to int 2023-11-12 18:37:33 +00:00
Daniel Barlow 3da692f7ef don't import flashimage unconditionally, it breaks qemu 2023-11-12 18:11:13 +00:00
Daniel Barlow f61e737b54 improve doc for outputs and hardware
Changed my mind about "installer" as a first-class concept, at least
in the current implementation. Not every documented output is an
installer
2023-11-12 17:15:58 +00:00
Daniel Barlow 7cfb92e3ce more doc 2023-11-10 21:17:20 +00:00
Daniel Barlow a9760d239c basic doc for flashimage installer 2023-11-09 22:43:50 +00:00
Daniel Barlow 7d5c7b9b44 export evaluation from default.nix and use it for docs 2023-11-09 22:14:31 +00:00
Daniel Barlow 23b3a2baef extract vmroot output into its own file 2023-11-08 23:19:11 +00:00
Daniel Barlow a9d847e2c0 add ext4 as rootfsType 2023-11-06 21:52:31 +00:00
Daniel Barlow 6489a39424 qemu armv7 2023-11-05 23:19:11 +00:00
Daniel Barlow c94d12934f remove direct use of run-liminix-vm from tests and doc 2023-11-05 20:37:23 +00:00
Daniel Barlow c40eef25d6 qemu: use phram instead of block2mtd 2023-11-05 19:13:51 +00:00
Daniel Barlow 46991e2761 aarch64 ram starts at 0x40000000 2023-11-05 15:33:10 +00:00
Daniel Barlow a135cb1217 introduce lim, the liminix library
so far we have lim.parseInt, which parses an integer from a string
with optional base-selecting-prefix (e.g. 0755, 0x12ab)
2023-11-05 15:13:06 +00:00
Daniel Barlow 863045b86b added hardware.ram.startAddress config
it's not 0 on arm32, so this will be useful for qemu
2023-11-05 15:11:58 +00:00
Daniel Barlow 629624bb25 replace multiway if with pkgs.stdenv.hostPlatform.qemuArch 2023-11-05 11:40:26 +00:00
Daniel Barlow 92b9bf959e options.system.outputs.initramfs -> initramfs module 2023-11-05 11:33:02 +00:00
Daniel Barlow e6cb5e319b extract NETDEVICES kconfig to kernel.nix module 2023-11-05 11:31:23 +00:00
Daniel Barlow e6ef4f78bb "ubimage" module contains ubifs image + instructions
Presently either you run this from U-Boot or you figure out for
yourself how to kexecboot into a recovery system :-)
2023-10-21 23:20:53 +01:00
Daniel Barlow f3225c2bd5 delete dup outputs.systemConfiguration
perhaps this should go into initramfs.nix not jffs2.nix
2023-10-19 10:09:08 +01:00
Daniel Barlow 629914f65e initial support for ubifs 2023-10-16 19:55:17 +01:00
Daniel Barlow 364c5faf9e tftpboot: fix errors in phram partition size calc 2023-10-10 20:26:27 +01:00
Daniel Barlow bd20f3e419 uimage: make fit optional 2023-10-09 19:47:57 +01:00
Daniel Barlow f62ad0e1d7 use "tftpboot" instead of "tftp" in u-boot commands
openwrt's u-boot installation doesn't accept the short form
2023-10-09 19:47:57 +01:00
Daniel Barlow c18f07f02f aarch64: make tftpboot work
- patch dtb to add reserved-memory stanza for the phram device to use
  (aarch64 does not accept memmap= command line option)

- patch phram driver to use memremap() instead of ioremap() as
  ioremap can't be used for system ram on arm devices
2023-10-09 19:47:57 +01:00
Daniel Barlow dbc16edf96 don't use ttyAMA0 console on all aarch64, just qemu 2023-10-09 19:47:57 +01:00
Daniel Barlow 4df248323c use MTD_SPI_NOR_USE_4K_SECTORS only on MIPS 2023-10-07 22:41:15 +01:00
Daniel Barlow caf8e85061 remove USE_OF from aarch64 2023-10-02 22:43:13 +01:00
Daniel Barlow 76f03ecf0f move OF and USE_OF to arch modules 2023-09-30 21:52:13 +01:00
Daniel Barlow 3a2f074199 disable 4k flash erase blocks everywhere 2023-09-27 22:10:17 +01:00
Daniel Barlow ab147abd9b less padding in firmware.bin
we only need to align to erase block size, which may be
less than the 128k previously hard-coded
2023-09-26 16:43:03 +01:00
Daniel Barlow c59a228955 this is the dhcp6c service we want 2023-09-26 16:43:03 +01:00
Daniel Barlow 94e51db649 tests: use run.sh instead of calling run-liminix-vm directly
this makes it easier to run tests on aarch64 where
qemu wants an Image file instead of a vmlinux
2023-09-24 00:24:48 +01:00
Daniel Barlow be22fbbb0a bootable aarch64 liminux with qemu
I may have broken the run-liminix-vm command a bit for MIPS due to
necessary changes in how we pass the command line.  If CI isn't green
for this commit and youre trying the worked examples, I suggest
reverting to the commit before this one.
2023-09-20 22:55:51 +01:00
Daniel Barlow 4389fa15f7 rename mips-vm as run-liminix-vm 2023-09-20 18:33:20 +01:00
Daniel Barlow 4f29bdd3ed detect arch in kernel and uimage
also move kernel builder to pkgs/

FIXME we need to straighten out the mess in calling
dtb.nix/uimage.nix
2023-09-20 18:26:33 +01:00
Daniel Barlow f1c04c7979 extract mips kernel options to module 2023-09-20 17:50:21 +01:00
Daniel Barlow f75995e895 introduce modules/arch/{mipsel,mipseb}.nix
for settings that are common to all mipse[lb] but would not be shared
with e.g. aarch64 or x86
2023-09-20 17:30:05 +01:00
Daniel Barlow b36272f99e add outputs for vlan service 2023-09-17 17:00:31 +01:00
Daniel Barlow 0abe4f96a7 ssh ensure we create /run/dropbear
this is required if we don't have persistent store (jffs2)
2023-09-17 17:00:26 +01:00
Daniel Barlow 4fd1b5f08b er, "input" != output" 2023-09-13 18:01:50 +01:00
Daniel Barlow 899f096346 dnsmasq static hosts defaults to empty attrset 2023-09-04 23:02:17 +01:00
Daniel Barlow 0cf4733327 add placeholders for missing module docs 2023-09-04 22:19:22 +01:00
Daniel Barlow 0a6af46364 support dhcp static leases 2023-09-04 22:08:07 +01:00
Daniel Barlow 3bdc986dd7 extract "mount filesystem" to module 2023-09-04 21:17:52 +01:00
Daniel Barlow 83092b7b73 add watchdog service 2023-09-02 17:28:40 +01:00
Daniel Barlow 7ad848cb77 add service to enable packet forwarding
might be worth looking into adding RA config to this
2023-09-01 17:34:47 +01:00
Daniel Barlow e04ec2e959 move SWCONFIG defn into per-device files
it doesn't work on qemu
2023-08-31 23:50:07 +01:00
Daniel Barlow d60aab728d reinstate loopback network (oops) 2023-08-31 23:29:30 +01:00
Daniel Barlow 3609d8d5ee implement route as module-based-service 2023-08-31 23:24:23 +01:00
Daniel Barlow e577caa15f extneder: use bridge module 2023-08-31 18:29:45 +01:00
Daniel Barlow 7faf620c0b move loopback config from base to netowrk module 2023-08-31 18:28:35 +01:00
Daniel Barlow f1dfb1f976 BRIDGE_VLAN_FILTERING depends on bridge _and_ vlan
I'm half-pleased with this. It demonstrates how we can have complex
conditional kernel config, but the way we detect if vlan exists is
tacky.
2023-08-31 18:24:09 +01:00
Daniel Barlow 333327be75 make a module for vlan
Acked-by: Daniel Barlow <<dan@telent.net>>
2023-08-30 23:26:44 +01:00
Daniel Barlow efa1919e04 move squashfs kernel options into module 2023-08-30 22:59:28 +01:00
Daniel Barlow de77635490 move bridge-related kernel config to the module 2023-08-30 17:29:42 +01:00
Daniel Barlow aecbe08f08 add o+x permission on service-state directories
this is needed for resolvconf, which writes resolv.conf as
an output and wants to make it world-readable
2023-08-28 22:02:28 +01:00
Daniel Barlow ff2d3e1a63 TODO comments 2023-08-28 22:02:28 +01:00
Daniel Barlow e86daf9bbc default value for services.default
as a default default target, start all the services
2023-08-28 22:02:28 +01:00
Daniel Barlow 00c8ea66ea add service fir dhcp v4 client 2023-08-28 22:02:28 +01:00
Daniel Barlow 31f0213b6f convert network link/address to module-based-service
... and make bridge use it.

We also had to convert bridge back into a pair of services.
Downstreams want to depend on the bridge it self being configured
even if not necessarily all the members are up. e.g. don't want
to break ssh on lan if there's a misconfigured wlan device
2023-08-28 22:02:28 +01:00
Daniel Barlow 540a1dfd76 remove interface.device
build-time uses can mostly be replaced with interface.name

for runtime uses, switch to $(output ${interface} name)
2023-08-28 22:02:28 +01:00
Daniel Barlow 6b28f5dd79 chrony: drop privileges 2023-08-27 22:40:49 +01:00
Daniel Barlow f4ad4d3ce1 update bridge service doc 2023-08-18 23:58:06 +01:00
Daniel Barlow 6f92f8fa8b merge bridge services into one 2023-08-16 23:29:53 +01:00
Daniel Barlow a019e59a80 improve doc 2023-08-16 22:52:16 +01:00
Daniel Barlow 1b8536ff81 describe hostname option 2023-08-16 22:26:40 +01:00
Daniel Barlow f93c03c98a improve descriptions for base and busybox 2023-08-16 22:26:31 +01:00
Daniel Barlow dc4b7ebffd module docs: print examples 2023-08-11 21:12:57 +01:00
Daniel Barlow b81604870b extract kernel config options from base module
we then "import" them straight back into base.nix - it's not
as though you can opt out of having a kernel. But this means
they'll appear separately in the documentation
2023-08-11 18:15:17 +01:00
Daniel Barlow 3ea40f95dc convert pppoe to serviceDefn 2023-08-10 22:53:45 +01:00
Daniel Barlow 2942c465b9 add ssh module 2023-08-10 22:53:21 +01:00
Daniel Barlow 2a29a00dfe much text, such doc, very wow 2023-08-09 22:27:37 +01:00
Daniel Barlow 5cff862ae9 add preamble text to each service-providing-module 2023-08-07 23:03:49 +01:00
Daniel Barlow 615c2de537 extract module top-level comment to docs 2023-08-07 22:14:58 +01:00
Daniel Barlow 6d619ee8b5 add some missing descriptions 2023-08-07 21:43:12 +01:00
Daniel Barlow 2414dd4b55 convert ntp to serviceDefn 2023-08-05 14:16:54 +01:00
Daniel Barlow 93e04bb834 convert bridge service to serviceDefn 2023-08-05 14:10:14 +01:00
Daniel Barlow f82501d278 update hostapd to "build" syntax 2023-08-05 12:21:18 +01:00
Daniel Barlow 90c1d59aca convert firewall service to new serviceDefn
this is a bit kludgey with dependencies, need to
come back and look at that
2023-08-05 12:07:35 +01:00
Daniel Barlow fbb2c04132 move module-based-service parameter types into service
This is in preparation for writing something that extracts them
into documentation.

user configurations now call config.system.service.foo.build { ...params }
instead of config.system.service.foo

the parameter type definitions themselves now move into the
config stanza of the module referencing the service

new helper function  liminix.callService

The only service moved so far is dnsmasq
2023-08-04 20:39:29 +01:00
Daniel Barlow c3631f4c9d improve grammar of mkEnableOption descriptions 2023-08-04 20:19:27 +01:00
Daniel Barlow 4689cebf8d fix illegal module options 2023-08-04 20:07:06 +01:00
Daniel Barlow 7fad66ff27 fix makestep type 2023-07-22 23:50:01 +01:00
Daniel Barlow bf1d9beec1 add first version of ntp module 2023-07-22 23:25:25 +01:00
Daniel Barlow 9b70fd62f6 extract bridge to module-based services 2023-07-20 12:02:09 +01:00
Daniel Barlow 648ea5613b use module-based-service for hostapd 2023-07-16 17:51:50 +01:00
Daniel Barlow f73a9d82dc add comments 2023-07-16 17:51:50 +01:00
Daniel Barlow d7f3e05063 turn nftables firewall into a service-providing module 2023-07-16 17:51:50 +01:00
Daniel Barlow 669af24247 make a module for dnsmasq 2023-07-14 23:18:21 +01:00
Daniel Barlow df6cfe1cd5 move pppoe service derivation into ppp module dir 2023-07-14 21:35:59 +01:00
Daniel Barlow c13defc891 rename modules/ppp.nix -> modules/ppp/default.nix 2023-07-14 21:08:33 +01:00
Daniel Barlow 682183a88d move typeChecked into pkgs.liminix.lib 2023-07-14 20:22:29 +01:00
Daniel Barlow 69e6eb5a89 accept attr args to pppoe service, and typecheck them
We use (abuse, arguably) the nixos module system for typechecking.  Un
the plus side, it gives us documentation of the options and their
expected types. On the downside, the error message doesn't tell us
the file in which the error was encountered.

(This is subject to change, if I can find a better way)
2023-07-14 16:53:36 +01:00
Daniel Barlow 9441f48819 new ppp module, used by rotuer
The objective here is that services which depend on global config
(e.g. kernel config or busybox options or static paths in the
filesystem) now live under config.system.service, and are added
to that collection by the module that defines the necessary state.

This is a first step: the services will be configured by a typechecked
attr set instead of the arbitrary arguments that
pkgs.liminix.networking.pppoe accepts
2023-07-13 19:44:14 +01:00
Daniel Barlow 2e50368bd2 rename config.outputs to config.system.outputs
New rules: everything under "config" that isn't actually configuration
(e.g. build products) will in future live in config.system. This is
the first step.
2023-07-13 19:24:59 +01:00
Daniel Barlow b6e72504d6 ipv6 default route
needs to specify the ppp0 *peer* address not the local address
2023-06-30 10:17:33 +01:00
Daniel Barlow 447f068569 partly support getting IPv6 addresses
- gets interface id from ppp
- runs odhcpc to get RA and prefix delegation
- doesn't do anything useful with the data yet
2023-05-24 23:01:50 +01:00
Daniel Barlow bc27f121d9 /etc/ashrc for interactive non-login shells 2023-05-21 17:08:32 +01:00
Daniel Barlow a48d51ffdc keep dropbear host keys in /persist if it exists 2023-05-21 12:01:42 +01:00
Daniel Barlow 68ab6faeb3 write etc/nix-store-paths in systemConfiguration 2023-05-19 23:57:50 +01:00
Daniel Barlow b0a0fdcfcc add "standard" module, which includes flashimage kexec & jffs2
most systems need most of these, so it makes writing the docs a
lot easier
2023-05-17 15:38:22 +01:00
Daniel Barlow 67768004ee erase full flash, it seems to help with jffs2 2023-04-26 22:19:01 +01:00
Daniel Barlow 26c6eac937 delete config boot.tftp.enable as it doesn't enable anything 2023-04-26 22:18:23 +01:00
Daniel Barlow 4cfaed7303 specify root device as /dev/mtdblockn
the (openwrt?) magic that autodetects it based on mtd labels
won't work with a two-stage boot
2023-04-26 22:16:15 +01:00
Daniel Barlow 6d6dbe1cbb tftpboot: allow padding image with freeSpaceBytes
this is useful for writable filesystems so that there's more than
an erase block of space to write into
2023-04-26 22:15:19 +01:00
Daniel Barlow 2f3b108ef1 tftpboot: set phram erase block size to match hardware
this is needed for tftp boot with a jffs2 filesystem
2023-04-23 21:24:37 +01:00
Daniel Barlow 2c4f8b823e remove jffs2boot target
It's not needed now initramfs is compiled into the kernel.
2023-04-23 20:56:20 +01:00
Daniel Barlow 99af416e14 use /bin/sh for init scripts 2023-04-19 21:41:05 +01:00
Daniel Barlow 5dd0c6e3c0 rewrite preinit as very small C program
By using the kernel "nolibc" header to avoid requiring a C library, we
can bring the initramfs size to around 4k

This does involve a tiny bit of inline mips assembly which I'm not
sure about. gcc seems unwilling to generate the code to load $gp at
function entry of main(), so we do it by hand - but I'd rather find
out why gcc doesn't.
2023-04-15 18:27:39 +01:00
Daniel Barlow b1a89ae8c3 jffs2: squash uids, enable lzo compression 2023-04-15 17:23:58 +01:00
Daniel Barlow 1cc0b13b57 rewrite systemconfig in C and link statically
systemconfig (a.k.a "activate") is run from the initramfs. Converting
it from a shell script to an executable means it doesn't depend on
there being a shell in the initramfs
2023-04-15 17:21:27 +01:00
Brian McKenna fb796e61e0 pseudofile: allow setting uid and gid of files
Necessary for Dropbear to accept non-root authorized_keys files.
2023-04-14 23:12:52 +01:00
Daniel Barlow 9f3c80e774 make initramfs busybox (very slightly) smaller 2023-04-11 23:08:02 +01:00
Daniel Barlow 2566dc564c remove need for symlinks in initramfs busybox 2023-04-10 22:57:50 +01:00
Daniel Barlow 0ad7b0e48b don't hardcode mtd0 initramfs->second stage 2023-04-10 22:57:50 +01:00
Daniel Barlow 0a2881914b set erase block size to something that works for jffs2 2023-04-10 22:57:50 +01:00
Daniel Barlow 4638092d3d build initramfs into kernel
this doesn't matter for qemu, but there's no other way of
getting a hardware device to find it if the bootloader
won't co-operate
2023-04-10 22:57:50 +01:00
Daniel Barlow 633a4f8003 move BLK_DEV_INITRD to base.nix 2023-04-10 22:57:50 +01:00
Daniel Barlow 42725f56f9 make jffs2 module provide o.rootfs, conditionally
it's enabled if config.rootfsType == "jffs2"
2023-04-10 20:01:58 +01:00
Daniel Barlow 63a89f7d0d add config.boot.initramfs.enable 2023-04-10 19:07:27 +01:00
Daniel Barlow 07eb3d66da remove unused combined-image output 2023-04-10 18:15:48 +01:00
Daniel Barlow 0687ae7f5c rename flashable->flashimage, o.squashfs to rootfs
"rootfs" describes what it is for, "squashfs" merely says
how it's implemented

(also, rootfs-as-jffs2 will soon be added)
2023-04-10 18:13:27 +01:00
Daniel Barlow f5156425a2 correct jffs2 endian, remove unused bindings 2023-04-07 09:39:47 +01:00
Daniel Barlow 54a1ab3529 support jffs2, with initramfs
the jffs2 filesystem contains only /nix/store and a script which is
run in early init (initramfs) and is responsible for recreating
"traditional" directories (/bin /etc/**/* /var &c) based on the
configuration.

this is tested only in qemu so far and could use some cleanup
2023-04-04 23:35:49 +01:00
Daniel Barlow 25d9da967c remove support for sockets in pseudofiles
(1) we can't make them on a real filesystem except by running
something that calls socket()
(2) whyever would we want to?
2023-04-04 23:23:22 +01:00
Daniel Barlow f5a7b78679 rename kexec-tools-static
it doesn't build natively on x86-64 and I don't suppose we need it to
anyway
2023-03-24 20:51:46 +00:00
Daniel Barlow c831859513 add flashcp to allow flashing from a running system 2023-03-24 17:32:46 +00:00
Daniel Barlow 045f10e79b build kexec statically 2023-03-24 17:12:19 +00:00
Daniel Barlow a5cfa37ed3 unify kernel command line handling
We now use MIPS_CMDLINE_DTB_EXTEND for all boot varieties
(tftpboot, flash boot, kexec) with the addition of
MIPS_BOOTLOADER_CMDLINE_REQUIRE_COOKIE - local patch -
so that the bootloader args are ignored unless they
contain the string "liminix"
2023-03-23 22:24:44 +00:00
Daniel Barlow 8250d592ba don't hardcode root device, too confusing when adding phram 2023-03-19 20:27:05 +00:00
Daniel Barlow 4b19568f1b add kexecboot
This allows booting a new image from a running OS, creating a
phram mtd for the root squashfs

* enable CONFIG_KEXEC
* add modules/kexecboot
* patch kexec-tools to add --map-file option for the squashfs
* patch kernel kexec code to call new kernel with DTB
2023-03-19 20:25:43 +00:00
Daniel Barlow b85492c744 when flashing, only need to erase the space we're writing 2023-03-18 14:50:09 +00:00
Daniel Barlow 3c6ec354ce move root's home directory to /home/root
/ is a bad choice of home directory

/home/root instead of /root is to make it easier to write
ssh keys to the right place
2023-03-18 14:46:50 +00:00
Daniel Barlow e78d5212e6 move tftp config to base module
we need it for flashing from u-boot even when tftp booting
is not enabled
2023-03-18 14:45:51 +00:00
Daniel Barlow ce05f4e44c extract phram.mtd ramdisk support from tftpboot module
also rename tftproot output to tftpboot for consistency
2023-03-18 14:30:10 +00:00
Daniel Barlow 3efa9e0af2 restore missing applets 2023-03-10 23:14:13 +00:00
Daniel Barlow f2d1789ad7 add openssh authorized_keys 2023-03-10 23:13:32 +00:00
Daniel Barlow 225fc6fe51 configurable busybox
allows modules to add to the busybox applets and change config
2023-03-10 18:40:45 +00:00
Daniel Barlow 43f1fb230b remove unrecoginsed earlyprintk param from kernel commandline 2023-03-10 00:50:28 +00:00
Daniel Barlow d83bcc643e add wifi firmware, move things around in ram
* at the base address we were using, the filesystem was getting
corrupted presumably because the kernel unpacked into it

* leave a little more space between compressed kernel and
squashfs. this is probably ineffective but also harmless
2023-03-10 00:48:47 +00:00