From 48534f8c321cb33190a3cc80a9c364ffbf68c878 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Tue, 19 Mar 2024 02:44:58 +0100 Subject: 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 --- get-candidates.nix | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 get-candidates.nix (limited to 'get-candidates.nix') 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 ; + 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)) -- cgit v1.2.3