liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

default.nix (1960B)


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