GithubHelp home page GithubHelp logo

Comments (6)

danth avatar danth commented on August 26, 2024

It seems that when we use mkIf, the option must exist even if the condition is false. Something like optionalAttrs would fix that, but it might introduce new issues which mkIf exists to solve.

from stylix.

dwarfmaster avatar dwarfmaster commented on August 26, 2024

I looked into it, and it seems we're running into a limitation of the nixos module system. We can't conditionally set an option only if it exists. The following in stylix/nixos/default.nix should work, but it will break for any config in which computing the WHNF of options depends on the WHNF of config :

   if options ? home-manager
    then (lib.mkIf hm.autoImport {
           home-manager.sharedModules = [ homeManagerModule ];
         })
    else {}

from stylix.

SenchoPens avatar SenchoPens commented on August 26, 2024

Hi everyone!

@dwarfmaster the WHNF of options can't depend on the WHNF of config in first place as it will cause infinite recursion right away, because the WHNF of config depends on the WHNF of options, so it's safe to do as you proposed.

@danth maybe follow this pattern for modules which set options that are not in the latest release? I just tried it on my local fork with avizo and mako, while being on 22.11, and it worked. Example (mako.nix):

...
  config = if options.services ? mako then lib.mkIf config.stylix.targets.mako.enable {
...

from stylix.

SomeGuyNamedMay avatar SomeGuyNamedMay commented on August 26, 2024

that seems like a reasonable option to me

from stylix.

danth avatar danth commented on August 26, 2024

@SenchoPens That makes sense, I can implement it unless you're already working on it (I noticed you forked the repo).

Is it safe to use lib.optionalAttrs in place of the if statement?

from stylix.

SenchoPens avatar SenchoPens commented on August 26, 2024

Done. Good call with the lib.optionalAttrs!

from stylix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.