Comments (4)
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.
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.
I think the top-level module should always be a flake module, then it can define nested nixosModules
/flakeModules
. For example:
- https://github.com/Preemo-Inc/nix-ml-ops/blob/main/nixos-modules/nix-ld.nix
- https://github.com/Preemo-Inc/nix-ml-ops/blob/main/flake-modules/options-document.nix
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.
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)
- Provide a way to easily run doc tests HOT 1
- Explicitly pass default nixpkgs to mkFlake
- Document, how to declare packages only for concrete system
- perSystem.packages cannot be used with recursive packages HOT 1
- NixOS options not 1:1 available HOT 2
- nixosConfigurations example does not invoke nixosConfigurations HOT 2
- infinite recursion when `self` assigned to option HOT 6
- Add `templates` to `flake` HOT 2
- Infinite recursion error when unknown option is set HOT 3
- nix flake show broken HOT 2
- Set `_file` and `_class` for modules defined under `flake.modules.${className}.${moduleName}` HOT 1
- How to define a custom flake attribute for a reusable module HOT 2
- Attribute set is expected to be unique HOT 2
- Generate nixosConfigurations HOT 1
- Per system option with a different name? HOT 4
- Flakestry releases HOT 2
- Q: How to correctly implement a home-manager? HOT 1
- Do we really need nixpkgs in inputs instead of the lightweight nix-community/nixpkgs.lib? HOT 2
- `flake-parts` doesn't evaluate. HOT 3
- Declaring per-system functions as flake outputs HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flake-parts.