Skip to content
This repository was archived by the owner on Apr 12, 2021. It is now read-only.
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-channels
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 8b4ed614c9e7
Choose a base ref
...
head repository: NixOS/nixpkgs-channels
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: da9efe97d90c
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Aug 16, 2018

  1. nixos/systemd: Allow to override serviceConfig

    This has been reported by @qknight in his Stack Overflow question:
    
    https://stackoverflow.com/q/50678639
    
    The correct way to override a single value would be to use something
    like this:
    
    systemd.services.nagios.serviceConfig.Restart = lib.mkForce "no";
    
    However, this doesn't work because the check is applied for the attrsOf
    type and thus the attribute values might still contain the attribute set
    created by mkOverride.
    
    The unitOption type however did already account for this, but at this
    stage it's already too late.
    
    So now the actual value is unpacked while checking the values of the
    attribute set, which should allow us to override values in
    serviceConfig.
    
    Signed-off-by: aszlig <aszlig@nix.build>
    Cc: @edolstra, @qknight
    (cherry picked from commit 0e7c945)
    Reason: Another user has hit this problem on Discourse[1] and I thought
            I had already backported it to 18.03, apparently I didn't. Given
            the time of the original commit I think this had enough testing
            already so it shouldn't break anything and rather make things
            less annoying.
    [1]: https://discourse.nixos.org/t/is-there-a-universal-way-to-enable-a-service-auto-restart/592/3
    aszlig committed Aug 16, 2018

    Verified

    This commit was signed with the committer’s verified signature.
    Copy the full SHA
    da9efe9 View commit details
Showing with 10 additions and 4 deletions.
  1. +10 −4 nixos/modules/system/boot/systemd-lib.nix
14 changes: 10 additions & 4 deletions nixos/modules/system/boot/systemd-lib.nix
Original file line number Diff line number Diff line change
@@ -77,10 +77,16 @@ rec {
optional (badFields != [ ])
"Systemd ${group} has extra fields [${concatStringsSep " " badFields}].";

checkUnitConfig = group: checks: v:
let errors = concatMap (c: c group v) checks; in
if errors == [] then true
else builtins.trace (concatStringsSep "\n" errors) false;
checkUnitConfig = group: checks: attrs: let
# We're applied at the top-level type (attrsOf unitOption), so the actual
# unit options might contain attributes from mkOverride that we need to
# convert into single values before checking them.
defs = mapAttrs (const (v:
if v._type or "" == "override" then v.content else v
)) attrs;
errors = concatMap (c: c group defs) checks;
in if errors == [] then true
else builtins.trace (concatStringsSep "\n" errors) false;

toOption = x:
if x == true then "true"