summaryrefslogtreecommitdiff
path: root/get-candidates.nix
diff options
context:
space:
mode:
authorstuebinm2024-03-19 02:44:58 +0100
committerstuebinm2024-03-19 02:45:25 +0100
commit48534f8c321cb33190a3cc80a9c364ffbf68c878 (patch)
tree609f30d231b394ed42ea623ff584873b3561b531 /get-candidates.nix
rust script to automatically add meta.mainProgram to nixpkgs
with thanks to pennae, who showed that this approach was possible (and wrote the status-report widget) https://github.com/pennae/nix-doc-munge
Diffstat (limited to 'get-candidates.nix')
-rw-r--r--get-candidates.nix30
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))