Closed diegofariasm closed 9 months ago
I have tried look around for a option defined for the imports, but i couldn't really find it. To be honest, i think is mistagged this issue.
Anyway, wouldn't it be possible to make an option that resolves to the normal home-manager imports? this would, in instance, enabe you to do condiotional imports in a pretty concise manner.
{ config, pkgs, lib, ... }:
let cfg = config.modules.editors.kakoune;
in
{
options.modules.editors.kakoune = {
enable = lib.mkOption {
description = ''
Wheter to install kakoune.
'';
type = lib.types.bool;
default = false;
example = true;
};
};
config = lib.mkIf cfg.enable {
imports = [
someHomemanagerModule
];
home.packages = with pkgs; [
kakoune
];
};
}
Hi,
The assignment of imports
must be moved at the same level as options
and config
.
It's not possible to have conditional (lazy) imports
as the nixpkgs module system does not support it.
imports
is not an option and handled in a unique way like config
, options
and other meta values.
It's not possible to have conditional (lazy) imports as the nixpkgs module system does not support it. Oh, that's too bad.
The assignment of imports must be moved at the same level as options and config. I know. I just had an doubt and would be wondering if something like that would actually be possible to achieve.
I was just wondering if that would be possible because of this:
imports = [ … ] ++ lib.optional (builtins.pathExists ./secrets.nix) ./secrets.nix;
That i found in a discourse discussion: nixos-discourse
Yes, that solution would work as it can be evaluated before the rest of the module system.
I believe all/most references to config
while evaluating imports
will lead to an infinite recursion error.
Anyway, thanks for the help. It's just as you have said, mostly everything i have tried to do ended up in a infinite recursion. Thanks for the help and sorry for the trouble.
Are you following the right branch?
Is there an existing issue for this?
Issue description
I am trying to do a conditional import for a module:
And the issue is i get this error:
error: The option
home-manager.users.fushiii.imports' does not exist`Is there anyway to achieve what i am trying to do or is not possible?
Maintainer CC
No response
System information