nix-community / flakelight

Framework for simplifying flake setup [maintainer=@accelbread]
MIT License
177 stars 3 forks source link

Expose `lib` in `overlay.default` #6

Closed noverby closed 8 months ago

noverby commented 8 months ago

Right now, packages are available in overlay.default.

Wouldn't it make sense to also expose lib in overlay.default, so you can define values and helper functions, that can be used globally?

accelbread commented 8 months ago

This I am a bit torn on.

On one hand, if a flake has a lib output, it is reasonable to put it in the overlay to allow easier use, and avoid the flake having to declare that.

On the other hand, there a few issues.

For one, the lib would need to be composable with nixpkgs lib. Most flakes I have seen with lib outputs, while this would work, are not designed with that in mind. Usual use would be use lib for nixpkgs and flake-name.lib for that flake's lib separately. Even if a flake does not use a name currently in nixpkgs, a future update to nixpkgs could cause the overlay to mask an incompatible function and cause hard to debug issues. Flakes that do intend to compose also usually don't put their functions in the top-level of lib but in lib.flake-name. This would be the better general approach but requires knowing that that flake-name name should be. As an edge case, a flake lib which is made extensible and relies on extending itself could malfunction when combined with nixpkgs lib, as we'd have to use nixpkgs' extensibility.

Second, with packages, there is a distinct difference between using the overlay and using the flake package outputs. Flake package outputs are built with the flake's deps, but overlays use deps as supplied by the user. For lib code, the functions would be the exact same whether used from the flake output or the overlay, so theres much less value. To make them useful, the lib would have to be defined as an overlay that uses lib functions from prev and have the regular overlay generated from that. This would be non-standard and wouldn't make sense as default imo.

Third, as a user of the flake, I'd find it surprising if the overlay modified lib, especially because it could conflict with my own lib modifications.

Currently to add lib to the overlay, namespacing under flake-name, you could do something like:

{
  inputs.flakelight.url = "github:accelbread/flakelight";
  outputs = { flakelight, ... }:
    flakelight ./. rec {
      pkgs.hello = { hello }: hello;
      lib = { test = x: x; };
      overlay = final: prev: { lib = prev.lib.extend (final: prev: { flake-name = lib; });};
    };
}

The above unfortunately is not simple, but would have both lib.flake-name and the package in the output overlay. We could make a libOverlay option to directly set lib overlays though that would be non-standard. Also I'm not sure putting lib in the overlay is a good idea in the first place.

So I am leaning towards not doing lib automatically since its unclear what the automatic thing to do is. There does not seem to be a clear "good way" to do it. I could be convinced otherwise though.

noverby commented 8 months ago

Maybe there could be an option to expose lib attributes, like they do in crane with e.g. mkCargoDerivation: https://github.com/ipetkov/crane/blob/master/lib/cargoBuild.nix

accelbread commented 8 months ago

Yeah, theres already an option for exposing a lib attribute: https://github.com/accelbread/flakelight/blob/master/api_guide.md#lib-1. It also supports autoloading.

Though crane is also a bad example since it breaks convention by having crane.lib.${system} lib outputs instead of the conventional single lib output.

To have a normal lib output, can just use the flakelight option. If you want to have per-system lib outputs like crane, can use the perSystem option to set lib.

noverby commented 8 months ago

@noverby But if you use the lib option, will all the lib attributes then be available globally?

E.g. if you define mkCustomDerivation in nix/lib, can it then be used in nix/packages:

# pkg1.nix
{mkCustomDerivation, ...}: mkCustomDerivation { ... } 
accelbread commented 8 months ago

You would be able to do the following:

# pkg1.nix
{outputs, ...}: outputs.lib.mkCustomDerivation { ... }

Could also use self, like:

# pkg1.nix
{inputs, ...}: inputs.self.lib.mkCustomDerivation { ... }

Though I would avoid using self, since when using self its easy to trigger inf recursion.

accelbread commented 8 months ago

Though, if you want to access functions directly through the package set, you can use withOverlays

See flakelight-rust, which uses withOverlays to add crane stuff to the package set: https://github.com/accelbread/flakelight-rust/blob/master/flakelight-rust.nix

To use withOverlays to have all your lib stuff available, would need something like:

{
  inputs.flakelight.url = "github:accelbread/flakelight";
  outputs = { flakelight, ... }:
    flakelight ./. {
      withOverlays = final: prev: prev.outputs.lib;
    };
}

With that, your last example would work with getting mkCustomDerivation directly from the pkgs set.

noverby commented 8 months ago

@accelbread Yeah you are right about infinite recursion :) By adding lib to overlays, as you suggested, it causes the following infinite recursion error:

Error output ```bash warning: Git tree '/home/noverby/Work/factbird/cloud-services' is dirty error: … while evaluating call site at «none»:0: (source not available) … while calling anonymous lambda at «string»:2:23: 1| 2| lockFileStr: rootSrc: rootSubdir: | ^ 3| … while evaluating call site at «none»:0: (source not available) … while calling anonymous lambda at «string»:10:13: 9| builtins.mapAttrs 10| (key: node: | ^ 11| let … while evaluating call site at «string»:45:21: 44| 45| outputs = flake.outputs (inputs // { self = result; }); | ^ 46| … while calling 'outputs' at /nix/store/d94zkffsad8qz8v1qxj2f76j58b6g09h-source/flake.nix:30:13: 29| }; 30| outputs = { | ^ 31| flakelight, … while evaluating call site at /nix/store/d94zkffsad8qz8v1qxj2f76j58b6g09h-source/flake.nix:39:5: 38| } @ inputs: 39| flakelight ./. (_: { | ^ 40| inherit inputs; … while calling '__functor' at /nix/store/y3hmkfmzwknj6k9ijw3msjx5akgdhyvk-source/default.nix:19:28: 18| mkFlake = { 19| __functor = self: src: root: (evalModules { | ^ 20| specialArgs.modulesPath = ./builtinModules; … while evaluating call site at «none»:0: (source not available) … while calling 'g' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/attrsets.nix:599:19: 598| g = 599| name: value: | ^ 600| if isAttrs value && cond value … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/attrsets.nix:602:20: 601| then recurse (path ++ [name]) value 602| else f (path ++ [name]) value; | ^ 603| in mapAttrs g; … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:242:72: 241| # For definitions that have an associated option 242| declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options; | ^ 243| … while evaluating the attribute 'value' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:768:9: 767| in warnDeprecation opt // 768| { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value; | ^ 769| inherit (res.defsFinal') highestPrio; … while evaluating the option `outputs': … while evaluating the attribute 'mergedValue' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:803:5: 802| # Type-check the remaining definitions, and merge them. Or throw if no definitions. 803| mergedValue = | ^ 804| if isDefined then … while evaluating the attribute 'values' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:797:9: 796| in { 797| values = defs'''; | ^ 798| inherit (defs'') highestPrio; … while evaluating the attribute 'values' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:896:7: 895| in { 896| values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs; | ^ 897| inherit highestPrio; … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:783:17: 782| # Process mkMerge and mkIf properties. 783| defs' = concatMap (m: | ^ 784| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value)) … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:783:28: 782| # Process mkMerge and mkIf properties. 783| defs' = concatMap (m: | ^ 784| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value)) … while evaluating definitions from `/nix/store/y3hmkfmzwknj6k9ijw3msjx5akgdhyvk-source/builtinModules/core.nix': … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:784:137: 783| defs' = concatMap (m: 784| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value)) | ^ 785| ) defs; … while calling 'dischargeProperties' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:855:25: 854| */ 855| dischargeProperties = def: | ^ 856| if def._type or "" == "merge" then … while evaluating the attribute 'value' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:605:52: 604| (n: value: 605| [{ inherit (module) file; inherit value; }] | ^ 606| ) … while evaluating call site at /nix/store/y3hmkfmzwknj6k9ijw3msjx5akgdhyvk-source/builtinModules/core.nix:59:15: 58| 59| outputs = foldAttrs mergeAttrs { } (map | ^ 60| (system: mapAttrs … while calling 'foldAttrs' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/attrsets.nix:416:5: 415| # A list of attribute sets to fold together by key. 416| list_of_attrs: | ^ 417| foldr (n: a: … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/attrsets.nix:417:5: 416| list_of_attrs: 417| foldr (n: a: | ^ 418| foldr (name: o: … while calling 'foldr' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/lists.nix:53:20: 52| */ 53| foldr = op: nul: list: | ^ 54| let … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/lists.nix:60:8: 59| else op (elemAt list n) (fold' (n + 1)); 60| in fold' 0; | ^ 61| … while calling 'fold'' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/lists.nix:56:15: 55| len = length list; 56| fold' = n: | ^ 57| if n == len … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/lists.nix:59:14: 58| then nul 59| else op (elemAt list n) (fold' (n + 1)); | ^ 60| in fold' 0; … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/attrsets.nix:417:15: 416| list_of_attrs: 417| foldr (n: a: | ^ 418| foldr (name: o: … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/attrsets.nix:418:9: 417| foldr (n: a: 418| foldr (name: o: | ^ 419| o // { ${name} = op n.${name} (a.${name} or nul); } … while calling 'foldr' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/lists.nix:53:20: 52| */ 53| foldr = op: nul: list: | ^ 54| let … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/lists.nix:60:8: 59| else op (elemAt list n) (fold' (n + 1)); 60| in fold' 0; | ^ 61| … while calling 'fold'' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/lists.nix:56:15: 55| len = length list; 56| fold' = n: | ^ 57| if n == len … while evaluating call site at «none»:0: (source not available) … while calling anonymous lambda at /nix/store/y3hmkfmzwknj6k9ijw3msjx5akgdhyvk-source/builtinModules/core.nix:60:8: 59| outputs = foldAttrs mergeAttrs { } (map 60| (system: mapAttrs | ^ 61| (_: v: { ${system} = v; }) … while evaluating call site at /nix/store/y3hmkfmzwknj6k9ijw3msjx5akgdhyvk-source/builtinModules/core.nix:62:10: 61| (_: v: { ${system} = v; }) 62| (config.perSystem (import inputs.nixpkgs { | ^ 63| inherit system; … while calling 'merge' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/types.nix:638:9: 637| merge = loc: defs: 638| fnArgs: (mergeDefinitions (loc ++ [ "" ]) elemType (map (fn: { inherit (fn) file; value = fn.value fnArgs; }) defs)).mergedValue; | ^ 639| getSubOptions = prefix: elemType.getSubOptions (prefix ++ [ "" ]); … while evaluating the attribute 'mergedValue' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:803:5: 802| # Type-check the remaining definitions, and merge them. Or throw if no definitions. 803| mergedValue = | ^ 804| if isDefined then … while evaluating the attribute 'values' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:797:9: 796| in { 797| values = defs'''; | ^ 798| inherit (defs'') highestPrio; … while evaluating the attribute 'values' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:896:7: 895| in { 896| values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs; | ^ 897| inherit highestPrio; … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:783:17: 782| # Process mkMerge and mkIf properties. 783| defs' = concatMap (m: | ^ 784| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value)) … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:783:28: 782| # Process mkMerge and mkIf properties. 783| defs' = concatMap (m: | ^ 784| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value)) … while evaluating definitions from `/nix/store/y3hmkfmzwknj6k9ijw3msjx5akgdhyvk-source/builtinModules/formatter.nix': … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:784:137: 783| defs' = concatMap (m: 784| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value)) | ^ 785| ) defs; … while calling 'dischargeProperties' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:855:25: 854| */ 855| dischargeProperties = def: | ^ 856| if def._type or "" == "merge" then … while evaluating the attribute 'value' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/types.nix:638:106: 637| merge = loc: defs: 638| fnArgs: (mergeDefinitions (loc ++ [ "" ]) elemType (map (fn: { inherit (fn) file; value = fn.value fnArgs; }) defs)).mergedValue; | ^ 639| getSubOptions = prefix: elemType.getSubOptions (prefix ++ [ "" ]); … while evaluating call site at /nix/store/y3hmkfmzwknj6k9ijw3msjx5akgdhyvk-source/builtinModules/core.nix:62:28: 61| (_: v: { ${system} = v; }) 62| (config.perSystem (import inputs.nixpkgs { | ^ 63| inherit system; … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/top-level/impure.nix:14:1: 13| 14| { # We put legacy `system` into `localSystem`, if `localSystem` was not passed. | ^ 15| # If neither is passed, assume we are building packages on the current … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/top-level/impure.nix:87:1: 86| 87| import ./. (builtins.removeAttrs args [ "system" ] // { | ^ 88| inherit config overlays localSystem; … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/top-level/default.nix:19:1: 18| 19| { # The system packages will be built on. See the manual for the | ^ 20| # subtle division of labor between these two `*System`s and the three … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/top-level/default.nix:132:4: 131| 132| in checked pkgs | ^ 133| … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/top-level/default.nix:58:108: 57| throwIfNot (lib.isList crossOverlays) "The crossOverlays argument to nixpkgs must be a list." 58| lib.foldr (x: throwIfNot (lib.isFunction x) "All crossOverlays passed to nixpkgs must be functions.") (r: r) crossOverlays | ^ 59| ; … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/top-level/default.nix:130:10: 129| 130| pkgs = boot stages; | ^ 131| … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:42:1: 41| # other words, this does a foldr not foldl. 42| stageFuns: let | ^ 43| … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:142:4: 141| 142| in dfold folder postStage (_: {}) withAllowCustomOverrides | ^ 143| … while calling 'dfold' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:60:27: 59| */ 60| dfold = op: lnul: rnul: list: | ^ 61| let … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:72:13: 71| lapp = lnul cur; 72| cur = go lapp 0; | ^ 73| in cur; … while calling 'go' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:63:18: 62| len = builtins.length list; 63| go = pred: n: | ^ 64| if n == len … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:68:18: 67| # Note the cycle -- call-by-need ensures finite fold. 68| cur = op pred (builtins.elemAt list n) succ; | ^ 69| succ = go cur (n + 1); … while calling 'folder' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:89:33: 88| # debugging purposes. 89| folder = nextStage: stageFun: prevStage: let | ^ 90| args = stageFun prevStage; … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:90:12: 89| folder = nextStage: stageFun: prevStage: let 90| args = stageFun prevStage; | ^ 91| args' = args // { … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:79:23: 78| withAllowCustomOverrides = lib.lists.imap1 79| (index: stageFun: prevStage: | ^ 80| # So true by default for only the first element because one … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:84:11: 83| { allowCustomOverrides = index == 1; } 84| // (stageFun prevStage)) | ^ 85| (lib.lists.reverseList stageFuns); … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:679:4: 678| # This "no-op" stage is just a place to put the assertions about stage5. 679| (prevStage: | ^ 680| # previous stage5 stdenv; see stage3 comment regarding gcc, … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:682:12: 681| # which applies here as well. 682| assert isBuiltByNixpkgsCompiler prevStage.binutils-unwrapped; | ^ 683| assert isBuiltByNixpkgsCompiler prevStage.${localSystem.libc}; … while calling 'isBuiltByNixpkgsCompiler' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:107:5: 106| isBuiltByNixpkgsCompiler = 107| pkg: isFromNixpkgs pkg && isFromNixpkgs pkg.stdenv.cc.cc; | ^ 108| isBuiltByBootstrapFilesCompiler = … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:107:10: 106| isBuiltByNixpkgsCompiler = 107| pkg: isFromNixpkgs pkg && isFromNixpkgs pkg.stdenv.cc.cc; | ^ 108| isBuiltByBootstrapFilesCompiler = … while calling 'isFromNixpkgs' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:103:19: 102| 103| isFromNixpkgs = pkg: !(isFromBootstrapFiles pkg); | ^ 104| isFromBootstrapFiles = … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:103:26: 102| 103| isFromNixpkgs = pkg: !(isFromBootstrapFiles pkg); | ^ 104| isFromBootstrapFiles = … while calling 'isFromBootstrapFiles' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:105:5: 104| isFromBootstrapFiles = 105| pkg: pkg.passthru.isFromBootstrapFiles or false; | ^ 106| isBuiltByNixpkgsCompiler = … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:69:18: 68| cur = op pred (builtins.elemAt list n) succ; 69| succ = go cur (n + 1); | ^ 70| in cur; … while calling 'go' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:63:18: 62| len = builtins.length list; 63| go = pred: n: | ^ 64| if n == len … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:68:18: 67| # Note the cycle -- call-by-need ensures finite fold. 68| cur = op pred (builtins.elemAt list n) succ; | ^ 69| succ = go cur (n + 1); … while calling 'folder' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:89:33: 88| # debugging purposes. 89| folder = nextStage: stageFun: prevStage: let | ^ 90| args = stageFun prevStage; … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:90:12: 89| folder = nextStage: stageFun: prevStage: let 90| args = stageFun prevStage; | ^ 91| args' = args // { … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:79:23: 78| withAllowCustomOverrides = lib.lists.imap1 79| (index: stageFun: prevStage: | ^ 80| # So true by default for only the first element because one … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:84:11: 83| { allowCustomOverrides = index == 1; } 84| // (stageFun prevStage)) | ^ 85| (lib.lists.reverseList stageFuns); … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:588:4: 587| # 588| (prevStage: | ^ 589| # previous stage4 stdenv; see stage3 comment regarding gcc, … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:591:12: 590| # which applies here as well. 591| assert isBuiltByNixpkgsCompiler prevStage.binutils-unwrapped; | ^ 592| assert isBuiltByNixpkgsCompiler prevStage.${localSystem.libc}; … while calling 'isBuiltByNixpkgsCompiler' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:107:5: 106| isBuiltByNixpkgsCompiler = 107| pkg: isFromNixpkgs pkg && isFromNixpkgs pkg.stdenv.cc.cc; | ^ 108| isBuiltByBootstrapFilesCompiler = … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:107:10: 106| isBuiltByNixpkgsCompiler = 107| pkg: isFromNixpkgs pkg && isFromNixpkgs pkg.stdenv.cc.cc; | ^ 108| isBuiltByBootstrapFilesCompiler = … while calling 'isFromNixpkgs' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:103:19: 102| 103| isFromNixpkgs = pkg: !(isFromBootstrapFiles pkg); | ^ 104| isFromBootstrapFiles = … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:103:26: 102| 103| isFromNixpkgs = pkg: !(isFromBootstrapFiles pkg); | ^ 104| isFromBootstrapFiles = … while calling 'isFromBootstrapFiles' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:105:5: 104| isFromBootstrapFiles = 105| pkg: pkg.passthru.isFromBootstrapFiles or false; | ^ 106| isBuiltByNixpkgsCompiler = … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:69:18: 68| cur = op pred (builtins.elemAt list n) succ; 69| succ = go cur (n + 1); | ^ 70| in cur; … while calling 'go' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:63:18: 62| len = builtins.length list; 63| go = pred: n: | ^ 64| if n == len … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:68:18: 67| # Note the cycle -- call-by-need ensures finite fold. 68| cur = op pred (builtins.elemAt list n) succ; | ^ 69| succ = go cur (n + 1); … while calling 'folder' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:89:33: 88| # debugging purposes. 89| folder = nextStage: stageFun: prevStage: let | ^ 90| args = stageFun prevStage; … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:90:12: 89| folder = nextStage: stageFun: prevStage: let 90| args = stageFun prevStage; | ^ 91| args' = args // { … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:79:23: 78| withAllowCustomOverrides = lib.lists.imap1 79| (index: stageFun: prevStage: | ^ 80| # So true by default for only the first element because one … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:84:11: 83| { allowCustomOverrides = index == 1; } 84| // (stageFun prevStage)) | ^ 85| (lib.lists.reverseList stageFuns); … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:527:4: 526| # 527| (prevStage: | ^ 528| # previous stage3 stdenv: … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:529:12: 528| # previous stage3 stdenv: 529| assert isBuiltByNixpkgsCompiler prevStage.binutils-unwrapped; | ^ 530| assert isBuiltByNixpkgsCompiler prevStage.${localSystem.libc}; … while calling 'isBuiltByNixpkgsCompiler' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:107:5: 106| isBuiltByNixpkgsCompiler = 107| pkg: isFromNixpkgs pkg && isFromNixpkgs pkg.stdenv.cc.cc; | ^ 108| isBuiltByBootstrapFilesCompiler = … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:107:10: 106| isBuiltByNixpkgsCompiler = 107| pkg: isFromNixpkgs pkg && isFromNixpkgs pkg.stdenv.cc.cc; | ^ 108| isBuiltByBootstrapFilesCompiler = … while calling 'isFromNixpkgs' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:103:19: 102| 103| isFromNixpkgs = pkg: !(isFromBootstrapFiles pkg); | ^ 104| isFromBootstrapFiles = … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:103:26: 102| 103| isFromNixpkgs = pkg: !(isFromBootstrapFiles pkg); | ^ 104| isFromBootstrapFiles = … while calling 'isFromBootstrapFiles' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:105:5: 104| isFromBootstrapFiles = 105| pkg: pkg.passthru.isFromBootstrapFiles or false; | ^ 106| isBuiltByNixpkgsCompiler = … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:69:18: 68| cur = op pred (builtins.elemAt list n) succ; 69| succ = go cur (n + 1); | ^ 70| in cur; … while calling 'go' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:63:18: 62| len = builtins.length list; 63| go = pred: n: | ^ 64| if n == len … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:68:18: 67| # Note the cycle -- call-by-need ensures finite fold. 68| cur = op pred (builtins.elemAt list n) succ; | ^ 69| succ = go cur (n + 1); … while calling 'folder' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:89:33: 88| # debugging purposes. 89| folder = nextStage: stageFun: prevStage: let | ^ 90| args = stageFun prevStage; … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:90:12: 89| folder = nextStage: stageFun: prevStage: let 90| args = stageFun prevStage; | ^ 91| args' = args // { … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:79:23: 78| withAllowCustomOverrides = lib.lists.imap1 79| (index: stageFun: prevStage: | ^ 80| # So true by default for only the first element because one … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:84:11: 83| { allowCustomOverrides = index == 1; } 84| // (stageFun prevStage)) | ^ 85| (lib.lists.reverseList stageFuns); … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:485:4: 484| # binutils and rest of the bootstrap tools, including GCC. 485| (prevStage: | ^ 486| # previous stage2 stdenv: … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:487:19: 486| # previous stage2 stdenv: 487| assert isBuiltByNixpkgsCompiler prevStage.binutils-unwrapped; | ^ 488| assert isBuiltByNixpkgsCompiler prevStage.${localSystem.libc}; … while calling 'isBuiltByNixpkgsCompiler' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:107:5: 106| isBuiltByNixpkgsCompiler = 107| pkg: isFromNixpkgs pkg && isFromNixpkgs pkg.stdenv.cc.cc; | ^ 108| isBuiltByBootstrapFilesCompiler = … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:107:10: 106| isBuiltByNixpkgsCompiler = 107| pkg: isFromNixpkgs pkg && isFromNixpkgs pkg.stdenv.cc.cc; | ^ 108| isBuiltByBootstrapFilesCompiler = … while calling 'isFromNixpkgs' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:103:19: 102| 103| isFromNixpkgs = pkg: !(isFromBootstrapFiles pkg); | ^ 104| isFromBootstrapFiles = … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:103:26: 102| 103| isFromNixpkgs = pkg: !(isFromBootstrapFiles pkg); | ^ 104| isFromBootstrapFiles = … while calling 'isFromBootstrapFiles' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:105:5: 104| isFromBootstrapFiles = 105| pkg: pkg.passthru.isFromBootstrapFiles or false; | ^ 106| isBuiltByNixpkgsCompiler = … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:69:18: 68| cur = op pred (builtins.elemAt list n) succ; 69| succ = go cur (n + 1); | ^ 70| in cur; … while calling 'go' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:63:18: 62| len = builtins.length list; 63| go = pred: n: | ^ 64| if n == len … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:68:18: 67| # Note the cycle -- call-by-need ensures finite fold. 68| cur = op pred (builtins.elemAt list n) succ; | ^ 69| succ = go cur (n + 1); … while calling 'folder' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:89:33: 88| # debugging purposes. 89| folder = nextStage: stageFun: prevStage: let | ^ 90| args = stageFun prevStage; … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:90:12: 89| folder = nextStage: stageFun: prevStage: let 90| args = stageFun prevStage; | ^ 91| args' = args // { … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:79:23: 78| withAllowCustomOverrides = lib.lists.imap1 79| (index: stageFun: prevStage: | ^ 80| # So true by default for only the first element because one … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:84:11: 83| { allowCustomOverrides = index == 1; } 84| // (stageFun prevStage)) | ^ 85| (lib.lists.reverseList stageFuns); … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:399:4: 398| # 399| (prevStage: | ^ 400| # previous stage1 stdenv: … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:401:12: 400| # previous stage1 stdenv: 401| assert isBuiltByBootstrapFilesCompiler prevStage.binutils-unwrapped; | ^ 402| assert isFromBootstrapFiles prevStage."${localSystem.libc}"; … while calling 'isBuiltByBootstrapFilesCompiler' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:109:5: 108| isBuiltByBootstrapFilesCompiler = 109| pkg: isFromNixpkgs pkg && isFromBootstrapFiles pkg.stdenv.cc.cc; | ^ 110| … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:109:10: 108| isBuiltByBootstrapFilesCompiler = 109| pkg: isFromNixpkgs pkg && isFromBootstrapFiles pkg.stdenv.cc.cc; | ^ 110| … while calling 'isFromNixpkgs' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:103:19: 102| 103| isFromNixpkgs = pkg: !(isFromBootstrapFiles pkg); | ^ 104| isFromBootstrapFiles = … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:103:26: 102| 103| isFromNixpkgs = pkg: !(isFromBootstrapFiles pkg); | ^ 104| isFromBootstrapFiles = … while calling 'isFromBootstrapFiles' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:105:5: 104| isFromBootstrapFiles = 105| pkg: pkg.passthru.isFromBootstrapFiles or false; | ^ 106| isBuiltByNixpkgsCompiler = … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:69:18: 68| cur = op pred (builtins.elemAt list n) succ; 69| succ = go cur (n + 1); | ^ 70| in cur; … while calling 'go' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:63:18: 62| len = builtins.length list; 63| go = pred: n: | ^ 64| if n == len … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:68:18: 67| # Note the cycle -- call-by-need ensures finite fold. 68| cur = op pred (builtins.elemAt list n) succ; | ^ 69| succ = go cur (n + 1); … while calling 'folder' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:89:33: 88| # debugging purposes. 89| folder = nextStage: stageFun: prevStage: let | ^ 90| args = stageFun prevStage; … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:90:12: 89| folder = nextStage: stageFun: prevStage: let 90| args = stageFun prevStage; | ^ 91| args' = args // { … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:79:23: 78| withAllowCustomOverrides = lib.lists.imap1 79| (index: stageFun: prevStage: | ^ 80| # So true by default for only the first element because one … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:84:11: 83| { allowCustomOverrides = index == 1; } 84| // (stageFun prevStage)) | ^ 85| (lib.lists.reverseList stageFuns); … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:320:4: 319| # is not part of the final stdenv. 320| (prevStage: | ^ 321| assert isBuiltByBootstrapFilesCompiler prevStage.binutils-unwrapped; … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:321:12: 320| (prevStage: 321| assert isBuiltByBootstrapFilesCompiler prevStage.binutils-unwrapped; | ^ 322| assert isFromBootstrapFiles prevStage."${localSystem.libc}"; … while calling 'isBuiltByBootstrapFilesCompiler' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:109:5: 108| isBuiltByBootstrapFilesCompiler = 109| pkg: isFromNixpkgs pkg && isFromBootstrapFiles pkg.stdenv.cc.cc; | ^ 110| … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:109:10: 108| isBuiltByBootstrapFilesCompiler = 109| pkg: isFromNixpkgs pkg && isFromBootstrapFiles pkg.stdenv.cc.cc; | ^ 110| … while calling 'isFromNixpkgs' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:103:19: 102| 103| isFromNixpkgs = pkg: !(isFromBootstrapFiles pkg); | ^ 104| isFromBootstrapFiles = … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:103:26: 102| 103| isFromNixpkgs = pkg: !(isFromBootstrapFiles pkg); | ^ 104| isFromBootstrapFiles = … while calling 'isFromBootstrapFiles' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:105:5: 104| isFromBootstrapFiles = 105| pkg: pkg.passthru.isFromBootstrapFiles or false; | ^ 106| isBuiltByNixpkgsCompiler = … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:69:18: 68| cur = op pred (builtins.elemAt list n) succ; 69| succ = go cur (n + 1); | ^ 70| in cur; … while calling 'go' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:63:18: 62| len = builtins.length list; 63| go = pred: n: | ^ 64| if n == len … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:68:18: 67| # Note the cycle -- call-by-need ensures finite fold. 68| cur = op pred (builtins.elemAt list n) succ; | ^ 69| succ = go cur (n + 1); … while calling 'folder' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:89:33: 88| # debugging purposes. 89| folder = nextStage: stageFun: prevStage: let | ^ 90| args = stageFun prevStage; … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:90:12: 89| folder = nextStage: stageFun: prevStage: let 90| args = stageFun prevStage; | ^ 91| args' = args // { … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:79:23: 78| withAllowCustomOverrides = lib.lists.imap1 79| (index: stageFun: prevStage: | ^ 80| # So true by default for only the first element because one … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:84:11: 83| { allowCustomOverrides = index == 1; } 84| // (stageFun prevStage)) | ^ 85| (lib.lists.reverseList stageFuns); … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:283:4: 282| # overrides attribute and the inherit syntax. 283| (prevStage: | ^ 284| # previous stage0 stdenv: … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:285:12: 284| # previous stage0 stdenv: 285| assert isFromBootstrapFiles prevStage.binutils.bintools; | ^ 286| assert isFromBootstrapFiles prevStage."${localSystem.libc}"; … while calling 'isFromBootstrapFiles' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/linux/default.nix:105:5: 104| isFromBootstrapFiles = 105| pkg: pkg.passthru.isFromBootstrapFiles or false; | ^ 106| isBuiltByNixpkgsCompiler = … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:69:18: 68| cur = op pred (builtins.elemAt list n) succ; 69| succ = go cur (n + 1); | ^ 70| in cur; … while calling 'go' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:63:18: 62| len = builtins.length list; 63| go = pred: n: | ^ 64| if n == len … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:68:18: 67| # Note the cycle -- call-by-need ensures finite fold. 68| cur = op pred (builtins.elemAt list n) succ; | ^ 69| succ = go cur (n + 1); … while calling 'folder' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:89:33: 88| # debugging purposes. 89| folder = nextStage: stageFun: prevStage: let | ^ 90| args = stageFun prevStage; … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/stdenv/booter.nix:101:12: 100| then args' 101| else allPackages ((builtins.removeAttrs args' ["selfBuild"]) // { | ^ 102| adjacentPackages = if args.selfBuild or true then null else rec { … while calling 'allPackages' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/top-level/default.nix:120:17: 119| # sets. Only apply arguments which no stdenv would want to override. 120| allPackages = newArgs: import ./stage.nix ({ | ^ 121| inherit lib nixpkgsFun; … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/top-level/default.nix:120:26: 119| # sets. Only apply arguments which no stdenv would want to override. 120| allPackages = newArgs: import ./stage.nix ({ | ^ 121| inherit lib nixpkgsFun; … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/top-level/stage.nix:12:1: 11| 12| { ## Misc parameters kept the same for all stages | ^ 13| ## … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/pkgs/top-level/stage.nix:291:3: 290| # Return the complete set of packages. 291| lib.fix toFix | ^ 292| … while calling 'fix' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/fixed-points.nix:25:9: 24| */ 25| fix = f: let x = f x; in x; | ^ 26| … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/fixed-points.nix:25:20: 24| */ 25| fix = f: let x = f x; in x; | ^ 26| … while calling 'extends' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/fixed-points.nix:91:24: 90| */ 91| extends = f: rattrs: self: let super = rattrs self; in super // f self super; | ^ 92| … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/fixed-points.nix:91:42: 90| */ 91| extends = f: rattrs: self: let super = rattrs self; in super // f self super; | ^ 92| … while calling 'extends' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/fixed-points.nix:91:24: 90| */ 91| extends = f: rattrs: self: let super = rattrs self; in super // f self super; | ^ 92| … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/fixed-points.nix:91:42: 90| */ 91| extends = f: rattrs: self: let super = rattrs self; in super // f self super; | ^ 92| … while calling 'extends' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/fixed-points.nix:91:24: 90| */ 91| extends = f: rattrs: self: let super = rattrs self; in super // f self super; | ^ 92| … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/fixed-points.nix:91:67: 90| */ 91| extends = f: rattrs: self: let super = rattrs self; in super // f self super; | ^ 92| … while calling 'composeExtensions' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/fixed-points.nix:99:18: 98| composeExtensions = 99| f: g: final: prev: | ^ 100| let fApplied = f final prev; … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/fixed-points.nix:100:22: 99| f: g: final: prev: 100| let fApplied = f final prev; | ^ 101| prev' = prev // fApplied; … while calling anonymous lambda at /nix/store/d94zkffsad8qz8v1qxj2f76j58b6g09h-source/flake.nix:53:17: 52| # }) 53| (final: prev: prev.outputs.lib) | ^ 54| ]; … while evaluating the attribute 'outputs.lib' at /nix/store/y3hmkfmzwknj6k9ijw3msjx5akgdhyvk-source/builtinModules/builtinOverlay.nix:28:14: 27| { 28| inherit src inputs outputs flakelight system; | ^ 29| inputs' = mapAttrs (_: mapAttrs (_: v: v.${system} or { })) inputs; … while evaluating call site at «none»:0: (source not available) … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:504:44: 503| context = name: ''while evaluating the module argument `${name}' in "${key}":''; 504| extraArgs = builtins.mapAttrs (name: _: | ^ 505| builtins.addErrorContext (context name) … while evaluating the module argument `outputs' in "/nix/store/y3hmkfmzwknj6k9ijw3msjx5akgdhyvk-source/builtinModules/builtinOverlay.nix": … while evaluating call site at «none»:0: (source not available) … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/types.nix:563:29: 562| merge = loc: defs: 563| zipAttrsWith (name: defs: | ^ 564| let merged = mergeDefinitions (loc ++ [name]) elemType defs; … while evaluating the attribute 'optionalValue.value' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:815:5: 814| 815| optionalValue = | ^ 816| if isDefined then { value = mergedValue; } … while evaluating the attribute 'values' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:797:9: 796| in { 797| values = defs'''; | ^ 798| inherit (defs'') highestPrio; … while evaluating the attribute 'values' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:896:7: 895| in { 896| values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs; | ^ 897| inherit highestPrio; … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:783:17: 782| # Process mkMerge and mkIf properties. 783| defs' = concatMap (m: | ^ 784| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value)) … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:783:28: 782| # Process mkMerge and mkIf properties. 783| defs' = concatMap (m: | ^ 784| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value)) … while evaluating definitions from `/nix/store/y3hmkfmzwknj6k9ijw3msjx5akgdhyvk-source/builtinModules/core.nix': … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:784:137: 783| defs' = concatMap (m: 784| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value)) | ^ 785| ) defs; … while calling 'dischargeProperties' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:855:25: 854| */ 855| dischargeProperties = def: | ^ 856| if def._type or "" == "merge" then … while evaluating the attribute 'value' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/types.nix:569:58: 568| # Push down position info. 569| (map (def: mapAttrs (n: v: { inherit (def) file; value = v; }) def.value) defs); | ^ 570| emptyValue = { value = {}; }; … while evaluating call site at «none»:0: (source not available) … while calling 'g' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/attrsets.nix:599:19: 598| g = 599| name: value: | ^ 600| if isAttrs value && cond value … while evaluating call site at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/attrsets.nix:602:20: 601| then recurse (path ++ [name]) value 602| else f (path ++ [name]) value; | ^ 603| in mapAttrs g; … while calling anonymous lambda at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:242:72: 241| # For definitions that have an associated option 242| declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options; | ^ 243| … while evaluating the attribute 'value' at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:768:9: 767| in warnDeprecation opt // 768| { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value; | ^ 769| inherit (res.defsFinal') highestPrio; error: infinite recursion encountered at /nix/store/x74ckj67m4v6nl52g8njpgyxibaj45y7-source/lib/modules.nix:768:9: 767| in warnDeprecation opt // 768| { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value; | ^ 769| inherit (res.defsFinal') highestPrio; ```
noverby commented 8 months ago

It seems to work fine, when just defining lib/default.nix, but if I define any other file e.g. lib/helper.nix, then it will result in an infinite recursion no matter the content of lib/helper.nix.

accelbread commented 8 months ago

Ah yeah; outputs is from the module system which needs withOverlays to compute which attrs are output, so thats a loop.

Using outputs.lib.mkCustomDerivation without withOverlays should be fine though.

noverby commented 8 months ago

Is nix/lib suppose to support functions like this?

# nix/lib/default.nix 
{src, ...}
: rec {
  rustToolchain = {pkgs}:
    pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile (src + /rust-toolchain.toml);

  rustToolchainForAarch64 = {pkgs}:
    pkgs.aarch64.pkgsBuildHost.rust-bin.fromRustupToolchainFile (src + /rust-toolchain.toml);

  craneLib = {
    pkgs,
    crane,
  }:
    (crane.mkLib pkgs).overrideToolchain rustToolchain;

  craneLibAarch64 = {
    pkgs,
    crane,
  }:
    (crane.mkLib pkgs.aarch64).overrideToolchain rustToolchainForAarch64;
}
accelbread commented 8 months ago

It can support any structure for lib; it only requires that lib is an attrset (or a function when autoloading). If using nix/lib/default.nix, whatever is in that file will be exported as the lib attribute if it is an attrset, and it will be passed module args if it is a function.

So yes, that should work.

If crane is a flake input, can also use { src, inputs, ... } for the params and use inputs.crane.

accelbread commented 8 months ago

Though if its only intended for use inside the flake (not exporting to other flakes), instead of using lib, I'd try:

# nix/withOverlays.nix
final: prev:
rec {
  rustToolchain =
    final.pkgsBuildHost.rust-bin.fromRustupToolchainFile (final.src + /rust-toolchain.toml);

  rustToolchainForAarch64 =
    final.aarch64.pkgsBuildHost.rust-bin.fromRustupToolchainFile (final.src + /rust-toolchain.toml);

  craneLib =
    (final.inputs.crane.mkLib final).overrideToolchain rustToolchain;

  craneLibAarch64 = (final.crane.mkLib final.aarch64).overrideToolchain rustToolchainForAarch64;
}

That way you get direct access in all package defs and pkgs args.

noverby commented 8 months ago

@accelbread If I move the overlay to a withOverlays subdir like nix/withOverlays/rust.nix, then I get the error:

A definition for option `withOverlays' is not of type `(list of nixpkgs overlay) or nixpkgs overlay convertible to it'. Definition values:
accelbread commented 8 months ago

withOverlays expects an overlay or a list of overlays. nix/withOverlays/rust.nix tries to set it to { rust = <contents of nix/withOverlays/rust.nix>;} which won't work. If you want to split your overlay into multiple overlays, each in their own file (for example nix/withOverlays/a.nix and nix/withOverlays/b.nix), then you can add the following file:

# nix/withOverlays/default.nix
[
  (import ./a.nix)
  (import ./b.nix)
]

That way withOverlays is set to that list, and you can organize the multiple overlay files as you wish.

Or if you have just the one overlay and just want it to be in a folder, then just naming it nix/withOverlays/default.nix also works.

noverby commented 8 months ago

Thanks @accelbread!

Using withOverlays seems like a proper solution, so I will close this issue.