GithubHelp home page GithubHelp logo

Comments (4)

roberth avatar roberth commented on June 18, 2024 1

The idea behind this restriction is to make sure that all flake-parts modules are in one, compatible form.
This convention avoids weird errors that would arise when importing a perSystem-level module into the top level or vice versa.

  • NixOS/nixpkgs#197547 would help, but only in cases where the module has its "class" set; usually not by the author, but possibly by flake-parts itself, via flake.flakeModules or similar.

The statements about the scope only hold true as long as all code is defined inside a single flake.nix file.
The lexical scope breaks as soon as the code is split into modules.

This should work if you define the module as a top-level module. The top-level module provides the lexical scope with these variables, as suggested in the error message.

from flake-parts.

roberth avatar roberth commented on June 18, 2024

This decision could be reverted when we have

  • error messages for bad imports: NixOS/nixpkgs#197547
  • deferredModule options that tag modules with their class

from flake-parts.

Atry avatar Atry commented on June 18, 2024

I think the top-level module should always be a flake module, then it can define nested nixosModules/flakeModules. For example:

When defining a nested flakeModules, the top level inputs are from the flake that defines the module, and the nested inputs are from the flake that use the module.

from flake-parts.

TECHNOFAB11 avatar TECHNOFAB11 commented on June 18, 2024

I just had the same issue, I wanted to access my util flake from a perSystem module. A workaround is adding this to the imports where the module gets imported:

({...}: {
  _module.args.origInputs = inputs;
})

I could then just use origInputs.<flake>

from flake-parts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.