Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding and using the nixos-hardware flake #44

Closed
ellakk opened this issue Dec 28, 2020 · 2 comments · Fixed by #45
Closed

Adding and using the nixos-hardware flake #44

ellakk opened this issue Dec 28, 2020 · 2 comments · Fixed by #45

Comments

@ellakk
Copy link

ellakk commented Dec 28, 2020

Hi!
I'm having problems using the nixos-hardware flake. I'm pretty pretty new to flakes and have not been using NixOS for very long so maybe I'm missing something obvious. Been trying to figure out what's causing the infinite recursion but I'm completely stuck, any pointers in the right direction is welcomed.

I've done the following:
Added the nixos-hardware flake to inputs:

  inputs =
    {
      master.url = "nixpkgs/master";
      nixos.url = "nixpkgs/release-20.09";
      home.url = "github:nix-community/home-manager/release-20.09";
      flake-utils.url = "github:numtide/flake-utils";

      # Extras
      emacs-overlay.url  = "github:nix-community/emacs-overlay";
      nixos-hardware.url = "github:NixOS/nixos-hardware/master";
      nur.url = "github:nix-community/NUR";
    };

  outputs = inputs@{ self, home, nixos, master, flake-utils, emacs-overlay, nixos-hardware, nur }:
...

Import my laptops configuration from the nixos-hardware flake in my <hostname.nix> file:

{ config, lib, pkgs, nixos-hardware, modulesPath, ... }:

{
  imports =
    [ (modulesPath + "/installer/scan/not-detected.nix")
      nixos-hardware.nixosModules.lenovo-thinkpad-t470s
    ];
}

I'm then hit with infinite recursion error when trying to build, nix flake check outputs the following:

error: --- EvalError ----------------------------------------------------------------------------- nix
at: (262:28) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/modules.nix

   261|         value = builtins.addErrorContext (context name)
   262|           (args.${name} or config._module.args.${name});
      |                            ^
   263|       }) requiredArgs);

