diff options
author | Samuel Dionne-Riel <samuel@dionne-riel.com> | 2021-06-04 17:34:33 -0400 |
---|---|---|
committer | rnhmjoj <rnhmjoj@inventati.org> | 2023-09-05 10:09:43 +0200 |
commit | 7fa154f3ee4d93236bb844b97ca0dac32559dc37 (patch) | |
tree | 7e24eb6f1799d636f433e7634ce201da482a8650 /nixos/modules/virtualisation/anbox.nix | |
parent | cdc51c811a492b8b7e20e2c579cb51a57d6dc922 (diff) | |
download | nixpkgs-7fa154f3ee4d93236bb844b97ca0dac32559dc37.tar nixpkgs-7fa154f3ee4d93236bb844b97ca0dac32559dc37.tar.gz nixpkgs-7fa154f3ee4d93236bb844b97ca0dac32559dc37.tar.bz2 nixpkgs-7fa154f3ee4d93236bb844b97ca0dac32559dc37.tar.lz nixpkgs-7fa154f3ee4d93236bb844b97ca0dac32559dc37.tar.xz nixpkgs-7fa154f3ee4d93236bb844b97ca0dac32559dc37.tar.zst nixpkgs-7fa154f3ee4d93236bb844b97ca0dac32559dc37.zip |
nixos/anbox: allow applying changes to the image
Diffstat (limited to 'nixos/modules/virtualisation/anbox.nix')
-rw-r--r-- | nixos/modules/virtualisation/anbox.nix | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/nixos/modules/virtualisation/anbox.nix b/nixos/modules/virtualisation/anbox.nix index 6323a3b72c5..dd4a49413f7 100644 --- a/nixos/modules/virtualisation/anbox.nix +++ b/nixos/modules/virtualisation/anbox.nix @@ -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 { @@ -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 { type = types.lines; default = ""; @@ -127,7 +161,7 @@ in ExecStart = '' ${pkgs.anbox}/bin/anbox container-manager \ --data-path=${anboxloc} \ - --android-image=${cfg.image} \ + --android-image=${finalImage} \ --container-network-address=${cfg.ipv4.container.address} \ --container-network-gateway=${cfg.ipv4.gateway.address} \ --container-network-dns-servers=${cfg.ipv4.dns} \ |