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

mkForce, mkDefault etc, stripped from modules ? #125

Open
theotheroracle opened this issue Aug 4, 2024 · 8 comments
Open

mkForce, mkDefault etc, stripped from modules ? #125

theotheroracle opened this issue Aug 4, 2024 · 8 comments

Comments

@theotheroracle
Copy link

theotheroracle commented Aug 4, 2024

i'm trying to set something as mkDefault in a module, and then mkForce the same option in the system config, but the error message prints out no mkDefault, and simply says the option was defined twice, is some stripping being done or am i just using mkForce wrong ?

for reference, the option i was trying to set was boot.supportedFilesystems = mkDefault [ "bcachefs" ];

@theotheroracle
Copy link
Author

i was able to use mkForce normally to overide a default package option, which indicates to me that i'm either somehow using it wrong in the above example, or that perhaps there's just some issue with it from module to system config, but i'm not sure so i'll leave this open for now

@olifloof
Copy link

olifloof commented Aug 5, 2024

can you link your config?

@theotheroracle
Copy link
Author

@olifloof
Copy link

olifloof commented Sep 7, 2024

i would suggest creating an option with a default

{
  lib,
  config,
  namespace,
  ...
}:
let
  cfg = config.${namespace}.boot;
in {
  options.${namespace}.boot.supportedFilesystems = lib.mkOption {
    type = types.listOf types.str;
    default = [ "bcachefs" ];
  };

  boot.supportedFilesystems = cfg.supportedFilesystems;
  boot.loader.systemd-boot.enable = true;
  boot.consoleLogLevel = 3;
  boot.kernelParams = [ "quiet" ];
  boot.loader.timeout = 1;
  boot.loader.systemd-boot.configurationLimit = 5;
  boot.initrd.systemd.enable = true;
  boot.plymouth.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
}

and then setting it in your system config like this

{ lib, namespace, ... }:
{
  ${namespace}.boot.supportedFilesystems = ["ext4"];
}

@theotheroracle
Copy link
Author

{
  lib,
  config,
  namespace,
  ...
}:
let
  cfg = config.${namespace}.boot;
in {
  options.${namespace}.boot.supportedFilesystems = lib.mkOption {
    type = lib.types.listOf lib.types.str;
    default = [ "bcachefs" ];
  };
  boot.supportedFilesystems = cfg.supportedFilesystems;
}
error: Module `:anon-1718:anon-1' has an unsupported attribute `boot'. This is caused by introducing a top-level `config' or `options' attribute. Add configuration attributes immediately on the top level instead, or move all of them (namely: boot) into the explicit `config' attribute.

@olifloof
Copy link

ah, it should be within config

@@ -11,5 +11,7 @@ in {
     type = lib.types.listOf lib.types.str;
     default = [ "bcachefs" ];
   };
-  boot.supportedFilesystems = cfg.supportedFilesystems;
+  config = {
+    boot.supportedFilesystems = cfg.supportedFilesystems;
+  };
 }

@theotheroracle
Copy link
Author

i get the same error, not sure if i did something wrong or not

{
  lib,
  config,
  namespace,
  ...
}:
let
  cfg = config.${namespace}.boot;
in {
  options.${namespace}.boot.supportedFilesystems = lib.mkOption {
    type = lib.types.listOf lib.types.str;
    default = [ "bcachefs" ];
  };
  config = {
  boot.supportedFilesystems = cfg.supportedFilesystems;
  };
}

@theotheroracle
Copy link
Author

theotheroracle commented Sep 16, 2024

nvm i figured it out; i had extra config not in the "config" option, nix is weird

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