Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
base: 375611df00b0
Choose a base ref
...
head repository: NixOS/nixpkgs
compare: 6d0a85fe528e
Choose a head ref
  • 9 commits
  • 12 files changed
  • 3 contributors

Commits on Aug 3, 2020

  1. lib/modules: Scope module evaluation variables more tightly

    This is a purely cosmetic change so it's easier to see dependencies
    between variables.
    infinisil committed Aug 3, 2020
    Copy the full SHA
    b02a3d7 View commit details
    Browse the repository at this point in the history
  2. lib/modules: Internally collect all unmatched definitions

    This fundamentally changes how the module evaluation internally
    handles definitions without an associated option.
    
    Previously the values of these definitions were discarded and only
    the names were propagated. This was fine because that's all that's
    needed for optionally checking whether all definitions have an
    associated option with _module.check.
    
    However with the upcoming change of supporting freeform modules,
    we *do* need the values of these.
    
    With this change, the module evaluation cleanly separates definitions
    that match an option, and ones that do not.
    infinisil committed Aug 3, 2020
    Copy the full SHA
    fd75dc8 View commit details
    Browse the repository at this point in the history
  3. lib/modules: Implement freeform modules

    For programs that have a lot of (Nix-representable) configuration options,
    a simple way to represent this in a NixOS module is to declare an
    option of a type like `attrsOf str`, representing a key-value mapping
    which then gets generated into a config file. However with such a type,
    there's no way to add type checking for only some key values.
    
    On the other end of the spectrum, one can declare a single separate
    option for every key value that the program supports, ending up with a module
    with potentially 100s of options. This has the benefit that every value
    gets type checked, catching mistakes at evaluation time already. However
    the disadvantage is that the module becomes big, becomes coupled to the
    program version and takes a lot of effort to write and maintain.
    
    Previously there was a middle ground between these two
    extremes: Declare an option of a type like `attrsOf str`, but declare
    additional separate options for the values you wish to have type
    checked, and assign their values to the `attrsOf str` option. While this
    works decently, it has the problem of duplicated options, since now both
    the additional options and the `attrsOf str` option can be used to set a
    key value. This leads to confusion about what should happen if both are
    set, which defaults should apply, and more.
    
    Now with this change, a middle ground becomes available that solves above
    problems: The module system now supports setting a freeform type, which
    gets used for all definitions that don't have an associated option. This
    means that you can now declare all options you wish to have type
    checked, while for the rest a freeform type like `attrsOf str` can be
    used.
    infinisil committed Aug 3, 2020
    Copy the full SHA
    65e25de View commit details
    Browse the repository at this point in the history
  4. lib/types: Make submodules use the freeform type description

    Submodules that have a freeform type set behave as if that was the type
    of the option itself (for values that don't have an option). Since the
    submodules options are shown as separate entries in the manual, it makes
    sense to show the freeform type as the submodule type.
    infinisil committed Aug 3, 2020
    Copy the full SHA
    2d45a62 View commit details
    Browse the repository at this point in the history
  5. Copy the full SHA
    446d80d View commit details
    Browse the repository at this point in the history

Commits on Aug 10, 2020

  1. Copy the full SHA
    e0ded8f View commit details
    Browse the repository at this point in the history

Commits on Aug 14, 2020

  1. lib/modules: Add syntactic sugar for config._module.freeformType

    This introduces `freeformType` as a top-level module attribute, allowing
    definitions like
    
      {
        freeformType = ...;
        options = ...;
        config = ...;
      }
    infinisil committed Aug 14, 2020
    Copy the full SHA
    42cf813 View commit details
    Browse the repository at this point in the history
  2. nixos/doc: Add freeform modules documentation

    Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
    infinisil and roberth committed Aug 14, 2020
    Copy the full SHA
    25d7515 View commit details
    Browse the repository at this point in the history

Commits on Aug 15, 2020

  1. Merge pull request #82743 from Infinisil/partially-typed-v2

    Freeform modules
    roberth committed Aug 15, 2020
    Copy the full SHA
    6d0a85f View commit details
    Browse the repository at this point in the history