nixos/anbox: allow applying changes to the image
This commit is contained in:
parent
cdc51c811a
commit
7fa154f3ee
|
@ -25,6 +25,28 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
finalImage = if cfg.imageModifications == "" then cfg.image else ( pkgs.callPackage (
|
||||||
|
{ runCommandNoCC, squashfsTools }:
|
||||||
|
|
||||||
|
runCommandNoCC "${cfg.image.name}-modified.img" {
|
||||||
|
nativeBuildInputs = [
|
||||||
|
squashfsTools
|
||||||
|
];
|
||||||
|
} ''
|
||||||
|
echo "-> Extracting Anbox root image..."
|
||||||
|
unsquashfs -dest rootfs ${cfg.image}
|
||||||
|
|
||||||
|
echo "-> Modifying Anbox root image..."
|
||||||
|
(
|
||||||
|
cd rootfs
|
||||||
|
${cfg.imageModifications}
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "-> Packing modified Anbox root image..."
|
||||||
|
mksquashfs rootfs $out -comp xz -no-xattrs -all-root
|
||||||
|
''
|
||||||
|
) { });
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -42,6 +64,18 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
imageModifications = mkOption {
|
||||||
|
default = "";
|
||||||
|
type = types.lines;
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
Commands to edit the image filesystem.
|
||||||
|
|
||||||
|
This can be used to e.g. bundle a privileged F-Droid.
|
||||||
|
|
||||||
|
Commands are ran with PWD being at the root of the filesystem.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
extraInit = mkOption {
|
extraInit = mkOption {
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
default = "";
|
default = "";
|
||||||
|
@ -127,7 +161,7 @@ in
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.anbox}/bin/anbox container-manager \
|
${pkgs.anbox}/bin/anbox container-manager \
|
||||||
--data-path=${anboxloc} \
|
--data-path=${anboxloc} \
|
||||||
--android-image=${cfg.image} \
|
--android-image=${finalImage} \
|
||||||
--container-network-address=${cfg.ipv4.container.address} \
|
--container-network-address=${cfg.ipv4.container.address} \
|
||||||
--container-network-gateway=${cfg.ipv4.gateway.address} \
|
--container-network-gateway=${cfg.ipv4.gateway.address} \
|
||||||
--container-network-dns-servers=${cfg.ipv4.dns} \
|
--container-network-dns-servers=${cfg.ipv4.dns} \
|
||||||
|
|
Loading…
Reference in a new issue