Skip to content

Commit

Permalink
main builder error handling improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
birdee committed Nov 12, 2024
1 parent 9a9b694 commit a912409
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
17 changes: 7 additions & 10 deletions builder/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
, packageDefinitions
, name
, nixpkgs
, system ? (if builtins.isAttrs nixpkgs && nixpkgs ? system then nixpkgs.system else import ./builder_error.nix)
, system ? (nixpkgs.system or import ./builder_error.nix)
, extra_pkg_config ? {}
, dependencyOverlays ? null
, nixCats_passthru ? {}
Expand All @@ -16,16 +16,13 @@ let
else (nixpkgs.config or {}) // extra_pkg_config;
overlays = if isList dependencyOverlays
then dependencyOverlays
else if isAttrs dependencyOverlays && hasAttr system dependencyOverlays
then dependencyOverlays.${system}
else if isNull dependencyOverlays then []
else import ./builder_error.nix;
else dependencyOverlays.${system} or
(if isNull dependencyOverlays then []
else import ./builder_error.nix);
in if isAttrs nixCats_passthru && isFunction categoryDefinitions
&& isAttrs packageDefinitions && isString name then
import (
if isAttrs nixpkgs && nixpkgs ? path && ! nixpkgs ? outPath
then nixpkgs.path else nixpkgs
) { inherit system config overlays; }
&& isAttrs packageDefinitions && isString name
then import (nixpkgs.path or nixpkgs.outPath or nixpkgs)
{ inherit system config overlays; }
else import ./builder_error.nix;

ncTools = import ./ncTools.nix { inherit (pkgs) lib; };
Expand Down
17 changes: 6 additions & 11 deletions utils/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ with builtins; rec {
luaPath:
{
nixpkgs
, system ? (if isAttrs nixpkgs && nixpkgs ? system then nixpkgs.system else import ../builder/builder_error.nix)
, system ? (nixpkgs.system or import ../builder/builder_error.nix)
, extra_pkg_config ? {}
, dependencyOverlays ? null
, nixCats_passthru ? {}
Expand All @@ -24,20 +24,15 @@ with builtins; rec {
else if isPath nixpkgs || isString nixpkgs then "path"
else if isAttrs nixpkgs && (lib.isDerivation nixpkgs || nixpkgs ? outPath) then "drv"
else import ../builder/builder_error.nix;
nixpkgspath = if pkgstype == "drv" then nixpkgs.outPath else if pkgstype == "pkgs" then nixpkgs.path else nixpkgs;
nixlib = if pkgstype == "pkgs" || pkgstype == "nixpkgs"
then nixpkgs.lib
else import "${nixpkgspath}/lib";
newnixpkgs = if pkgstype == "nixpkgs"
then nixpkgs
else if pkgstype == "pkgs"
then nixpkgs // { outPath = nixpkgspath; }
nixpkgspath = if pkgstype == "pkgs" then nixpkgs.path else nixpkgs.outPath or nixpkgs;
newnixpkgs = if pkgstype == "nixpkgs" then nixpkgs
else if pkgstype == "pkgs" then nixpkgs // { outPath = nixpkgspath; }
else {
lib = nixlib;
lib = nixpkgs.lib or import "${nixpkgspath}/lib";
outPath = nixpkgspath;
};
in
nixlib.makeOverridable (import ../builder) {
newnixpkgs.lib.makeOverridable (import ../builder) {
nixpkgs = newnixpkgs;
inherit luaPath categoryDefinitions packageDefinitions name
system extra_pkg_config dependencyOverlays nixCats_passthru;
Expand Down

0 comments on commit a912409

Please sign in to comment.