Coder Social home page Coder Social logo

Comments (4)

infinisil avatar infinisil commented on September 27, 2024 1

A couple days ago I had a discussion with @Melkor333 on IRC regarding this: https://logs.nix.samueldr.com/nixos/2020-07-12#1594566523-1594572059; where I also suggested a non-optimal solution

The change in nixpkgs that introduced this problem is my PR NixOS/nixpkgs#75031. I don't think this is a problem with the PR though, because the problematic code in nixcloud-webservices at

type = let
submodules = toplevel.options.users.users.type.getSubModules;
in lib.types.submodule (map (m: m.submodule) submodules);
(among others) relies on module system internals, which I removed in that PR: https://github.com/NixOS/nixpkgs/pull/75031/files#diff-490491facef0aa6a6dbe8ffc5bd97097L174-L184

After messing with it for a bit, here is how the same functionality can be achieved without relying on internals:

{
  options.webserver.userOptions = lib.mkOption {
    type = lib.types.submodule options.users.users.type.functor.wrapped.getSubModules;
    default = {};
  };

  config.users.users.webserver = lib.modules.mkAliasAndWrapDefsWithPriority lib.id options.webserver.userOptions;

Also, make sure to not use // for merging in the module system like in

users.${config.webserver.user} = {
inherit (config.webserver) group;
} // removeAttrs config.webserver.userOptions [ "name" "group" ];
, because it can lead to problems. Prefer mkMerge instead. And to prevent attributes from being changed, a mkForce is recommended. So in the end that part looks about like this:

{
  users.${config.webserver.user} = lib.mkMerge [
    (lib.mkForce { inherit (config.webserver) user group; })
    (lib.modules.mkAliasAndWrapDefsWithPriority lib.id options.webserver.userOptions)
  ];
}

To prevent name and group from being changed you could set group and name with a mkForce.

from nixcloud-webservices.

Melkor333 avatar Melkor333 commented on September 27, 2024 1

Oh wow thank you for taking another look at it!! 😯 I hope I’ll have time next weekend to run the tests with this code and create a PR...

from nixcloud-webservices.

leenaars avatar leenaars commented on September 27, 2024

There were some changes in modules related to nixcloud-webservices::

https://nixos.org/nixos/manual/release-notes.html#sec-release-19.09

from nixcloud-webservices.

fgaz avatar fgaz commented on September 27, 2024

This prevents nixcloud-webservices to work on the newly released 20.03

from nixcloud-webservices.

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.