feat: add transformInputs which allows initializing inputs

This commit is contained in:
technofab 2025-08-15 15:29:49 +02:00
parent 7222ac48cd
commit 9f20f8c94b
No known key found for this signature in database
7 changed files with 25 additions and 17 deletions

View file

@ -1,7 +1,8 @@
{inputs, ...}: let {inputs, ...}: let
inherit (inputs) pkgs devshellLib; inherit (inputs) pkgs dslib;
in { in {
default = devshellLib.mkShell { default = dslib.mkShell {
packages = [pkgs.alejandra]; packages = [pkgs.alejandra];
enterShellCommands."ren".text = "echo Hello rensa!";
}; };
} }

View file

@ -5,10 +5,7 @@
outputs = i: outputs = i:
i i
// rec { // {
pkgs = import i.parent.nixpkgs { dslib = i.devshell.lib {inherit (i.parent) pkgs;};
inherit (i) system;
};
devshellLib = i.devshell.lib {inherit pkgs;};
}; };
} }

View file

@ -11,6 +11,11 @@
in in
rensa.buildWith { rensa.buildWith {
inherit inputs; inherit inputs;
transformInputs = system: i:
i
// {
pkgs = import i.nixpkgs {inherit system;};
};
cellsFrom = ./cells; cellsFrom = ./cells;
cellBlocks = with rensa.blocks; [ cellBlocks = with rensa.blocks; [
(simple "test") (simple "test")

View file

@ -10,6 +10,7 @@
inputs, inputs,
cellsFrom, cellsFrom,
cellBlocks, cellBlocks,
transformInputs ? system: i: i,
systems ? [ systems ? [
"x86_64-linux" "x86_64-linux"
"aarch64-linux" "aarch64-linux"
@ -21,7 +22,7 @@
loadOutputFor = system: let loadOutputFor = system: let
loadCell = createCellLoader { loadCell = createCellLoader {
inherit inputs system cells cellsFrom cellBlocks; inherit inputs system cells cellsFrom cellBlocks transformInputs;
}; };
cells' = l.mapAttrsToList (cell: type: cell) (l.readDir cellsFrom); cells' = l.mapAttrsToList (cell: type: cell) (l.readDir cellsFrom);

View file

@ -10,8 +10,9 @@
inputs, inputs,
system, system,
cells, cells,
transformInputs,
}: let }: let
importSignatureFor = createImportSignature {inherit inputs;}; importSignatureFor = createImportSignature {inherit inputs transformInputs;};
loadCellBlock = cellName: cellP: cellBlock: let loadCellBlock = cellName: cellP: cellBlock: let
blockP = paths.cellBlockPath cellP cellBlock; blockP = paths.cellBlockPath cellP cellBlock;
@ -25,8 +26,8 @@
then then
(callFlake (builtins.dirOf cellP.flake) { (callFlake (builtins.dirOf cellP.flake) {
root = { root = {
parent = inputs; parent = transformInputs system inputs;
system = system; inherit system;
}; };
}).outputs }).outputs
else {}; else {};
@ -121,9 +122,10 @@
cells, cells,
cellsFrom, cellsFrom,
cellBlocks, cellBlocks,
transformInputs,
}: let }: let
inherit (utils) unique accumulate; inherit (utils) unique accumulate;
loadCellBlock = createCellBlockLoader {inherit inputs system cells;}; loadCellBlock = createCellBlockLoader {inherit inputs system cells transformInputs;};
loadCell = cellName: let loadCell = cellName: let
cellP = paths.cellPath cellsFrom cellName; cellP = paths.cellPath cellsFrom cellName;

View file

@ -3,7 +3,8 @@
nixpkgs-lib.url = "github:nix-community/nixpkgs.lib"; nixpkgs-lib.url = "github:nix-community/nixpkgs.lib";
}; };
outputs = inputs: import ./. { outputs = inputs:
import ./. {
inherit (inputs.nixpkgs-lib) lib; inherit (inputs.nixpkgs-lib) lib;
}; };
} }

View file

@ -22,12 +22,13 @@
rev = cfg.inputs.self.sourceInfo.rev or "not-a-commit"; rev = cfg.inputs.self.sourceInfo.rev or "not-a-commit";
}; };
in { in {
inputs = inputs = cfg.transformInputs system (
(deSystemize system (cfg.inputs // additionalInputs)) (deSystemize system (cfg.inputs // additionalInputs))
// { // {
inherit self; inherit self;
cells = deSystemize system cells; cells = deSystemize system cells;
}; }
);
inherit cell system; inherit cell system;
}; };
in { in {