Hello dear nix
community, I’m trying to package dotnet
project into flake and I’m hitting the wall with nix
code giving me error in the flake, but not in repl.
Here is my code:
loadfromlock.nix
{
# tried to use pkgs and resolve dependices in this file but it had the same error
# pkgs ? import <nixpkgs> {},
stdenvNoCC, lib, fetchurl, unzip,
filepath
}:
let
lock = import ./readlock.nix {inherit lib; filepath = filepath; };
fetchNuget = import ./fetchnuget.nix { inherit stdenvNoCC lib fetchurl unzip; };
in
map(package: fetchNuget { pname = package.name; version = package.version; hash = package.contentHash; }) lock
in the flake I have
{
description = "My dotnet flake";
outputs = inputs@{
self,
nixpkgs,
... }:
let
...
nugets = import ./loadfromlock.nix { inherit (nixpkgs) stdenvNoCC lib fetchurl unzip; filepath = filepath;};
in {
...
}
which results in
error: attribute 'stdenvNoCC' missing
at /nix/store/yy9yjds5cwzc8hglsxrclrpa33jgs4xg-source/flake.nix:54:43:
53| filepath = ./packages.nixlock.json;
54| nugets = import ./loadfromlock.nix { inherit (nixpkgs) stdenvNoCC lib fetchurl unzip; filepath = filepath;};
| ^
55| in {
… while evaluating anonymous lambda
at /nix/store/yy9yjds5cwzc8hglsxrclrpa33jgs4xg-source/fetchnuget.nix:3:1:
2| {stdenvNoCC, lib, fetchurl, unzip}:
3| attrs@{
| ^
4| pname,
… from call site
at /nix/store/yy9yjds5cwzc8hglsxrclrpa33jgs4xg-source/loadfromlock.nix:10:16:
9| in
10| map(package: fetchNuget { pname = package.name; version = package.version; hash = package.contentHash; }) lock
| ^
… while evaluating anonymous lambda
at /nix/store/yy9yjds5cwzc8hglsxrclrpa33jgs4xg-source/loadfromlock.nix:10:7:
9| in
10| map(package: fetchNuget { pname = package.name; version = package.version; hash = package.contentHash; }) lock
| ^
… from call site
… while evaluating 'isDerivation'
at /nix/store/kc7nh9sdr4z8c7xc9j9891v212k2zj8k-source/lib/attrsets.nix:427:18:
426| */
427| isDerivation = x: x.type or null == "derivation";
| ^
428|
… from call site
at /nix/store/kc7nh9sdr4z8c7xc9j9891v212k2zj8k-source/pkgs/stdenv/generic/make-derivation.nix:193:8:
192| checkDependencyList' = positions: name: deps: lib.flip lib.imap1 deps (index: dep:
193| if lib.isDerivation dep || isNull dep || builtins.typeOf dep == "string" || builtins.typeOf dep == "path" then dep
| ^
194| else if lib.isList dep then checkDependencyList' ([index] ++ positions) name dep
… while evaluating anonymous lambda
at /nix/store/kc7nh9sdr4z8c7xc9j9891v212k2zj8k-source/pkgs/stdenv/generic/make-derivation.nix:192:81:
191| checkDependencyList = checkDependencyList' [];
192| checkDependencyList' = positions: name: deps: lib.flip lib.imap1 deps (index: dep:
| ^
193| if lib.isDerivation dep || isNull dep || builtins.typeOf dep == "string" || builtins.typeOf dep == "path" then dep
… from call site
at /nix/store/kc7nh9sdr4z8c7xc9j9891v212k2zj8k-source/lib/lists.nix:117:32:
116| */
117| imap1 = f: list: genList (n: f (n + 1) (elemAt list n)) (length list);
| ^
118|
… while evaluating anonymous lambda
at /nix/store/kc7nh9sdr4z8c7xc9j9891v212k2zj8k-source/lib/lists.nix:117:29:
116| */
117| imap1 = f: list: genList (n: f (n + 1) (elemAt list n)) (length list);
| ^
118|
… from call site
… while evaluating the attribute 'buildInputs' of the derivation 'altair-20220815-dirty'
at /nix/store/kc7nh9sdr4z8c7xc9j9891v212k2zj8k-source/pkgs/stdenv/generic/make-derivation.nix:270:7:
269| // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
270| name =
| ^
271| let
but in if run the same loadfromlock.nix
in repl
I would get desired result as such
Welcome to Nix 2.10.3. Type :? for help.
nix-repl> nixpkgs = import <nixpkgs> {}
nix-repl> filepath = ./packages.nixlock.json
nix-repl> nugets = import ./loadfromlock.nix { inherit (nixpkgs) stdenvNoCC lib fetchurl unzip; file
path = filepath;}
nix-repl> nugets
[ «derivation /nix/store/h7p37plmcg9hczk2h5jc0s7m0lg92kmy-nuget-GitVersion.MsBuild-5.7.0.nupkg.drv» «derivation /nix/store/4xswdi1famd03zrgj7wfa0dqcg15zyh5-nuget-StyleCop.Analyzers-1.1.118.nupkg.drv» ]
What am I missing here?