Skip to content

Commit 8aa3ed1

Browse files
committed
Use runInLinuxVM instead of guestfish
1 parent 21bb880 commit 8aa3ed1

1 file changed

Lines changed: 63 additions & 14 deletions

File tree

nix/rootfs.nix

Lines changed: 63 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
fetchurl,
44
runCommand,
55

6-
libguestfs-with-appliance,
6+
# libguestfs-with-appliance,
7+
vmTools,
78
qemu,
89
cpio,
10+
util-linux,
11+
dosfstools,
12+
e2fsprogs,
913

1014
versions,
1115
extractor,
@@ -45,19 +49,64 @@
4549

4650
rootfsImage = if isNewFormat then rootfsImageNew else rootfsImageOld;
4751

52+
needsPatchDhcpcd = (builtins.compareVersions fw_version "3.12.0.0") != 1;
53+
4854
in
49-
runCommand "rm-${fw_version}.qcow2"
50-
{
51-
nativeBuildInputs = [
52-
qemu
53-
libguestfs-with-appliance
54-
];
55-
56-
passthru.fw_version = fw_version;
57-
}
58-
''
59-
${../make_rootfs.sh} ${rootfsImage} ${fw_version}
60-
mv rootfs.qcow2 $out
61-
''
55+
vmTools.runInLinuxVM (
56+
runCommand "rm-${fw_version}.qcow2"
57+
{
58+
passthru.fw_version = fw_version;
59+
60+
buildInputs = [
61+
util-linux
62+
dosfstools
63+
e2fsprogs
64+
];
65+
preVM = ''
66+
${qemu}/bin/qemu-img create -f qcow2 $out 8G
67+
'';
68+
QEMU_OPTS = "-drive file=\"$out\",if=virtio,cache=unsafe,werror=report,format=qcow2";
69+
}
70+
''
71+
set -x
72+
73+
sfdisk /dev/vda <<SFD
74+
label: dos
75+
label-id: 0xc410b303
76+
device: /dev/vda
77+
unit: sectors
78+
sector-size: 512
79+
80+
/dev/vda1 : start= 2048, size= 40960, type=83
81+
/dev/vda2 : start= 43008, size= 552960, type=83
82+
/dev/vda3 : start= 595968, size= 552960, type=83
83+
/dev/vda4 : start= 1148928, size= 13793280, type=83
84+
SFD
85+
86+
mkfs.vfat /dev/vda1
87+
88+
cp ${rootfsImage} /dev/vda2
89+
e2fsck -f -y /dev/vda2
90+
resize2fs /dev/vda2
91+
92+
mkfs.ext4 /dev/vda3
93+
mkfs.ext4 /dev/vda4
94+
95+
mkdir -p /mnt/home /mnt/root
96+
mount /dev/vda2 /mnt/root
97+
mount /dev/vda4 /mnt/home
98+
99+
cp -a /mnt/root/etc/skel /mnt/home/root
100+
umount /mnt/home
101+
102+
ln -s /dev/null /mnt/root/etc/systemd/system/remarkable-fail.service
103+
104+
${lib.optionalString needsPatchDhcpcd "sed -i 's/wlan/eth/' /mnt/root/lib/systemd/system/dhcpcd.service"}
105+
106+
umount /mnt/root
107+
108+
set +x
109+
''
110+
)
62111
) versions;
63112
}

0 commit comments

Comments
 (0)