nixos-configs/lib/pkgs/default.nix

67 lines
1.8 KiB
Nix
Raw Normal View History

2024-09-25 15:34:56 -04:00
{
pkgs,
self,
}: let
inherit (builtins) readFile fromJSON;
inherit (self.lib) capitalise mkVersion;
inherit (pkgs.lib) concatMapStrings elemAt length map optionalString splitString toLower;
in {
buildPlugin = pname: src:
pkgs.vimUtils.buildVimPlugin {
inherit pname src;
version = mkVersion src;
};
buildNodeModules = dir: npmDepsHash: let
packageJSON = fromJSON (readFile (dir + /package.json));
pkg = pkgs.callPackage ({buildNpmPackage, ...}:
buildNpmPackage {
pname = packageJSON.name;
inherit (packageJSON) version;
src = dir;
inherit npmDepsHash;
dontNpmBuild = true;
}) {};
in "${pkg}/lib/node_modules/${pkg.pname}/node_modules";
buildGirTypes = {
configPath,
packages,
pname,
2025-01-02 01:26:38 -05:00
delete ? [],
}: let
withGirNames =
map (package: {
inherit package;
girName =
if package.pname == "astal-wireplumber"
then "AstalWp-0.1"
2024-12-25 03:11:27 -05:00
else if package.pname == "astal"
then "AstalIO-0.1"
2024-12-25 03:11:27 -05:00
else if package.pname == "astal3"
then "Astal-3.0"
2024-12-25 03:11:27 -05:00
else if package.pname == "astal4"
2024-12-19 20:54:26 -05:00
then "Astal-4.0"
2024-12-27 01:27:33 -05:00
else if package.pname == "astal-powerprofiles"
then "AstalPowerProfiles-0.1"
else if package.pname == "gtk4"
then "Gtk-4.0"
2025-01-02 01:26:38 -05:00
else if package.pname == "libadwaita"
then "Adw-1"
else (concatMapStrings capitalise (splitString "-" package.pname)) + "-0.1";
})
packages;
in {
2025-01-02 01:26:38 -05:00
"${configPath}${optionalString (length packages == 1) "/${toLower (elemAt withGirNames 0).girName}"}" = {
force = true;
source = pkgs.callPackage ./mk-types {
inherit (self.inputs) ts-for-gir-src;
2025-01-02 01:26:38 -05:00
inherit delete pname withGirNames;
};
2025-01-02 01:26:38 -05:00
};
};
}