Commit cd869b7f authored by Yiyu Zhou's avatar Yiyu Zhou
Browse files

pihole-ftl: cleanup

parent 6f0445b7
Loading
Loading
Loading
Loading
+19 −13
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  nixosTests,
  fetchFromGitHub,
  cmake,
  fetchFromGitHub,
  gmp,
  lib,
  libidn2,
  libunistring,
  mbedtls,
  ncurses,
  nettle,
  nix-update-script,
  nixosTests,
  readline,
  stdenv,
  versionCheckHook,
  xxd,
}:

@@ -46,14 +48,15 @@ stdenv.mkDerivation (finalAttrs: {

  postPatch = ''
    substituteInPlace src/version.c.in \
      --replace-quiet "@GIT_VERSION@" "v${finalAttrs.version}" \
      --replace-quiet "@GIT_DATE@" "1970-01-01" \
      --replace-quiet "@GIT_BRANCH@" "master" \
      --replace-quiet "@GIT_TAG@" "v${finalAttrs.version}" \
      --replace-quiet "@GIT_HASH@" "builtfromreleasetarball"
      --replace-fail "@GIT_VERSION@" "v${finalAttrs.version}" \
      --replace-fail "@GIT_DATE@" "1970-01-01" \
      --replace-fail "@GIT_BRANCH@" "master" \
      --replace-fail "@GIT_TAG@" "v${finalAttrs.version}" \
      --replace-fail "@GIT_HASH@" "builtfromreleasetarball"

    # Remove hard-coded absolute path to the pihole script, rely on it being provided by $PATH
    # Use execvp instead of execv so PATH is followed
    # Remove hard-coded absolute path to the pihole script, rely on it
    # being provided by $PATH.  Use execvp instead of execv so PATH is
    # followed.
    substituteInPlace src/api/action.c \
      --replace-fail "/usr/local/bin/pihole" "pihole" \
      --replace-fail "execv" "execvp"
@@ -62,17 +65,20 @@ stdenv.mkDerivation (finalAttrs: {
  installPhase = ''
    runHook preInstall

    install -Dm 555 -t $out/bin pihole-FTL
    install -D pihole-FTL $out/bin/${finalAttrs.meta.mainProgram}

    runHook postInstall
  '';

  passthru = {
    settingsTemplate = ./pihole.toml;

    tests = nixosTests.pihole-ftl;
    updateScript = nix-update-script { };
  };

  doInstallCheck = true;
  nativeInstallCheckInputs = [ versionCheckHook ];

  meta = {
    description = "Pi-hole FTL engine";
    homepage = "https://github.com/pi-hole/FTL";