summaryrefslogtreecommitdiff
path: root/get-candidates.nix
blob: b9b6a07e4d9cdcbc3f6b19cbc7e4ddf541f0d09d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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))