feat(ags): improve types

This commit is contained in:
matt1432 2025-01-02 01:26:38 -05:00
parent 8871cc8f01
commit ccd437a275
10 changed files with 64 additions and 1778 deletions
lib/pkgs

View file

@ -31,6 +31,7 @@ in {
configPath,
packages,
pname,
delete ? [],
}: let
withGirNames =
map (package: {
@ -48,15 +49,18 @@ in {
then "AstalPowerProfiles-0.1"
else if package.pname == "gtk4"
then "Gtk-4.0"
else if package.pname == "libadwaita"
then "Adw-1"
else (concatMapStrings capitalise (splitString "-" package.pname)) + "-0.1";
})
packages;
in {
"${configPath}${optionalString (length packages == 1) "/${toLower (elemAt withGirNames 0).girName}"}".source =
pkgs.callPackage
./mk-types {
"${configPath}${optionalString (length packages == 1) "/${toLower (elemAt withGirNames 0).girName}"}" = {
force = true;
source = pkgs.callPackage ./mk-types {
inherit (self.inputs) ts-for-gir-src;
inherit pname withGirNames;
inherit delete pname withGirNames;
};
};
};
}

View file

@ -4,9 +4,10 @@
withGirNames,
buildNpmPackage,
ts-for-gir-src,
delete ? [],
...
}: let
inherit (lib) concatMapStringsSep;
inherit (lib) concatMapStringsSep optionalString;
buildPhase = ''
npx @ts-for-gir/cli generate ${concatMapStringsSep " " (p: p.girName) withGirNames} \
@ -31,6 +32,9 @@ in
'';
installPhase = ''
${optionalString (delete != []) (
"rm -f " + concatMapStringsSep " " (file: "./types/${file}.d.ts") delete
)}
cp -r ./types $out
'';
}