Fil-C on Nix

Filnix wiki

mbrock/filnix

finix/demo.nix

A small finix machine whose whole userland is Fil-C: finit as PID 1, mdevd, sysklogd, dhcpcd, OpenSSH, the shell and the tools are Fil-C builds; only the kernel and the exceptions in lib/native-exceptions.nix are not. Try it:

nix run .#finixConfigurations.filc-demo.config.system.build.vm

and log in as root (no password) on the console, or ssh -p 2222 demo@localhost with password "demo". Ctrl-a x quits QEMU. finix/test.nix boots it and checks that its processes are Fil-C.

λconfig, lib, pkgs, modules, …
let

QEMU runs on the host, so it is the native build.

20native=
pkgs.pkgsBuildBuild
in
23imports=
with modules; getty openssh sudo dhcpcd sysklogd nix-daemon
32filc.enable=
true
34networking.hostName=
lib.mkDefault"filc-demo"
36boot.kernelParams=
"console=ttyS0,115200n8"

The root file system is a tmpfs; the Nix store is the host's, over 9p.

39fileSystems."/"=
40device=
"tmpfs"
41fsType=
"tmpfs"
42options=
"mode=755"
45services.getty.enable=
true

The VM runs with -nographic: the login prompt is on the serial console.

47services.getty.ttys=
"ttyS0" "tty1"
51services.mdevd.enable=
true
52services.sysklogd.enable=
true
53services.dhcpcd.enable=
lib.mkDefaulttrue
54services.openssh.enable=
true
55services.nix-daemon.enable=
true

finix's lix-daemon module, when imported (its test driver imports every module), would make Lix the default; Lix is partly Rust.

58services.nix-daemon.package=
pkgs.nix
59programs.sudo.enable=
true
61users.users.root.password=
""
62users.users.demo=
63isNormalUser=
true
64password=
"$6$filcdemofilcdemo$/GDxfM31Nn0AzYyqqGfxyZb7sJiojyzIFCPaW/9ixsOOmQ.7.mzzZRc/281rrQBqbTdB4DfmWSP9BXML40cH9."
demo
65extraGroups=
"wheel"
68environment.systemPackages=
with pkgs; bashInteractive coreutils findutils gnugrep gnused gawk less nano curl procps iproute2
82virtualisation.memorySize=
2048
83virtualisation.cores=
2
84virtualisation.qemu.package=
lib.mkDefaultnative.qemu_kvm
uses native
86system.build.vm=
native.writeShellScriptBin"run-filc-demo-vm"
exec ${lib.escapeShellArgsconfig.virtualisation.qemu.argv} \
-nographic \
-nic user,model=virtio-net-pci,hostfwd=tcp::2222-:22 \
"$@"
uses native