Skip to content

Commit

Permalink
Conditionally enable systemd timesyncd patch
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Mika Tammi authored and brianmcgillion committed Jan 15, 2024
1 parent a2c2dbf commit e475f98
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions overlays/custom-packages/systemd/default.nix
Original file line number Diff line number Diff line change
@@ -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"
]}"
'';
});
})

0 comments on commit e475f98

Please sign in to comment.