diff --git a/README.md b/README.md index a095fdb..df4ab80 100644 --- a/README.md +++ b/README.md @@ -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 +## 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 diff --git a/THOUGHTS.txt b/THOUGHTS.txt index 07ca690..b35f044 100644 --- a/THOUGHTS.txt +++ b/THOUGHTS.txt @@ -186,7 +186,7 @@ creates the interface instead of using an existing unconfigured one 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 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? -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 environment.defaultPackages. maybe call it packagesInProfile or 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 diff --git a/default.nix b/default.nix index 9f1696d..7a10547 100644 --- a/default.nix +++ b/default.nix @@ -4,7 +4,7 @@ let overlay = import ./overlay.nix; nixpkgs = import ( device.system // {overlays = [overlay]; }); - inherit (nixpkgs.pkgs) callPackage liminix; + inherit (nixpkgs.pkgs) callPackage writeText liminix; config = (import ./merge-modules.nix) [ ./modules/base.nix ({ lib, ... } : { config = { inherit (device) kernel; }; }) @@ -24,6 +24,9 @@ in { ln -s ${squashfs} squashfs 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 # cross-compiling nix-shell for any package we're customizing