diff options
Diffstat (limited to 'get-candidates.nix')
-rw-r--r-- | get-candidates.nix | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/get-candidates.nix b/get-candidates.nix new file mode 100644 index 0000000..b9b6a07 --- /dev/null +++ b/get-candidates.nix @@ -0,0 +1,30 @@ +let + pkgs = import ../../../clones/nixpkgs { }; + lib = pkgs.lib; + + dbFile = builtins.storePath <nixpkgs/programs.sqlite>; + dbJson = pkgs.runCommand "json" { } '' + ${lib.getExe pkgs.sqlite} ${dbFile} '.mode json' " + SELECT package, system, json_group_array(name) AS names + FROM Programs + WHERE system = 'x86_64-linux' + GROUP BY package, system; + " > $out + ''; + + programs = lib.importJSON dbJson; + + # the channel is older than nixpkgs master, so some attributes may no longer exist + # (but we edit on master, hence need that for e.g. positions) + stillExists = row: lib.hasAttrByPath (lib.splitString "." row.package) pkgs; + programs2 = lib.filter stillExists programs; + + getPackage = e: lib.getAttrFromPath (lib.splitString "." e) pkgs; + isTrivial = row: + builtins.length (builtins.fromJSON row.names) == 1 + && !((getPackage row.package).meta ? "mainProgram"); + missing = lib.filter isTrivial programs2; +in + +pkgs.writeText "missing" + (builtins.toJSON (map (row: { pos = (getPackage row.package).meta.position or null; name = builtins.head (builtins.fromJSON row.names); }) missing)) |