1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
| | { runCommandNoCC, writeScript, writeReferencesToFile, makeFontsConf, lib
, dash, execline, s6, s6-rc, s6-portable-utils, s6-linux-utils, s6-linux-init, busybox
, mesa, squashfs-tools-ng, makeDBusConf
}:
{ services, rcServices ? {}, fonts ? [], path ? [] }:
let
stage1 = import ./stage1.nix {
inherit writeScript lib
execline s6 s6-rc s6-portable-utils s6-linux-utils s6-linux-init busybox mesa
path;
};
makeServicesDir = import ./services.nix {
inherit runCommandNoCC writeScript lib execline;
};
makeRcServicesDir = import ./rc-services.nix {
inherit runCommandNoCC lib s6-rc;
};
fontsConf = makeFontsConf { fontDirectories = fonts; };
squashfs = runCommandNoCC "root-squashfs" {} ''
cd ${rootfs}
(
grep -v ^${rootfs} ${writeReferencesToFile rootfs}
printf "%s\n" *
) \
| xargs tar -cP --owner root:0 --group root:0 --hard-dereference \
| ${squashfs-tools-ng}/bin/tar2sqfs -c gzip -X level=1 $out
'';
rootfs = runCommandNoCC "rootfs" { passthru = { inherit squashfs; }; } ''
mkdir $out
cd $out
mkdir -p bin sbin dev proc run sys tmp var/lib
ln -s /run var/run
ln -s ${dash}/bin/dash bin/sh
ln -s ${stage1} sbin/init
cp -r ${./etc} etc
chmod u+w etc
ln -s ${makeDBusConf {
suidHelper = "/run/dbus-daemon-launch-helper";
serviceDirectories = [];
}} etc/dbus-1
mkdir etc/fonts
ln -s ${fontsConf} etc/fonts/fonts.conf
touch etc/login.defs
cp -r ${makeServicesDir { inherit services; }} etc/service
cp -r ${makeRcServicesDir { services = rcServices; }} etc/s6-rc
'';
in
rootfs
|