From e475f9849799208ce95a5d6e1f3e5f07118dd3aa Mon Sep 17 00:00:00 2001 From: Mika Tammi Date: Mon, 15 Jan 2024 00:39:00 +0200 Subject: [PATCH] Conditionally enable systemd timesyncd patch The systemd package was patched nixpkgs upstream, causing the build against nixos-unstable to break, because same patch is about to be applied twice. Check if the patch is already present, and don't do timesync related overrides the second time if it is. Signed-off-by: Mika Tammi --- overlays/custom-packages/systemd/default.nix | 36 ++++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/overlays/custom-packages/systemd/default.nix b/overlays/custom-packages/systemd/default.nix index b173aad03..8411908a5 100644 --- a/overlays/custom-packages/systemd/default.nix +++ b/overlays/custom-packages/systemd/default.nix @@ -1,18 +1,26 @@ # Copyright 2022-2024 TII (SSRC) and the Ghaf contributors # SPDX-License-Identifier: Apache-2.0 (final: prev: { - systemd = prev.systemd.overrideAttrs (prevAttrs: { - patches = prevAttrs.patches ++ [./systemd-timesyncd-disable-nscd.patch]; - postPatch = - prevAttrs.postPatch - + '' - substituteInPlace units/systemd-timesyncd.service.in \ - --replace \ - "Environment=SYSTEMD_NSS_RESOLVE_VALIDATE=0" \ - "${final.lib.concatStringsSep "\n" [ - "Environment=LD_LIBRARY_PATH=$out/lib" - "Environment=SYSTEMD_NSS_RESOLVE_VALIDATE=0" - ]}" - ''; - }); + systemd = let + # The patch has been added nixpkgs upstream, don't override attributes if + # the patch is already present. + # + # https://github.com/NixOS/nixpkgs/pull/239201 + shouldOverride = !(final.lib.lists.any (p: final.lib.strings.hasSuffix "0020-timesyncd-disable-NSCD-when-DNSSEC-validation-is-dis.patch" p) prev.systemd.patches); + in + prev.systemd.overrideAttrs (prevAttrs: + final.lib.optionalAttrs shouldOverride { + patches = prevAttrs.patches ++ [./systemd-timesyncd-disable-nscd.patch]; + postPatch = + prevAttrs.postPatch + + '' + substituteInPlace units/systemd-timesyncd.service.in \ + --replace \ + "Environment=SYSTEMD_NSS_RESOLVE_VALIDATE=0" \ + "${final.lib.concatStringsSep "\n" [ + "Environment=LD_LIBRARY_PATH=$out/lib" + "Environment=SYSTEMD_NSS_RESOLVE_VALIDATE=0" + ]}" + ''; + }); })