mirror of
https://github.com/nix-community/flakelight.git
synced 2025-06-20 17:47:45 +02:00
Add inputs module attribute for setting default inputs
This commit is contained in:
parent
76c6ec7938
commit
b9ee864785
33
default.nix
33
default.nix
@ -2,14 +2,15 @@
|
|||||||
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
nixpkgs:
|
localInputs:
|
||||||
let
|
let
|
||||||
inherit (builtins) intersectAttrs isPath readDir;
|
inherit (builtins) intersectAttrs isPath readDir;
|
||||||
inherit (nixpkgs.lib) attrNames attrVals callPackageWith composeManyExtensions
|
inherit (localInputs.nixpkgs.lib) attrNames attrVals callPackageWith
|
||||||
filter filterAttrs foldAttrs foldl functionArgs genAttrs hasSuffix
|
composeManyExtensions filter filterAttrs foldAttrs foldl functionArgs
|
||||||
isFunction isList isString listToAttrs mapAttrs mapAttrsToList mapAttrs'
|
genAttrs hasSuffix isFunction isList isString listToAttrs mapAttrs
|
||||||
mergeAttrs nameValuePair optional optionalAttrs optionalString parseDrvName
|
mapAttrsToList mapAttrs' mergeAttrs nameValuePair optional optionalAttrs
|
||||||
pathExists pipe recursiveUpdate removePrefix removeSuffix zipAttrsWith;
|
optionalString parseDrvName pathExists pipe recursiveUpdate removePrefix
|
||||||
|
removeSuffix zipAttrsWith;
|
||||||
|
|
||||||
exports = {
|
exports = {
|
||||||
inherit mkFlake systems importDir autoImport autoImportAttrs defaultPkgName
|
inherit mkFlake systems importDir autoImport autoImportAttrs defaultPkgName
|
||||||
@ -18,6 +19,7 @@ let
|
|||||||
};
|
};
|
||||||
|
|
||||||
builtinModule = { src, inputs, root }: {
|
builtinModule = { src, inputs, root }: {
|
||||||
|
inputs = { inherit (localInputs) nixpkgs; };
|
||||||
withOverlays = params: [
|
withOverlays = params: [
|
||||||
(final: prev: {
|
(final: prev: {
|
||||||
flakelite = params // {
|
flakelite = params // {
|
||||||
@ -72,6 +74,7 @@ let
|
|||||||
else null;
|
else null;
|
||||||
|
|
||||||
moduleAttrs = [
|
moduleAttrs = [
|
||||||
|
"inputs"
|
||||||
"withOverlay"
|
"withOverlay"
|
||||||
"withOverlays"
|
"withOverlays"
|
||||||
"package"
|
"package"
|
||||||
@ -109,6 +112,7 @@ let
|
|||||||
fnUpdate = f1: f2: args: (f1 args) // (f2 args);
|
fnUpdate = f1: f2: args: (f1 args) // (f2 args);
|
||||||
|
|
||||||
mergeModules = m1: m2: {
|
mergeModules = m1: m2: {
|
||||||
|
inputs = m1.inputs // m2.inputs;
|
||||||
withOverlays = m1.withOverlays ++ m2.withOverlays;
|
withOverlays = m1.withOverlays ++ m2.withOverlays;
|
||||||
packages = m1.packages // m2.packages;
|
packages = m1.packages // m2.packages;
|
||||||
devTools = fnConcat m1.devTools m2.devTools;
|
devTools = fnConcat m1.devTools m2.devTools;
|
||||||
@ -163,27 +167,26 @@ let
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
mkFlake = src: inputs: root:
|
mkFlake = src: root:
|
||||||
let
|
let
|
||||||
modules = root.modules or pipe (inputs // { self = { }; }) [
|
modules = root.modules or (pipe (removeAttrs root'.inputs [ "self" ]) [
|
||||||
(filterAttrs (_: v: v ? flakeliteModule))
|
(filterAttrs (_: v: v ? flakeliteModule))
|
||||||
(mapAttrsToList (_: v: v.flakeliteModule))
|
(mapAttrsToList (_: v: v.flakeliteModule))
|
||||||
];
|
]);
|
||||||
|
|
||||||
inputs' = { inherit nixpkgs; } // inputs;
|
|
||||||
|
|
||||||
nonSysArgs = exports // {
|
nonSysArgs = exports // {
|
||||||
args = nonSysArgs;
|
args = nonSysArgs;
|
||||||
flakelite = exports;
|
flakelite = exports;
|
||||||
inherit src;
|
|
||||||
inputs = inputs';
|
|
||||||
root = root';
|
root = root';
|
||||||
inherit (inputs.nixpkgs) lib;
|
inherit src;
|
||||||
|
inherit (merged) inputs;
|
||||||
|
inherit (merged.inputs.nixpkgs) lib;
|
||||||
};
|
};
|
||||||
|
|
||||||
applyNonSysArgs = callFn nonSysArgs;
|
applyNonSysArgs = callFn nonSysArgs;
|
||||||
|
|
||||||
moduleAttrDefaults = {
|
moduleAttrDefaults = {
|
||||||
|
inputs = { };
|
||||||
withOverlays = [ ];
|
withOverlays = [ ];
|
||||||
packages = { };
|
packages = { };
|
||||||
devTools = _: [ ];
|
devTools = _: [ ];
|
||||||
@ -253,7 +256,7 @@ let
|
|||||||
((map (m: normalizeModule (applyNonSysArgs m))
|
((map (m: normalizeModule (applyNonSysArgs m))
|
||||||
([ builtinModule ] ++ modules)) ++ [ root' ]);
|
([ builtinModule ] ++ modules)) ++ [ root' ]);
|
||||||
|
|
||||||
pkgsFor = system: import inputs'.nixpkgs {
|
pkgsFor = system: import merged.inputs.nixpkgs {
|
||||||
inherit system;
|
inherit system;
|
||||||
overlays = merged.withOverlays ++ [
|
overlays = merged.withOverlays ++ [
|
||||||
(final: _: callPkgs final merged.packages)
|
(final: _: callPkgs final merged.packages)
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
inputs.nixpkgs.url = "nixpkgs/nixos-22.11";
|
inputs.nixpkgs.url = "nixpkgs/nixos-22.11";
|
||||||
outputs = { self, nixpkgs }@inputs:
|
outputs = inputs:
|
||||||
let
|
let
|
||||||
lib = import ./. nixpkgs;
|
lib = import ./. inputs;
|
||||||
in
|
in
|
||||||
lib.mkFlake ./. inputs {
|
lib.mkFlake ./. {
|
||||||
outputs = { inherit lib; };
|
outputs = { inherit lib; };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user