Skip to content

Instantly share code, notes, and snippets.

@Sigmanificient
Created April 30, 2024 06:18
Show Gist options
  • Save Sigmanificient/be93f7cbcec1affbdc1bdd2a930ac0b4 to your computer and use it in GitHub Desktop.
Save Sigmanificient/be93f7cbcec1affbdc1bdd2a930ac0b4 to your computer and use it in GitHub Desktop.
Get the amount of nix lines within the top 10 nixpkgs' nix files
find . -type f -name "*.nix" \
| xargs -i sh -c " \
cat {} \
| wc -l \
| xargs printf '%06d'; printf '\t%s\n' {}" \
| sort \
| tail -n 10 \
| tr '\t' ' ' \
| cut -d ' ' -f 1 \
| paste -s -d+ - \
| nix run nixpkgs#bc \
| xargs -i python -c \
"$(nix run nixpkgs#tokei \
| grep Total \
| grep -v "(Total)" \
| cut -d ' ' -f 23 \
| python -c \
"print(f'print(f\'{{100 * ({{}} / {input()}):,.2f}}%\')')")"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment