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

Importing namespaced nixosModules #136

Open
TakodaS opened this issue Oct 30, 2024 · 1 comment
Open

Importing namespaced nixosModules #136

TakodaS opened this issue Oct 30, 2024 · 1 comment

Comments

@TakodaS
Copy link

TakodaS commented Oct 30, 2024

Suppose I really like the palworld server configuration you use in your config and i want to use it in my dotfiles. I setup my snowfall flake as follows:

#flake.nix
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";

    snowfall-lib = {
      url = "github:snowfallorg/lib";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    jh-config = {
      url = "github:jakehamilton/config";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.aux-website.url = "nixpkgs"; # I override the flake urls here because nix flake show errors out
      inputs.discord-nord-theme.url = "nixpkgs";
    };
  };

  outputs = inputs:
    inputs.snowfall-lib.mkFlake {
      inherit inputs;
      src = ./.;
      systems.modules.nixos = with inputs; [
        jh-config.nixosModules."services/palworld"
      ];
    };
}

#systems/x86_64-linux/test-system/default.nix
{
  config,
  namespace, # The namespace used for your flake, defaulting to "internal" if not set.
  ...
}: {
  config.services.palworld.enable = true;
}

This fails with the error
error: The option plusultra.services.steam does not exist.
because this dependent option is not loaded. To fix this, I could add ` jh-config.nixosModules."services/steam" to my module imports but this might depend on other internally defined options and would mean I'd have to manually keep adding modules until the dependencies are satisfied. On the other hand, i can see how polluting the global namespace might have nasty consequences down the line. Is there a smarter way I'm missing? Many thanks!

@jameslounds
Copy link

I think this is an issue with how that specific module is written rather than with snowfall itself. This line makes explicit reference to config.plusultra.services.steam so if you use this module, you need to have config.plusultra.services.steam as an option in your config, since it's not declared by that file.

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

No branches or pull requests

2 participants