edolstra / flake-compat Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Provide a way to create a shell.nix with the same behavior as nix develop
The full trace is included at the bottom. I am trying to use flake-compat as a shim to generate a configuration.nix
for nixos-install
since the installer seems to be broken in many weird ways.
I tried to debug the installer, but the issue is fundamentally with the output of the flake, and it doesn't seem to set up a new system correctly. For example, writing the ISO's fstab
to /mnt/etc
rather than the one generated by my flake's activation script.
I have some glue code (bash) around these lines:
cat <<- EOF > "$root_dir/etc/nixos/configuration.nix"
(import (builtins.fetchTarball {
url = "$FLAKE_COMPAT_TARBALL_URL";
sha256 = "$FLAKE_COMPAT_TARBALL_HASH";
}) {src = "$flake_path";}).defaultNix.nixosConfigurations.$host_name.config
EOF
Obviously $root_dir
, $flake_path
, and $host_name
are handled elsewhere in the shell script. The flake is pre-built and sent over to the store at /mnt/nix/store
before running nixos-install
(on $root_dir
which is /mnt
).
I have attempted to follow the trace myself to determine if I can do something about it -- alas I am not experienced enough. I feel that it is worth note that I perform an explicit import of nixpkgs (that is a link to my flake.nix
).
I would like to know if I am using the wrong attribute path (in configuration.nix
) or something, and if the issue is that nixpkgs.pkgs
is not being evaluated properly. If it is being evaluated correctly by flake-compat
, I would like to know what wants nixpkgs.pkgs
, I do not see any occurrence in my code.
Thanks.
When running nixos-install
, I see the following:
error: The option `nixpkgs.pkgs' is used but not defined.
… while evaluating the attribute 'mergedValue'
at /mnt/nix/store/x20avpqcrk6my01n6h1blfslb6l4imw2-source/lib/modules.nix:747:5:
746| £ Type-check the remaining definitions, and merge them. Or throw if no definitions.
747| mergedValue =
| ^
748| if isDefined then
… while evaluating the option `nixpkgs.pkgs':
… while evaluating the attribute 'value'
at /mnt/nix/store/x20avpqcrk6my01n6h1blfslb6l4imw2-source/lib/modules.nix:712:9:
711| in warnDeprecation opt //
712| { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
| ^
713| inherit (res.defsFinal') highestPrio;
… while evaluating anonymous lambda
at /mnt/nix/store/x20avpqcrk6my01n6h1blfslb6l4imw2-source/lib/modules.nix:265:72:
264| £ For definitions that have an associated option
265| declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
| ^
266|
… from call site
at /mnt/nix/store/x20avpqcrk6my01n6h1blfslb6l4imw2-source/lib/attrsets.nix:401:20:
400| then recurse (path ++ [name]) value
401| else f (path ++ [name]) value;
| ^
402| in mapAttrs g;
… while evaluating 'g'
at /mnt/nix/store/x20avpqcrk6my01n6h1blfslb6l4imw2-source/lib/attrsets.nix:398:19:
397| g =
398| name: value:
| ^
399| if isAttrs value && cond value
… from call site
… while evaluating the attribute 'value'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:581:44:
580| defnsByName' = byName "config" (module: value:
581| [{ inherit (module) file; inherit value; }]
| ^
582| ) configs;
… while evaluating 'dischargeProperties'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:832:25:
831| */
832| dischargeProperties = def:
| ^
833| if def._type or "" == "merge" then
… from call site
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:761:137:
760| defs' = concatMap (m:
761| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
| ^
762| ) defs;
… while evaluating definitions from `/mnt/etc/nixos/configuration.nix':
… while evaluating anonymous lambda
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:760:28:
759| £ Process mkMerge and mkIf properties.
760| defs' = concatMap (m:
| ^
761| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
… from call site
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:760:17:
759| £ Process mkMerge and mkIf properties.
760| defs' = concatMap (m:
| ^
761| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
… while evaluating the attribute 'values'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:873:7:
872| in {
873| values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
| ^
874| inherit highestPrio;
… while evaluating the attribute 'values'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:774:9:
773| in {
774| values = defs''';
| ^
775| inherit (defs'') highestPrio;
… while evaluating the attribute 'isDefined'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:790:5:
789|
790| isDefined = defsFinal != [];
| ^
791|
… while evaluating the attribute 'pkgs.isDefined'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:750:22:
749| files = map (def: def.file) res.defsFinal;
750| inherit (res) isDefined;
| ^
751| £ This allows options to be correctly displayed using `${options.path.to.it}`
… while evaluating the attribute 'value'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/types.nix:461:58:
460| £ Push down position info.
461| (map (def: mapAttrs (n: v: { inherit (def) file; value = v; }) def.value) defs);
| ^
462| emptyValue = { value = {}; };
… while evaluating 'dischargeProperties'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:832:25:
831| */
832| dischargeProperties = def:
| ^
833| if def._type or "" == "merge" then
… from call site
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:761:137:
760| defs' = concatMap (m:
761| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
| ^
762| ) defs;
… while evaluating definitions from `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/misc/nixpkgs.nix':
… while evaluating anonymous lambda
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:760:28:
759| £ Process mkMerge and mkIf properties.
760| defs' = concatMap (m:
| ^
761| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
… from call site
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:760:17:
759| £ Process mkMerge and mkIf properties.
760| defs' = concatMap (m:
| ^
761| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
… while evaluating the attribute 'values'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:873:7:
872| in {
873| values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
| ^
874| inherit highestPrio;
… while evaluating the attribute 'values'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:774:9:
773| in {
774| values = defs''';
| ^
775| inherit (defs'') highestPrio;
… while evaluating the attribute 'optionalValue.value'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:792:5:
791|
792| optionalValue =
| ^
793| if isDefined then { value = mergedValue; }
… while evaluating anonymous lambda
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/types.nix:455:29:
454| merge = loc: defs:
455| zipAttrsWith (name: defs:
| ^
456| let merged = mergeDefinitions (loc ++ [name]) elemType defs;
… from call site
… while evaluating the module argument `pkgs' in "/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/services/hardware/bluetooth.nix":
… while evaluating anonymous lambda
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:494:44:
493| context = name: ''while evaluating the module argument `${name}' in "${key}":'';
494| extraArgs = builtins.mapAttrs (name: _:
| ^
495| builtins.addErrorContext (context name)
… from call site
… while evaluating the attribute 'type.getSubModules'
at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/services/hardware/bluetooth.nix:71:9:
70| settings = mkOption {
71| type = cfgFmt.type;
| ^
72| default = { };
… while evaluating 'fixupOptionType'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:893:26:
892| £ TODO: Merge this into mergeOptionDecls
893| fixupOptionType = loc: opt:
| ^
894| if opt.type.getSubModules or null == null
… from call site
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:609:23:
608| if length optionDecls == length decls then
609| let opt = fixupOptionType loc (mergeOptionDecls loc decls);
| ^
610| in {
… while evaluating 'warnIf'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/trivial.nix:350:18:
349| */
350| warnIf = cond: msg: if cond then warn msg else x: x;
| ^
351|
… from call site
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:742:9:
741| warnDeprecation =
742| warnIf (opt.type.deprecationMessage != null)
| ^
743| "The type `types.${opt.type.name}' of option `${showOption loc}' defined in ${showFiles opt.declarations} is deprecated. ${opt.type.deprecationMessage}";
… while evaluating 'evalOptionValue'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:717:31:
716| config value. */
717| evalOptionValue = loc: opt: defs:
| ^
718| let
… from call site
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:611:32:
610| in {
611| matchedOptions = evalOptionValue loc opt defns';
| ^
612| unmatchedDefns = [];
… while evaluating the attribute 'matchedOptions'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:611:15:
610| in {
611| matchedOptions = evalOptionValue loc opt defns';
| ^
612| unmatchedDefns = [];
… while evaluating anonymous lambda
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:642:37:
641|
642| matchedOptions = mapAttrs (n: v: v.matchedOptions) resultsByName;
| ^
643|
… from call site
… while evaluating 'attrByPath'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:24:35:
23| */
24| attrByPath = attrPath: default: e:
| ^
25| let attr = head attrPath;
… from call site
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:29:12:
28| else if e ? ${attr}
29| then attrByPath (tail attrPath) default e.${attr}
| ^
30| else default;
… while evaluating 'attrByPath'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:24:35:
23| */
24| attrByPath = attrPath: default: e:
| ^
25| let attr = head attrPath;
… from call site
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:29:12:
28| else if e ? ${attr}
29| then attrByPath (tail attrPath) default e.${attr}
| ^
30| else default;
… while evaluating 'attrByPath'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:24:35:
23| */
24| attrByPath = attrPath: default: e:
| ^
25| let attr = head attrPath;
… from call site
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:29:12:
28| else if e ? ${attr}
29| then attrByPath (tail attrPath) default e.${attr}
| ^
30| else default;
… while evaluating 'attrByPath'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:24:35:
23| */
24| attrByPath = attrPath: default: e:
| ^
25| let attr = head attrPath;
… from call site
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:1160:26:
1159| (abort "Renaming error: option `${showOption to}' does not exist.");
1160| toType = let opt = attrByPath to {} options; in opt.type or (types.submodule {});
| ^
1161| in
… while evaluating 'optionalAttrs'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:453:25:
452| */
453| optionalAttrs = cond: as: if cond then as else {};
| ^
454|
… from call site
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:1167:12:
1166| apply = x: use (toOf config);
1167| } // optionalAttrs (toType != null) {
| ^
1168| type = toType;
… while evaluating 'atDepth'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:60:17:
59| len = length attrPath;
60| atDepth = n:
| ^
61| if n == len
… from call site
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:63:39:
62| then value
63| else { ${elemAt attrPath n} = atDepth (n + 1); };
| ^
64| in atDepth 0;
… while evaluating the attribute 'options'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:573:38:
572| declsByName = byName "options" (module: option:
573| [{ inherit (module) _file; options = option; }]
| ^
574| ) options;
… while evaluating 'isType'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/types.nix:71:18:
70| rec {
71| isType = type: x: (x._type or "") == type;
| ^
72|
… from call site
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:606:36:
605| defns' = defnsByName'.${name} or [];
606| optionDecls = filter (m: isOption m.options) decls;
| ^
607| in
… while evaluating anonymous lambda
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:606:33:
605| defns' = defnsByName'.${name} or [];
606| optionDecls = filter (m: isOption m.options) decls;
| ^
607| in
… from call site
… while evaluating anonymous lambda
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:600:39:
599|
600| resultsByName = mapAttrs (name: decls:
| ^
601| £ We're descending into attribute ‘name’.
… from call site
… while evaluating anonymous lambda
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:647:22:
646| £ Propagate all unmatched definitions from nested option sets
647| mapAttrs (n: v: v.unmatchedDefns) resultsByName
| ^
648| £ Plus the definitions for the current prefix that don't have a matching option
… from call site
… while evaluating anonymous lambda
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:661:46:
660| else
661| concatLists (mapAttrsToList (name: defs:
| ^
662| map (def: def // {
… from call site
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:356:16:
355| mapAttrsToList = f: attrs:
356| map (name: f name attrs.${name}) (attrNames attrs);
| ^
357|
… while evaluating anonymous lambda
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:356:10:
355| mapAttrsToList = f: attrs:
356| map (name: f name attrs.${name}) (attrNames attrs);
| ^
357|
… from call site
… while evaluating the attribute 'unmatchedDefns'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:654:7:
653| £ Transforms unmatchedDefnsByName into a list of definitions
654| unmatchedDefns =
| ^
655| if configs == []
… while evaluating anonymous lambda
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:647:22:
646| £ Propagate all unmatched definitions from nested option sets
647| mapAttrs (n: v: v.unmatchedDefns) resultsByName
| ^
648| £ Plus the definitions for the current prefix that don't have a matching option
… from call site
… while evaluating anonymous lambda
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:661:46:
660| else
661| concatLists (mapAttrsToList (name: defs:
| ^
662| map (def: def // {
… from call site
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:356:16:
355| mapAttrsToList = f: attrs:
356| map (name: f name attrs.${name}) (attrNames attrs);
| ^
357|
… while evaluating anonymous lambda
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:356:10:
355| mapAttrsToList = f: attrs:
356| map (name: f name attrs.${name}) (attrNames attrs);
| ^
357|
… from call site
… while evaluating the attribute 'unmatchedDefns'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:654:7:
653| £ Transforms unmatchedDefnsByName into a list of definitions
654| unmatchedDefns =
| ^
655| if configs == []
… while evaluating anonymous lambda
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:647:22:
646| £ Propagate all unmatched definitions from nested option sets
647| mapAttrs (n: v: v.unmatchedDefns) resultsByName
| ^
648| £ Plus the definitions for the current prefix that don't have a matching option
… from call site
… while evaluating anonymous lambda
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:661:46:
660| else
661| concatLists (mapAttrsToList (name: defs:
| ^
662| map (def: def // {
… from call site
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:356:16:
355| mapAttrsToList = f: attrs:
356| map (name: f name attrs.${name}) (attrNames attrs);
| ^
357|
… while evaluating anonymous lambda
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:356:10:
355| mapAttrsToList = f: attrs:
356| map (name: f name attrs.${name}) (attrNames attrs);
| ^
357|
… from call site
… while evaluating the attribute 'unmatchedDefns'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:654:7:
653| £ Transforms unmatchedDefnsByName into a list of definitions
654| unmatchedDefns =
| ^
655| if configs == []
… while evaluating the attribute 'config.system.build.toplevel'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:363:9:
362| options = checked options;
363| config = checked (removeAttrs config [ "_module" ]);
| ^
364| _module = checked (config._module);
I added outputs.buildreq = linkFarmFromDrvs...
to my flake.
This broke nix-shell
which was using the latest flakes-compat
to access shellNix
.
As soon as I moved the derivation to bld.req
(chose weird names to avoid any potential keyword conflicts), then the issue went away.
Currently flake-compat fails in pure evaluation mode, due to the rootSrc
cleaning. I suspect we could just add another conditional to
Line 104 in 12c64ca
tryFetchGet
when not builtins ? currentSystem
I am not entirely sure if this is an issue with hydra
's use of flake-compat
or a flake-compat
issue, but it seems to me like the following way of importing a nix package that uses flake-compat
should remain valid. At least I expect I am not the only one to import nix packages this way so I expect this to break other peoples builds as well.
I have a dependency on NixOS/hydra
(using niv
) which under the hood uses flake-compat
:
https://github.com/NixOS/hydra/blob/c1a5ff3959f8d3d0f13295d29a02084e14dff735/default.nix#L4-L6
In order to simplify the reproduction of the issue, we can get niv
out of the way and simply use fetchTarball
.
This used to work:
nix-build -E 'import (fetchTarball https://github.com/NixOS/hydra/archive/master.tar.gz)'
But it now breaks:
$ nix-build -E 'import (fetchTarball https://github.com/NixOS/hydra/archive/master.tar.gz)'
this derivation will be built:
/nix/store/z0dgrm7wykms253zcnzjq4skc97b08aa-hydra-0.1.19700101.DIRTY.drv
building '/nix/store/z0dgrm7wykms253zcnzjq4skc97b08aa-hydra-0.1.19700101.DIRTY.drv'...
unpacking sources
unpacking source archive /nix/store/xwvjm5dxj60h6js47la34jv6xshr4rh1-source
do not know how to unpack source archive /nix/store/xwvjm5dxj60h6js47la34jv6xshr4rh1-source
error: builder for '/nix/store/z0dgrm7wykms253zcnzjq4skc97b08aa-hydra-0.1.19700101.DIRTY.drv' failed with exit code 1;
last 3 log lines:
> unpacking sources
> unpacking source archive /nix/store/xwvjm5dxj60h6js47la34jv6xshr4rh1-source
> do not know how to unpack source archive /nix/store/xwvjm5dxj60h6js47la34jv6xshr4rh1-source
For full logs, run 'nix log /nix/store/z0dgrm7wykms253zcnzjq4skc97b08aa-hydra-0.1.19700101.DIRTY.drv'.
I believe the commit that introduces the issue is bc5e257
I have forked NixOS/hydra
and modified the fetchTarball
of flake-compat
to a specific commit to showcase when it used to work and what it looks like now/on that first broken commit:
Works:
nix-build -E 'import (fetchTarball https://github.com/basile-henry/hydra/archive/last-working-flake-compat.tar.gz)'
Broken:
nix-build -E 'import (fetchTarball https://github.com/basile-henry/hydra/archive/first-broken-flake-compat.tar.gz)'
Using Nix 2.8.1, a flake from git has the attributes rev
, shortRev
, revCount
, lastModified
and lastModifiedDate
all under flake.sourceInfo
.
However, with flake-compat, flake.sourceInfo
has rev
, shortRev
, lastModified
and lastModifiedDate
, but not revCount
directly under flake.sourceInfo
.
revCount
is available under flake.sourceInfo.outPath
in this scenario.
My understanding was that flake-compat
could be used to enable the use of flakes with stable Nix. However, when I run nix-shell
for my devShell based project, I receive:
error: experimental Nix feature 'flakes' is disabled; add '--extra-experimental-features flakes' to enable it
Am I misunderstanding the purpose of flake-compat
?
Running nix build
successfully builds the artifacts and links them in the newly created results/bin
. When I ran nix-build --debug
, I got the following output:
evaluating file '/nix/store/jb9wd23mwynz6k168gg52hysyh5xag1s-source/default.nix'
warning: Git tree '/home/martin/code/iog/stablecoin-plutus' is dirty
acquiring write lock on '/nix/var/nix/temproots/303423'
evaluating file '/nix/store/4wqylrpk95rxrkmppn0ndgp0g8bq5j01-source/flake.nix'
using substituted/cached input 'github:numtide/flake-utils/5aed5285a952e0b949eb3ba02c12fa4fcfef535f' in '/nix/store/sk4ga2wy0b02k7pnzakwq4r3jdknda4g-source'
evaluating file '/nix/store/sk4ga2wy0b02k7pnzakwq4r3jdknda4g-source/flake.nix'
evaluating file '/nix/store/sk4ga2wy0b02k7pnzakwq4r3jdknda4g-source/default.nix'
evaluating attribute 'checks'
evaluating attribute 'devShells'
evaluating attribute 'inputs'
evaluating attribute 'lastModified'
evaluating attribute 'lastModifiedDate'
evaluating attribute 'legacyPackages'
evaluating attribute 'narHash'
evaluating attribute 'outPath'
evaluating attribute 'outputs'
evaluating attribute 'packages'
evaluating attribute 'revCount'
evaluating attribute 'sourceInfo'
evaluating attribute 'submodules'
querying info about missing paths...
starting pool of 24 threads
querying info about missing paths...
starting pool of 24 threads
entered goal loop
which resulted in an exit code 0 but does not build / link any artifacts (I checked this multiple times). In the end the problem was that the README says to put the following into my default.nix
(import
(
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{ src = ./.; }
).defaultNix
which references the rev of the flake-compat
object in the lock file. However, because of previous dependencies, the flake-compat
object in the lock file refers to a fork of flake-compat
from IOHK
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1647532380,
"narHash": "sha256-wswAxyO8AJTH7d5oU8VK82yBCpqwA+p6kLgpb1f1PAY=",
"owner": "input-output-hk",
"repo": "flake-compat",
"rev": "7da118186435255a30b5ffeabba9629c344c0bec",
"type": "github"
},
whereas flake-compat_11
(and several other variants) did refer to a commit by @edolstra's repo. When I replaced flake-compat
with (for example) flake-compat_11
, everything worked as intended.
This actually seems like a nix bug but I figured I would put it here first. The reason being that the result
dir was not created, there definitely was an error because I was trying to import some probably non-existent nix file, yet the process finishes with exit code 0.
I put
(import
(
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{ src = ./.; }
).defaultNix
in my default.nix and also
inputs.flake-compat = {
url = github:edolstra/flake-compat;
flake = false;
};
in my flake.nix. But when I try putting this in my configuration.nix
neovim-luca = (pkgs.callPackage (pkgs.fetchFromGitHub {
owner = "quoteme";
repo = "neovim-luca";
rev = "d85f02952e35d0fd2afa783adb3e93d08fdd03d9";
sha256 = "sha256-sPX1RaR3H4Hs2YEetdjI7b4UxBC4UxIkvOl1LIYSZuM=";
}) {});
and doing sudo nixos-rebuild switch
I get the following error:
building Nix...
building the system configuration...
error: attempt to call something which is not a function but a set
at /nix/store/34br6qh4x4hjj15jjnbiivwgdhz4ci5a-nixos/nixos/lib/customisation.nix:69:16:
68| let
69| result = f origArgs;
| ^
70|
(use '--show-trace' to show detailed location information)
nix-build
works fine. But callPackage does not work. How can I fix this?
I am not sure if this is a bug or I am using flake-compat
wrong. When the flake in question has input nixpkgs.url = "nixpkgs"
, and the lockfile has "path": "/nix/store...-source"
, flake-compat fails with
error: getting attributes of path '/nix/store/...-source': No such file or directory
Nix supports sourcehut:
inputs, but flake-compat doesn't.
Hi, I have the following error:
error: undefined variable 'pkgs' at /nix/store/qcjhyb3vi2lsdynlb6jhr2yc2z2sb2aa-source/flake.nix:65:35
During the execution of the following shell.nix code:
nix dev-shell --no-update-lock-file . -c hyperchat
(import(builtins.fetchgit "https://github.com/edolstra/flake-compat"){src=./. ;}).
Any suggestion?
Thanks in advance,
GP
Whenever I update an input in a flake.nix
without actually updating the flake.lock
the compat expression uses the input as specified in the lockfile. I think for consistency reasons it should fail during eval. Otherwise this might lead to an inconsistent state as users might forget to update the lockfile while the build succeeds.
Since 0f9255e, default.nix
has used builtins.storePath
, which is not available in pure evaluation mode (e.g. when used in a Flake).
This makes it challenging to use flake-compat
to incrementally migrate to Nix flakes.
… while evaluating the file '/nix/store/g10gzvphg32jxpga3rkqymyzhj1fvx33-source/default.nix':
… while evaluating the attribute 'defaultNix'
at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:229:5:
228| rec {
229| defaultNix =
| ^
230| (builtins.removeAttrs result ["__functor"])
… in the left operand of the update (//) operator
at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:231:7:
230| (builtins.removeAttrs result ["__functor"])
231| // (if result ? defaultPackage.${system} then { default = result.defaultPackage.${system}; } else {})
| ^
232| // (if result ? packages.${system}.default then { default = result.packages.${system}.default; } else {});
… while calling the 'removeAttrs' builtin
at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:230:8:
229| defaultNix =
230| (builtins.removeAttrs result ["__functor"])
| ^
231| // (if result ? defaultPackage.${system} then { default = result.defaultPackage.${system}; } else {})
… from call site
at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:224:10:
223| else if lockFile.version >= 5 && lockFile.version <= 7
224| then allNodes.${lockFile.root}
| ^
225| else throw "lock file '${lockFilePath}' has unsupported version ${toString lockFile.version}";
… while calling anonymous lambda
at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:156:13:
155| builtins.mapAttrs
156| (key: node:
| ^
157| let
… in the condition of the assert statement
at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:211:13:
210| if node.flake or true then
211| assert builtins.isFunction flake.outputs;
| ^
212| result
… while calling the 'isFunction' builtin
at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:211:20:
210| if node.flake or true then
211| assert builtins.isFunction flake.outputs;
| ^
212| result
… while calling the 'import' builtin
at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:167:19:
166|
167| flake = import (outPath + "/flake.nix");
| ^
168|
… while realising the context of a path
… while calling the 'storePath' builtin
at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:115:15:
114| # If it's already a store path, don't copy it again.
115| builtins.storePath src
| ^
116| else
error: 'builtins.storePath' is not allowed in pure evaluation mode
While working with a flakes
enabled nix
binary I have several inputs which are private github
repositories. Some of these private github
repositories are already flakes
, though not all. Following the advice in NixOS/nix#3991 (comment) I have my personal access token included in ~/.config/nix/nix.conf
and everything works well.
Due to complex compatibility/migration reasons I'm in a position where flake-compat
is required. Consider the following example flake.nix
:
{
inputs = {
private-repo = {
url = "github:a/b/main";
flake = false;
};
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = { self, private-repo, flake-compat }: { packages.x86_64-linux.foo = ...references some nix expressions from private-repo...; };
}
My default.nix
is a pretty standard implementation of the flake-compat
example. When I try to install foo
, the package provided by flake.nix
, via nix-env
I see a permission issue:
$ nix-env -if . outputs.packages.x86_64-linux.foo
error: unable to download 'https://api.github.com/repos/...': HTTP error 404
response body:
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest/reference/repos#download-a-repository-archive"
}
(use '--show-trace' to show detailed location information)
Given I have an appropriate ~/.config/nix/nix.conf
in place I was expecting this to work.
Any advice or help is greatly appreciated 🙇♂️
Note that if I run nix --extra-experimental-features flakes --extra-experimental-features nix-command flake show
before running nix-env
this pulls enough into my nix store that nix-env
subsequently works. This is not a viable workaround for me, though 😞
NixOS/nix#5532 has changed things from defaultPackage
to packages.default
, and devShell
to devShells.default
. flake-compat should presumably search those paths first. And maybe print a deprecation warning if people are still using defaultPackage
/devShell
?
What do you think if flake-compat was changed to provide the same output as builtins.getFlake
? That way, most of the logic can be substituted if the builtin exists.
Then the other issue is to select the right shell and packages from the current system, which I think is a separate concern. For this I would propose to extend the flake schema to include currentSystem = { packages = []; devShell = <drv>; <...> }
.
With both of these combined, flake-compat
is the same as builtins.getFlake
, and the flake schema would look something like this:
{
description = "";
inputs = {};
outputs = inputs: {};
currentSystem = {};
}
I have a flake that downloads an EXE and unpacks it to get to an Electron app that's inside it for unofficially supported Linux support. I've previously done something similar with MacOS DMG files.
I think there will always be pointers to various files on the internet that we don't have controlled fetchers for. Flakes seems to be able to handle these pretty well with an input type of file
. Is there any reason this can't be supported with flake-compat
?
I think a solution could give this project what getFlakes
returns for these file
inputs:
{
narHash = "sha256-…=";
outPath = "/nix/store/…-source";
}
Using Home-Manager it's possible to import flakes like this:
packageName = (import flake-compat {
src = builtins.fetchTarball "https://github.com/repo/name/archive/master.tar.gz";
}).defaultNix;
How would you go about adding patches to this?
(I'm new to NixOS and I'm having a had time finding this answer)
Flake inputs since recently support boolean arguments, including submodules = true
for git inputs, which are supposed to trigger recursive checkout.
It seems, however, that flake-compat
ignores those arguments:
nix build -L
succeeds to check out microsoft/onnxruntime` recursively (paths in https://github.com/microsoft/onnxruntime/tree/master/cmake/external are available in sources)
./build-compat.nix
fails with
The source directory
/build/source/cmake/external/googletest
does not contain a CMakeLists.txt file.
The source directory
...
The source directory
/build/source/cmake/external/flatbuffers
does not contain a CMakeLists.txt file.
Related:
Current implementation hard-codes the use of devShell.${system}
while other shells can be provided in flake.nix
at devShell.${system}.<whatever>
, e.g. devShell.${system}.foo
.
It would be useful to provide means of accessing these other shells too.
The current README says how to use flake-compat but not what it is. It would also be nice to write a description in the project settings.
Why not add a flake.nix
so that folks who are managing the import of flake-compat
via flakes itself don't have to use flake = false;
?
{ outputs = { nixpkgs, ... }:
let system = "x86_64-linux"; in
{ devShell.${system} =
nixpkgs.legacyPackages.${system}.mkShell
{ shellHook = "alias"; };
};
}
running this shell with nix-shell
and flake-compat will show all the aliases defined in your bashrc, whereas running it in nix develop
will not.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.