add outputs.manifest for diagnosing image size problems

module-based-network
Daniel Barlow 2022-09-27 22:07:18 +01:00
parent 5e573cef09
commit 2e13f1372e
3 changed files with 22 additions and 3 deletions

View File

@ -114,6 +114,16 @@ Assuming you have nixpkgs checked out in a peer directory of this one,
NIX_PATH=nixpkgs=../nixpkgs:$NIX_PATH ./run-tests.sh NIX_PATH=nixpkgs=../nixpkgs:$NIX_PATH ./run-tests.sh
## Diagnosing unexpectedly large images
Sometimes you can add a package and it causes the image size to balloon
because it has dependencies on other things you didn't know about. Build the
`outputs.manifest` attribute, which is a json representation of the
filesystem, and you can run `nix-store --query` on it:
NIX_PATH=nixpkgs=../nixpkgs:$NIX_PATH NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build -I liminix-config=path/to/your/configuration.nix --arg device "import ./devices/qemu.nix" -A outputs.manifest -o manifest
nix-store -q --tree manifest
## Articles of interest ## Articles of interest

View File

@ -186,7 +186,7 @@ creates the interface instead of using an existing unconfigured one
5) write a test for udhcp 5) write a test for udhcp
6) squashfs size is ~ 14MB for a configuration with not much in it, DONE 6) squashfs size is ~ 14MB for a configuration with not much in it,
look for obvious wastes of space look for obvious wastes of space
7) some of the pppoe config should be moved into a ppp service 7) some of the pppoe config should be moved into a ppp service
@ -207,7 +207,13 @@ is that specified or fluke?
19) syslogd - use busybox or s6? 19) syslogd - use busybox or s6?
20) The option currently called defaultPackages needs a better name as DONE 20) The option currently called defaultPackages needs a better name as
it doesn't have the same semantics as nixos it doesn't have the same semantics as nixos
environment.defaultPackages. maybe call it packagesInProfile or environment.defaultPackages. maybe call it packagesInProfile or
packagesOnPath. or defaultProfile.packages packagesOnPath. or defaultProfile.packages
Tue Sep 27 22:00:36 BST 2022
Found the cause of huge image size: rp-pppoe ships with scripts that
reference build-time packages, so we have x86-64 glibc in there

View File

@ -4,7 +4,7 @@
let let
overlay = import ./overlay.nix; overlay = import ./overlay.nix;
nixpkgs = import <nixpkgs> ( device.system // {overlays = [overlay]; }); nixpkgs = import <nixpkgs> ( device.system // {overlays = [overlay]; });
inherit (nixpkgs.pkgs) callPackage liminix; inherit (nixpkgs.pkgs) callPackage writeText liminix;
config = (import ./merge-modules.nix) [ config = (import ./merge-modules.nix) [
./modules/base.nix ./modules/base.nix
({ lib, ... } : { config = { inherit (device) kernel; }; }) ({ lib, ... } : { config = { inherit (device) kernel; }; })
@ -24,6 +24,9 @@ in {
ln -s ${squashfs} squashfs ln -s ${squashfs} squashfs
ln -s ${kernel.vmlinux} vmlinux ln -s ${kernel.vmlinux} vmlinux
''; '';
# this exists so that you can run "nix-store -q --tree" on it and find
# out what's in the image, which is nice if it's unexpectedly huge
manifest = writeText "manifest.json" (builtins.toJSON config.filesystem.contents);
}; };
# this is just here as a convenience, so that we can get a # this is just here as a convenience, so that we can get a
# cross-compiling nix-shell for any package we're customizing # cross-compiling nix-shell for any package we're customizing