infinite recursion encountered
--------------------------------------------- show-trace ---------------------------------------------
trace: while evaluating the module argument `nixos-hardware' in ":anon-1071":
trace: while evaluating 'isFunction'
at: (333:16) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/trivial.nix

   332|   */
   333|   isFunction = f: builtins.isFunction f ||
      |                ^
   334|     (f ? __functor && isFunction (f.__functor f));

trace: from call site
at: (148:12) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/modules.nix

   147|       loadModule = args: fallbackFile: fallbackKey: m:
   148|         if isFunction m || isAttrs m then
      |            ^
   149|           unifyModuleSyntax fallbackFile fallbackKey (applyIfFunction fallbackKey m args)

trace: while evaluating 'loadModule'
at: (147:53) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/modules.nix

   146|       # Like unifyModuleSyntax, but also imports paths and calls functions if necessary
   147|       loadModule = args: fallbackFile: fallbackKey: m:
      |                                                     ^
   148|         if isFunction m || isAttrs m then

trace: from call site
at: (185:22) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/modules.nix

   184|           let
   185|             module = loadModule args parentFile "${parentKey}:anon-${toString n}" x;
      |                      ^
   186|             collectedImports = collectStructuredModules module._file module.key module.imports args;

trace: while evaluating the attribute 'disabled'
at: (180:13) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/modules.nix

   179|           collectResults = modules: {
   180|             disabled = concatLists (catAttrs "disabled" modules);
      |             ^
   181|             inherit modules;

trace: while evaluating anonymous lambda
at: (202:31) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/modules.nix

   201|           disabledKeys = map moduleKey disabled;
   202|           keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
      |                               ^
   203|         in map (attrs: attrs.module) (builtins.genericClosure {

trace: from call site
trace: while evaluating 'filterModules'
at: (198:36) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/modules.nix

   197|       # modules recursively. It returns the final list of unique-by-key modules
   198|       filterModules = modulesPath: { disabled, modules }:
      |                                    ^
   199|         let

trace: from call site
at: (209:7) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/modules.nix

   208|     in modulesPath: initialModules: args:
   209|       filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);
      |       ^
   210| 

trace: while evaluating anonymous lambda
at: (208:37) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/modules.nix

   207| 
   208|     in modulesPath: initialModules: args:
      |                                     ^
   209|       filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);

trace: from call site
at: (86:25) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/modules.nix

    85|       merged =
    86|         let collected = collectModules
      |                         ^
    87|           (specialArgs.modulesPath or "")

trace: while evaluating 'reverseList'
at: (393:17) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/lists.nix

   392|   */
   393|   reverseList = xs:
      |                 ^
   394|     let l = length xs; in genList (n: elemAt xs (l - n - 1)) l;

trace: from call site
at: (90:33) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/modules.nix

    89|           ({ inherit lib options config; } // specialArgs);
    90|         in mergeModules prefix (reverseList collected);
      |                                 ^
    91| 

trace: while evaluating 'byName'
at: (321:25) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/modules.nix

   320|       */
   321|       byName = attr: f: modules:
      |                         ^
   322|         foldl' (acc: module:

trace: from call site
at: (329:21) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/modules.nix

   328|       # an attrset 'name' => list of submodules that declare ‘name’.
   329|       declsByName = byName "options" (module: option:
      |                     ^
   330|           [{ inherit (module) _file; options = option; }]

trace: while evaluating 'flip'
at: (138:16) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/trivial.nix

   137|   */
   138|   flip = f: a: b: f b a;
      |                ^
   139| 

trace: from call site
at: (341:23) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/modules.nix

   340| 
   341|       resultsByName = flip mapAttrs declsByName (name: decls:
      |                       ^
   342|         # We're descending into attribute ‘name’.

trace: while evaluating the attribute 'matchedOptions'
at: (373:14) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/modules.nix

   372|     in {
   373|       inherit matchedOptions;
      |              ^
   374| 

trace: while evaluating 'recurse'
at: (273:23) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/attrsets.nix

   272|     let
   273|       recurse = path: set:
      |                       ^
   274|         let

trace: from call site
at: (281:8) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/attrsets.nix

   280|         in mapAttrs g set;
   281|     in recurse [] set;
      |        ^
   282| 

trace: while evaluating 'mapAttrsRecursiveCond'
at: (271:36) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/attrsets.nix

   270|   */
   271|   mapAttrsRecursiveCond = cond: f: set:
      |                                    ^
   272|     let

trace: from call site
at: (98:28) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/modules.nix

    97|           # For definitions that have an associated option
    98|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
      |                            ^
    99| 

trace: while evaluating 'evalModules'
at: (21:17) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/modules.nix

    20|      evalModules) and the less declarative the module set is. */
    21|   evalModules = { modules
      |                 ^
    22|                 , prefix ? []

trace: from call site
at: (58:12) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/nixos/lib/eval-config.nix

    57|   # system configuration.
    58|   inherit (lib.evalModules {
      |            ^
    59|     inherit prefix check;

trace: while checking the NixOS configuration 'nixosConfigurations.ravenor'
at: (194:41) in file: /nix/store/l13lszj9qgpm1r7d8h8bhpq9ik1s5673-source/lib/attrsets.nix

   193|   */
   194|   nameValuePair = name: value: { inherit name value; };
      |                                         ^
   195| 

trace: while checking flake output 'nixosConfigurations'
at: (39:9) in file: /nix/store/ml7bzqjybd1c30hwxq1ia766rsr2q1fv-source/flake.nix

    38|       outputs = {
    39|         nixosConfigurations =
      |         ^
    40|           import ./hosts (recursiveUpdate inputs {

@nrdxp
Copy link
Collaborator

nrdxp commented Dec 28, 2020

Not sure if you're on the latest commit, but there has been a lot of work the last couple of days. Specifically, #42 restructured and simplies how you can add external overlays to your flake from others by simply declaring a new externOverlays attribute which is automatically added to the system overlays. Along with this I intended to add a externModules with the same functionality for modules from other flakes, but I must have been rushing and forgot to do so.

Suffice it to say that I will push a pr in the next few moments that will add this externModules list underneath the existing externOverlays, simply drop any modules your trying to use from the other flake in there and it should work.

nrdxp added a commit that referenced this issue Dec 28, 2020
Fixes #44. Easily add external modules from other flakes by dropping
them in the list.
@nrdxp nrdxp closed this as completed in #45 Dec 28, 2020
@benneti
Copy link
Contributor

benneti commented Jan 7, 2021

actually this approach does not seem good for nixos-hardware
if you take a look at the flake
https://github.com/NixOS/nixos-hardware/blob/master/flake.nix
it exports lots of modules and all of them are device specific.
For example one would only need the module
https://github.com/NixOS/nixos-hardware/blob/master/dell/xps/13-9370/default.nix
for a single host.

Any suggestion how to go about this?

blaggacao pushed a commit to blaggacao/devos that referenced this issue Jul 6, 2021
Fixes divnix#44. Easily add external modules from other flakes by dropping
them in the list.
Pacman99 pushed a commit that referenced this issue Feb 26, 2022
45: Changed output from nix build for iso and doi command r=Pacman99 a=Narice

Closes #44.

This will make the command easier and more predictable.
We can also as a result add the iso folder in the devos gitignore.

Co-authored-by: Narice <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants