From cc3020a32fa2a0bfd30056d77be07f263e658f59 Mon Sep 17 00:00:00 2001 From: Yusuf Bera Ertan Date: Mon, 31 Oct 2022 22:26:03 +0300 Subject: [PATCH] refactor: change projects -> inputs, make option description more explanatory --- examples/_d2n-flake-parts/flake.nix | 21 +++------------------ flake.nix | 2 +- src/modules/flake-parts/implementation.nix | 2 +- src/modules/flake-parts/interface.nix | 15 +++++++++++---- 4 files changed, 16 insertions(+), 24 deletions(-) diff --git a/examples/_d2n-flake-parts/flake.nix b/examples/_d2n-flake-parts/flake.nix index 7761c37d..5cb1ef62 100644 --- a/examples/_d2n-flake-parts/flake.nix +++ b/examples/_d2n-flake-parts/flake.nix @@ -16,29 +16,14 @@ }: flake-parts.lib.mkFlake {inherit self;} { systems = ["x86_64-linux"]; - imports = [dream2nix.flakeModule]; + imports = [dream2nix.flakeModuleBeta]; dream2nix = { config.projectRoot = ./.; - projects."ripgrep" = { + # define an input for dream2nix to generate outputs for + inputs."ripgrep" = { source = src; settings = [{builder = "crane";}]; }; }; - perSystem = { - config, - lib, - pkgs, - ... - }: let - inherit (config.dream2nix) outputs; - in { - packages.ripgrep = outputs.packages.ripgrep.overrideAttrs (old: { - buildInputs = (old.buildInputs or []) ++ [pkgs.hello]; - postInstall = '' - ${old.postInstall or ""} - hello - ''; - }); - }; }; } diff --git a/flake.nix b/flake.nix index 6e1cb183..414ad9ce 100644 --- a/flake.nix +++ b/flake.nix @@ -194,7 +194,7 @@ # kept for compat lib2 = d2n-lib; - flakeModule = { + flakeModuleBeta = { imports = [./src/modules/flake-parts]; dream2nix.lib = d2n-lib; }; diff --git a/src/modules/flake-parts/implementation.nix b/src/modules/flake-parts/implementation.nix index 6c1b2c81..c6a4c922 100644 --- a/src/modules/flake-parts/implementation.nix +++ b/src/modules/flake-parts/implementation.nix @@ -14,7 +14,7 @@ outputs = d2n.lib.dlib.mergeFlakes ( l.map (p: d2n.lib.makeFlakeOutputs (makeArgs p)) - (l.attrValues d2n.projects) + (l.attrValues d2n.inputs) ); in { config = { diff --git a/src/modules/flake-parts/interface.nix b/src/modules/flake-parts/interface.nix index fe89d902..8b84d8d6 100644 --- a/src/modules/flake-parts/interface.nix +++ b/src/modules/flake-parts/interface.nix @@ -22,14 +22,21 @@ in { }; default = {}; description = '' - The dream2nix config. + The dream2nix config. This will be applied to all defined `sources`. + You can override this per `source` by specifying `config` for that source: + ```nix + sources."name" = { + config.projectSource = ./source; + }; + ``` ''; }; - projects = l.mkOption { - type = t.attrsOf t.raw; + inputs = l.mkOption { + type = t.attrsOf t.attrs; default = {}; description = '' - The projects that outputs will be generated for. + A list of inputs to generate outputs from. + Each one takes the same arguments `makeFlakeOutputs` takes. ''; }; outputs = l.mkOption {