From 4cbe63ac640902384ca48244ab93e1da6d69ec12 Mon Sep 17 00:00:00 2001 From: Alexander Tomokhov Date: Fri, 1 Dec 2023 08:32:31 +0400 Subject: [PATCH] flake: abort on missing configPathsNeeded with message --- flake.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index 1e3cf1c..940ee1f 100644 --- a/flake.nix +++ b/flake.nix @@ -41,10 +41,12 @@ ++ # add SP modules, but contrain available config attributes for each # (TODO revise evaluation performance of the code below) - map - (sp-module: args@{ config, pkgs, ... }: + nixpkgs.lib.attrsets.mapAttrsToList + (name: sp-module: args@{ config, pkgs, ... }: let lib = nixpkgs.lib; + configPathsNeeded = sp-module.configPathsNeeded or + (abort "allowed config paths not set for module \"${name}\""); constrainConfigArgs = args'@{ pkgs, ... }: args' // { config = # TODO use lib.attrsets.mergeAttrsList from nixpkgs 23.05 @@ -52,7 +54,9 @@ (map (p: lib.attrsets.setAttrByPath p (lib.attrsets.getAttrFromPath p config)) - sp-module.configPathsNeeded)); + configPathsNeeded + ) + ); }; constrainImportsArgsRecursive = lib.attrsets.mapAttrsRecursive (p: v: @@ -76,7 +80,7 @@ constrainImportsArgsRecursive (sp-module.nixosModules.default (constrainConfigArgs args)) ) - (nixpkgs.lib.attrsets.attrValues sp-modules); + sp-modules; }; }; formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt;