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

module system: No shorthand imports syntax in submodules #70638

Open
roberth opened this issue Oct 7, 2019 · 2 comments
Open

module system: No shorthand imports syntax in submodules #70638

roberth opened this issue Oct 7, 2019 · 2 comments
Labels
0.kind: bug 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md

Comments

@roberth
Copy link
Member

roberth commented Oct 7, 2019

Describe the bug

When importing into a submodule, imports are not recognized unless the submodule is specified as a function. Also the error message is not helpful.

Normally the syntaxes for modules are interchangable. In particular:

{
    imports = [ ./someFile.nix ];
}

is equivalent to

{...}: {
    imports = [ ./someFile.nix ];
}

This does not work for submodules.

{
    x.y = {...}: { imports = [ ./someFile.nix ]; };
}

should be equivalent to, but doesn't work when specified as

{
    x.y.imports = [ ./someFile.nix ];
}

To Reproduce

This uses Arion as an example and to provide some context as to why one might want this:

$ git clone https://github.com/hercules-ci/arion; cd arion
$ git checkout for-nixpkgs-lib-imports-issue
$ cd examples/minimal
$ NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/master.tar.gz ../../run-arion-via-nix cat --show-trace
[...]
The option `services.webserver.imports' defined in `/nix/store/sf3j91p62aznv9iy102sa0838qgjg61n-arion-0.1.0.0-data/share/ghc-8.6.4/x86_64-linux-ghc-8.6.4/arion-compose-0.1.0.0/nix/modules/composition/docker-compose.nix' does not exist.

Expected behavior

The simplification just works.

Metadata
Please run nix run nixpkgs.nix-info -c nix-info -m and paste the result.

NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/master.tar.gz nix run nixpkgs.nix-info -c nix-info -m
warning: unknown setting 'sandbox-fallback'
 - system: `"x86_64-linux"`
 - host os: `Linux 5.2.13, NixOS, 19.09beta206.e6b068cd952 (Loris)`
 - multi-user?: `yes`
 - sandbox: `yes`
warning: unknown setting 'sandbox-fallback'
 - version: `nix-env (Nix) 2.2.2`
warning: unknown setting 'sandbox-fallback'
 - channels(user): `""`
warning: unknown setting 'sandbox-fallback'
 - channels(root): `"nixos-19.09beta206.e6b068cd952, nixos-19.03-19.03.173506.2dfae8e22fd, stable-18.09.2574.a7e559a5504"`
warning: unknown setting 'sandbox-fallback'
 - nixpkgs: `/nix/store/l9k8ycmrdn86a1lzgnx5c4ckld7k2l56-master.tar.gz`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
@infinisil
Copy link
Member

With #75031 you can turn off this odd behavior for specific submodules by replacing types.submodule with types.fullSubmodule {}, see #75031 (comment)

@stale
Copy link

stale bot commented Jun 2, 2020

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
Projects
None yet
Development

No branches or pull requests

2 participants