{"action":"created","issue":{"url":"https://api.github.com/repos/NixOS/nixpkgs/issues/48462","repository_url":"https://api.github.com/repos/NixOS/nixpkgs","labels_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/48462/labels{/name}","comments_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/48462/comments","events_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/48462/events","html_url":"https://github.com/NixOS/nixpkgs/issues/48462","id":370157389,"node_id":"MDU6SXNzdWUzNzAxNTczODk=","number":48462,"title":"dockerTools.buildLayeredImage creates skewed sized layers","user":{"login":"coretemp","id":34454443,"node_id":"MDQ6VXNlcjM0NDU0NDQz","avatar_url":"https://avatars0.githubusercontent.com/u/34454443?v=4","gravatar_id":"","url":"https://api.github.com/users/coretemp","html_url":"https://github.com/coretemp","followers_url":"https://api.github.com/users/coretemp/followers","following_url":"https://api.github.com/users/coretemp/following{/other_user}","gists_url":"https://api.github.com/users/coretemp/gists{/gist_id}","starred_url":"https://api.github.com/users/coretemp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coretemp/subscriptions","organizations_url":"https://api.github.com/users/coretemp/orgs","repos_url":"https://api.github.com/users/coretemp/repos","events_url":"https://api.github.com/users/coretemp/events{/privacy}","received_events_url":"https://api.github.com/users/coretemp/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-10-15T13:14:06Z","updated_at":"2018-10-15T15:01:17Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"## Issue description\r\nRecently `dockerTools.buildLayeredImage` ( https://grahamc.com/blog/nix-and-layered-docker-images ) functionality was merged into master. \r\n\r\nIt creates docker images with layers of a size with a distribution that is very skewed. See below for more information.\r\n\r\n### Steps to reproduce\r\n```\r\nlet\r\n  old_pkgs = import <nixpkgs> {};\r\n  pkgs  = <snip (assumes that it points at master> ;\r\n inherit (pkgs) stdenv;\r\n\r\nin pkgs.dockerTools.buildLayeredImage {\r\n   contents =  [pkgs.bashInteractive old_pkgs.curl old_pkgs.jq old_pkgs.emacs old_pkgs.git\r\n                old_pkgs.cacert old_pkgs.openssh old_pkgs.gnugrep\r\n                old_pkgs.coreutils\r\n                old_pkgs.which\r\n                old_pkgs.nix\r\n                old_pkgs.gnused old_pkgs.file old_pkgs.gawk];\r\n\r\n  name = \"foo/bar\";\r\n  tag = \"latest\";\r\n  config.Cmd = [ \"/bin/bash\" ];\r\n  maxLayers = 25;\r\n}\r\n```\r\n\r\nThe layers looks like: \r\n```\r\nb6cdec945d1b: Loading layer [==================================================>]    477MB/477MB\r\n86e60f3ed08f: Loading layer [==================================================>]  174.1kB/174.1kB\r\n79d24adb2c31: Loading layer [==================================================>]  348.2kB/348.2kB\r\n9354bd19facd: Loading layer [==================================================>]  12.19MB/12.19MB\r\n611dae553d72: Loading layer [==================================================>]  1.178MB/1.178MB\r\ncb916eb69cd1: Loading layer [==================================================>]  71.68kB/71.68kB\r\nee38b4411beb: Loading layer [==================================================>]    1.7MB/1.7MB\r\n05bad8e60f92: Loading layer [==================================================>]    809kB/809kB\r\nd30df3eb574c: Loading layer [==================================================>]    768kB/768kB\r\nbb3ba7943090: Loading layer [==================================================>]  40.96kB/40.96kB\r\ne7e6d2f94b2e: Loading layer [==================================================>]  5.612MB/5.612MB\r\n15048416f85e: Loading layer [==================================================>]  1.526MB/1.526MB\r\nb00ca1c01fd7: Loading layer [==================================================>]    512kB/512kB\r\n0518754facbc: Loading layer [==================================================>]  92.16kB/92.16kB\r\n13859dfd2c8b: Loading layer [==================================================>]  266.2kB/266.2kB\r\ne696a9248983: Loading layer [==================================================>]    256kB/256kB\r\n560c99588b76: Loading layer [==================================================>]  81.92kB/81.92kB\r\ndcf8aeee86d0: Loading layer [==================================================>]   51.2kB/51.2kB\r\n9b58d0959ca7: Loading layer [==================================================>]  2.898MB/2.898MB\r\n9caed6f91ab9: Loading layer [==================================================>]  112.6kB/112.6kB\r\ne7379e4a6dcb: Loading layer [==================================================>]  1.352MB/1.352MB\r\n4a5ae92f18dc: Loading layer [==================================================>]  40.96kB/40.96kB\r\nd91816088e26: Loading layer [==================================================>]  40.96kB/40.96kB\r\n7ddbb507422c: Loading layer [==================================================>]  21.79MB/21.79MB\r\n```\r\n\r\nAs you can see the size is unreasonably distributed (a 477MB layer with a bunch of tiny ones). \r\n\r\nMy question is: is this the intended behavior? If not, can we have tests that make sure the distribution of the size of the layers follows a particular (statistical) distribution.\r\n\r\n## Relevant people\r\n@graham-at-target \r\n\r\n## Technical details\r\n\r\n - system: `\"x86_64-linux\"`\r\n - host os: `Linux 4.14.74, NixOS, 18.09.git.08005ed (Jellyfish)`\r\n - multi-user?: `yes`\r\n - sandbox: `yes`\r\n - version: `nix-env (Nix) 2.1.1`\r\n - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`"},"comment":{"url":"https://api.github.com/repos/NixOS/nixpkgs/issues/comments/429889209","html_url":"https://github.com/NixOS/nixpkgs/issues/48462#issuecomment-429889209","issue_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/48462","id":429889209,"node_id":"MDEyOklzc3VlQ29tbWVudDQyOTg4OTIwOQ==","user":{"login":"coretemp","id":34454443,"node_id":"MDQ6VXNlcjM0NDU0NDQz","avatar_url":"https://avatars0.githubusercontent.com/u/34454443?v=4","gravatar_id":"","url":"https://api.github.com/users/coretemp","html_url":"https://github.com/coretemp","followers_url":"https://api.github.com/users/coretemp/followers","following_url":"https://api.github.com/users/coretemp/following{/other_user}","gists_url":"https://api.github.com/users/coretemp/gists{/gist_id}","starred_url":"https://api.github.com/users/coretemp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coretemp/subscriptions","organizations_url":"https://api.github.com/users/coretemp/orgs","repos_url":"https://api.github.com/users/coretemp/repos","events_url":"https://api.github.com/users/coretemp/events{/privacy}","received_events_url":"https://api.github.com/users/coretemp/received_events","type":"User","site_admin":false},"created_at":"2018-10-15T15:01:17Z","updated_at":"2018-10-15T15:01:17Z","author_association":"CONTRIBUTOR","body":"You probably want to add \r\n```\r\necho \"root:x:0:\" >> $out/etc/group\r\n``` \r\ntoo"}}
{"actor":{"display_login":"coretemp"}}