{ lib, inputs, }: let shouldRecurseForDerivations = p: lib.isAttrs p && p.recurseForDerivations or false; flattenPkgsWithPaths = s: let f = path: p: if shouldRecurseForDerivations p then builtins.concatMap (n: f (path ++ [ n ]) p.${n}) (builtins.attrNames p) else if lib.isDerivation p then [ { inherit path; drv = p; } ] else [ ]; in builtins.concatMap (n: f [ n ] s.${n}) (builtins.attrNames s); flattenPkgs = s: map (e: e.drv) (flattenPkgsWithPaths s); platformsOf = ps: ( lists: builtins.foldl' ( list1: list2: builtins.filter (x: builtins.elem x list2) list1 ) (builtins.head lists) (builtins.tail lists) ) (builtins.map (p: p.meta.platforms or lib.platforms.all) ps); toyvo = { name = "Collin Diekvoss"; email = "Collin@Diekvoss.com"; matrix = "@toyvo:matrix.org"; github = "ToyVo"; githubId = 5168912; }; in { # Add your library functions here # # hexint = x: hexvals.${toLower x}; maintainers.toyvo = toyvo; isReserved = n: n == "lib" || n == "overlays" || n == "modules" || n == "nixosModules" || n == "homeModules" || n == "darwinModules" || n == "flakeModules"; isBuildable = p: let licenseFromMeta = p.meta.license or [ ]; licenseList = if builtins.isList licenseFromMeta then licenseFromMeta else [ licenseFromMeta ]; in !(p.meta.broken or false) && builtins.all (license: license.free or true) licenseList; isCacheable = p: !(p.preferLocalBuild or false); inherit shouldRecurseForDerivations flattenPkgs flattenPkgsWithPaths platformsOf ; outputsOf = p: map (o: p.${o}) p.outputs; forSystem = system: p: (builtins.any (s: s == system) (p.meta.platforms or [ system ])) && !(builtins.any (s: s == system) (p.meta.badPlatforms or [ ])); mkWrappedProgram = pkgs: { name, package, binaryName ? package.meta.mainProgram or (lib.getName package), configDir ? null, envVars ? { }, extraFlags ? [ ], runtimeDeps ? [ ], extraBinaries ? [ ], }: pkgs.runCommand name { nativeBuildInputs = [ pkgs.makeWrapper ]; meta = package.meta // { description = "${package.meta.description or binaryName} with bundled configuration"; platforms = platformsOf ([ package ] ++ runtimeDeps); maintainers = [ toyvo ]; }; } '' mkdir -p $out/bin makeWrapper ${lib.getExe package} $out/bin/${binaryName} \ ${lib.optionalString (configDir != null) "--set XDG_CONFIG_HOME ${configDir}"} \ ${lib.optionalString (runtimeDeps != [ ]) "--prefix PATH : ${lib.makeBinPath runtimeDeps}"} \ ${lib.concatMapStringsSep " " (n: "--set ${n} \"${envVars.${n}}\"") (lib.attrNames envVars)} \ ${lib.concatMapStringsSep " " (flag: "--add-flags \"${flag}\"") extraFlags} ${lib.concatMapStringsSep "\n" ( binName: "ln -s $out/bin/${binaryName} $out/bin/${binName}" ) extraBinaries} ''; }