diff --git a/builder/default.nix b/builder/default.nix index 0ee410f..07b4bd9 100644 --- a/builder/default.nix +++ b/builder/default.nix @@ -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 ? {} @@ -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; }; diff --git a/utils/default.nix b/utils/default.nix index ed96db1..87203b7 100644 --- a/utils/default.nix +++ b/utils/default.nix @@ -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 ? {} @@ -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;