-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
Anonymous NixOS modules (e.g. from flakes) cannot be disabled #114131
Comments
I know that it's quite straightforward but I still think that it's better to rely on a test machine than to rebuild your own config. import ./make-test-python.nix ({ pkgs, ... }: {
name = "test";
nodes.test = { pkgs, ... }: { disabledModules = [ {} ]; };
testScript = ''
'';
}) |
So surely the answer is don't use anonymous modules? Edit: oh, for what it's worth, just because the module isn't in nixpkgs, doesn't mean it's de-facto anonymous. None of the ones in my flake are - I had to ensure that to make manual building work |
@bqv: Every module you access over the flake API (the attr What do you mean by “manual building”? |
Yes. Caring about file structure is not against the flake api imo, hence why flakes can be coerced to paths like any other derivation. Manual building = the act of building the manual... |
It's not against the flake api, but it circumvents it. It doesn't use the flake API, so it defeats the reason for using flakes. You can simply use any fixed-output derivation for fetching or declare a non-flake input to a flake, if you don't want to use a consistent api. Why are you using Nix in the first place if you can use Linux From Scratch? What do you need Linux for if you can write your own kernel and directly access hardware? Because of abstraction. Imagine a flake whose file tree is littered with modules in 50 different places but exposing the standardized flake API. You have to look at every file to know if it's a module. You don't want to include every single one by path, do you? |
You can't be serious... |
I've been running into this and it is pretty frustrating. |
You can still override modules by path, but you must rely on the file system structure of the flakes. The store dir of an input flake The modules aren't necessarily anonymous functions. They can be attrsets, functions or functors (i.e. attrsets containing an attr |
Edit: The issue was my lack of understanding of how nixos modules work, coupled with how declarative nixos containers work. disabledModules are not passed into the declared containers (which should be expected). I think I bumped into this issue, is there a workaround? Neither
seem to work, and there doesn't seem to be any examples or documentation on how to replace a module in a flaked configuration. Any ideas? |
{ config, pkgs, lib, modulesPath, ... }:
{
imports = [
"${modulesPath}/installer/sd-card/sd-image.nix"
];
disabledModules = map (m: /. + "${modulesPath}/${m}") [
"profiles/all-hardware.nix"
];
} |
the upstream module cannot be disabled easily or possibly at all when using flakes... NixOS/nixpkgs#114131
I marked this as stale due to inactivity. → More info |
Still important. (I use all of my custom modules via flake attributes, and if I were to need to disable a module pulled by another module, that would be a major source of pain.) |
Still important to me as well. Had to reference a flake module by path to get my config to work. |
Describe the bug
An anonymous NixOS module (not included in
imports
by path but as a function/attr set) cannot be disabled, both because on import the module key is not specific to a module but to an import and becausefilterModules
tries to convert all non-string elements ofdisabledModules
to strings, probably expecting them to be paths.This defeats the standardized
nixosModules
api of flakes, since one must rely on the file structure for importing and disabling fordisabledModules
to work.To Reproduce
disabledModules = [ {} ];
toconfiguration.nix
nixos-rebuild build
Expected behavior
If possible, modules should probably get a unique key, regardless of how they are given. This should also be used in
disabledModules
.The text was updated successfully, but these errors were encountered: