Skip to content

Instantly share code, notes, and snippets.

@ryantm
Last active May 19, 2018 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryantm/076e45eff4ff89756a7b8e63a78c26fe to your computer and use it in GitHub Desktop.
Save ryantm/076e45eff4ff89756a7b8e63a78c26fe to your computer and use it in GitHub Desktop.
let
pkgs = import <nixpkgs> {};
pname = a: (builtins.parseDrvName pkgs."${a}".name).name;
versionParts = a:
builtins.splitVersion (builtins.parseDrvName pkgs."${a}".name).version;
separator = "_";
path = n : v:
if v == []
then n
else "${n}${separator}${builtins.concatStringsSep "_" v}";
versions = versionParts:
if builtins.length versionParts == 0
then [[]]
else
[[]] ++
(builtins.map
(rest: [(builtins.elemAt versionParts 0)] ++ rest)
(versions (builtins.tail versionParts)));
validPaths = a:
builtins.concatStringsSep " or "
(builtins.map
(vs: path (pname a) vs)
(versions (versionParts a)));
policy = a: "${a} | ${validPaths a} ";
attrpaths = [
#"qt56"
"autoconf213"
"automake111x"
"libgit2_0_25"
"apacheKafka_0_10"
"dbus-sharp-glib-2_0"
"antlr3_5"
"bison3"
"automoc4"
"fplll_20160331"
"owncloud-client"
"libavc1394"
"icu58"
];
in
{
result =
builtins.concatStringsSep "\n" (builtins.map policy attrpaths)
+ "\n";
}
nix eval --raw -f policy.nix result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment