default.nix (2340B)
1 { 2 writeScriptBin, 3 writeScript, 4 systemconfig, 5 execline, 6 lib, 7 config ? { }, 8 liminix, 9 pseudofile, 10 pkgs, 11 }: 12 let 13 inherit (pseudofile) dir symlink; 14 inherit (liminix.services) oneshot; 15 paramConfig = config; 16 newRoot = "/run/maintenance"; 17 sysconfig = 18 let 19 doChroot = writeScript "exec" '' 20 #!${execline}/bin/execlineb -P 21 cd ${newRoot} 22 foreground { mount --move ${newRoot} / } 23 redirfd -r 0 /dev/console 24 redirfd -w 1 /dev/console 25 fdmove -c 2 1 26 emptyenv chroot . /bin/init 27 ''; 28 base = 29 { ... }: 30 { 31 config = { 32 services = { 33 banner = oneshot { 34 name = "banner"; 35 up = "cat /etc/banner > /dev/console"; 36 down = "true"; 37 }; 38 }; 39 40 filesystem = dir { 41 exec = symlink doChroot; 42 etc = dir { 43 banner = symlink ( 44 pkgs.writeText "banner" '' 45 46 LADIES AND GENTLEMEN WE ARE FLOATING IN SPACE 47 48 Most services are disabled. The system is operating 49 with a ram-based root filesystem, making it safe to 50 overwrite the flash devices in order to perform 51 upgrades and maintenance. 52 53 Don't forget to reboot when you have finished. 54 55 '' 56 ); 57 }; 58 }; 59 }; 60 }; 61 eval = lib.evalModules { 62 modules = [ 63 { 64 _module.args = { 65 inherit pkgs; 66 inherit (pkgs) lim; 67 }; 68 } 69 ../../modules/base.nix 70 ../../modules/users.nix 71 ../../modules/busybox.nix 72 base 73 ({ ... }: paramConfig) 74 ( 75 { ... }: 76 { 77 config = { 78 logging.script = "t"; 79 }; 80 } 81 ) 82 ../../modules/s6 83 ]; 84 }; 85 in 86 systemconfig eval.config.filesystem.contents; 87 in 88 writeScriptBin "levitate" '' 89 #!/bin/sh 90 destdir=${newRoot} 91 mkdir -p $destdir $destdir/nix/store 92 for path in $(cat ${sysconfig}/etc/nix-store-paths) ; do 93 (cd $destdir && cp -a $path .$path) 94 done 95 ${sysconfig}/bin/activate $destdir 96 ''