Skip to content

Instantly share code, notes, and snippets.

@msteen
Last active February 11, 2019 14:57
Show Gist options
  • Save msteen/a40d5b16d0b283c903f230b98ec9df63 to your computer and use it in GitHub Desktop.
Save msteen/a40d5b16d0b283c903f230b98ec9df63 to your computer and use it in GitHub Desktop.
json=$(nix eval --json '(
with builtins;
with import <nixpkgs/nixos> { };
with pkgs.lib;
let try = x: default: let res = tryEval x; in if res.success then res.value else default; in
groupBy
(x: x.meta.license.shortName)
(concatMap (pkg:
try (
let x = map (pkg: { inherit (pkg) name; meta = { inherit (pkg.meta) license; }; })
(filter (pkg: pkg.meta ? license && pkg.meta.license ? shortName) [ pkg ]);
in deepSeq x x) []
) config.environment.systemPackages)
)') && jq '.' <<< "$json" > packages.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment