diff options
| author | Raghuram Subramani <raghus2247@gmail.com> | 2025-12-04 10:20:23 -0500 |
|---|---|---|
| committer | Raghuram Subramani <raghus2247@gmail.com> | 2025-12-04 10:20:23 -0500 |
| commit | c39cc319394993299874c135564d7675a2c5da45 (patch) | |
| tree | 3763055cb549342f09eccdd0dbb8e11331021f01 | |
| parent | 62cbce9e51781c93822e2ad4eb9a4a54e996e432 (diff) | |
Nix doesn't allow network requests while building, so the source for
discount needs to be fetched before the build is initiated.
| -rw-r--r-- | CMakeLists.txt | 24 | ||||
| -rw-r--r-- | default.nix | 33 | ||||
| -rw-r--r-- | flake.nix | 2 |
3 files changed, 38 insertions, 21 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f5d6b44..131f872 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,15 +1,23 @@ cmake_minimum_required(VERSION 3.21) include(FetchContent) -FetchContent_Declare( - discount - GIT_REPOSITORY "https://github.com/Orc/discount" - GIT_TAG "main" - SOURCE_DIR "discount" -) -FetchContent_MakeAvailable(discount) -add_subdirectory(${discount_SOURCE_DIR}/cmake) +if (DEFINED DISCOUNT_SRC) + FetchContent_Declare( + discount + SOURCE_DIR "${DISCOUNT_SRC}" + ) +else () + FetchContent_Declare( + discount + GIT_REPOSITORY "https://github.com/Orc/discount.git" + GIT_TAG "main" + SOURCE_DIR "discount" + ) +endif() + +FetchContent_MakeAvailable(discount) +add_subdirectory(${discount_SOURCE_DIR}/cmake discount) project(msg C) diff --git a/default.nix b/default.nix index 958091f..14d32d8 100644 --- a/default.nix +++ b/default.nix @@ -4,19 +4,28 @@ , spdlog , abseil-cpp }: -llvmPackages.stdenv.mkDerivation rec { - pname = "msg"; - version = "0.1"; +let + discount_src = builtins.fetchGit{ + url = "https://github.com/Orc/discount.git"; + rev = "c214286f91cb754450121ad1f55a0e9470d3a16c"; + }; +in llvmPackages.stdenv.mkDerivation rec { + pname = "msg"; + version = "0.1"; - src = ./.; + src = ./.; - nativeBuildInputs = [ cmake ]; + nativeBuildInputs = [ cmake ]; - meta = with lib; { - homepage = "https://github.com/compromyse/msg"; - description = "Minimal Static Site Generator"; - licencse = licenses.gpl3; - platforms = with platforms; linux ++ darwin; - maintainers = [ maintainers.compromyse ]; - }; + cmakeFlags = [ + "-DDISCOUNT_SRC=${discount_src}" + ]; + + meta = with lib; { + homepage = "https://github.com/compromyse/msg"; + description = "Minimal Static Site Generator"; + licencse = licenses.gpl3; + platforms = with platforms; linux ++ darwin; + maintainers = [ maintainers.compromyse ]; + }; } @@ -5,7 +5,7 @@ }; outputs = { self, nixpkgs, ... }: - let + let pkgs = import nixpkgs { system = "x86_64-linux"; }; in { devShells.x86_64-linux.default = pkgs.mkShell { |
