mirror of
https://github.com/nix-community/flakelight.git
synced 2025-08-17 18:31:29 +02:00
Extend package calling to allow single pkgs arg or no args
This commit is contained in:
22
default.nix
22
default.nix
@ -4,12 +4,12 @@
|
|||||||
|
|
||||||
nixpkgs:
|
nixpkgs:
|
||||||
let
|
let
|
||||||
inherit (builtins) readDir;
|
inherit (builtins) functionArgs isFunction isList isPath isString readDir;
|
||||||
inherit (nixpkgs.lib) attrNames attrVals composeManyExtensions filter
|
inherit (nixpkgs.lib) attrNames attrVals composeManyExtensions filter
|
||||||
filterAttrs foldAttrs foldl genAttrs hasSuffix isFunction isList listToAttrs
|
filterAttrs foldAttrs foldl genAttrs hasSuffix listToAttrs mapAttrs
|
||||||
mapAttrs mapAttrsToList mapAttrs' mergeAttrs nameValuePair optional
|
mapAttrsToList mapAttrs' mergeAttrs nameValuePair optional optionalAttrs
|
||||||
optionalAttrs optionalString parseDrvName pathExists pipe recursiveUpdate
|
optionalString parseDrvName pathExists pipe recursiveUpdate removeSuffix
|
||||||
removeSuffix zipAttrsWith;
|
zipAttrsWith;
|
||||||
|
|
||||||
exports = { inherit mkFlake loadNixDir systems; };
|
exports = { inherit mkFlake loadNixDir systems; };
|
||||||
|
|
||||||
@ -126,7 +126,17 @@ let
|
|||||||
((map (m: normalizeModule (m src inputs root'))
|
((map (m: normalizeModule (m src inputs root'))
|
||||||
([ baseModule ] ++ modules)) ++ [ root' ]);
|
([ baseModule ] ++ modules)) ++ [ root' ]);
|
||||||
|
|
||||||
genPackages = pkgs: mapAttrs (_: v: pkgs.callPackage v { });
|
callWith = pkgs: x:
|
||||||
|
let
|
||||||
|
x' = if (isPath x) || (isString x) then import x else x;
|
||||||
|
in
|
||||||
|
if ! isFunction x' then x'
|
||||||
|
else
|
||||||
|
if functionArgs x' == { }
|
||||||
|
then x' pkgs
|
||||||
|
else pkgs.callPackage x' { };
|
||||||
|
|
||||||
|
genPackages = pkgs: mapAttrs (_: callWith pkgs);
|
||||||
|
|
||||||
pkgsFor = system: import (inputs.nixpkgs or nixpkgs) {
|
pkgsFor = system: import (inputs.nixpkgs or nixpkgs) {
|
||||||
inherit system;
|
inherit system;
|
||||||
|
Reference in New Issue
Block a user