diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index a512199..21640d0 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -104,3 +104,15 @@ jobs: with: file: "${{ github.workspace }}/out/rpm_package/*.rpm;${{ github.workspace }}/out/rpm_package/*.rpm.sha512" tags: true + + nix: + name: Build nix package + runs-on: ubuntu-22.04 + needs: metadata + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2 + + - name: Install Nix + uses: cachix/install-nix-action@3715ab1a11cac9e991980d7b4a28d80c7ebdd8f9 # v28 + - name: Build + run: nix-build ${{ github.workspace }}/tools/nix -A filc diff --git a/.gitignore b/.gitignore index 299cea8..5470fcb 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ filc !include/* !src/* out +result !bin/* coverage.info .idea diff --git a/CMakeLists.txt b/CMakeLists.txt index 75b99ae..835d70c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ file(READ ${CMAKE_CURRENT_SOURCE_DIR}/VERSION FILC_VERSION) project( filc VERSION ${FILC_VERSION} - LANGUAGES C CXX + LANGUAGES CXX ) include(FetchContent) diff --git a/shell.nix b/shell.nix index b6b6413..33c306f 100644 --- a/shell.nix +++ b/shell.nix @@ -3,8 +3,7 @@ let currentDir = builtins.toString ./.; pnpm = pkgs.callPackage ./tools/nix/pnpm.nix { nodejs = pkgs.nodejs_20; }; - cxxopts = pkgs.callPackage ./tools/nix/cxxopts.nix { }; - antlr4 = pkgs.callPackage ./tools/nix/antlr4.nix { }; + cxxopts = pkgs.cxxopts.override { enableUnicodeHelp = false; }; in pkgs.mkShell { @@ -27,8 +26,8 @@ pkgs.mkShell { pkgs.libffi pkgs.libxml2 cxxopts - antlr4.antlr - antlr4.runtime.cpp + pkgs.antlr4_13 + pkgs.antlr4_13.runtime.cpp ]; shellHook = '' diff --git a/tools/nix/antlr4.nix b/tools/nix/antlr4.nix deleted file mode 100644 index 19924cf..0000000 --- a/tools/nix/antlr4.nix +++ /dev/null @@ -1,78 +0,0 @@ -{ stdenv -, fetchurl -, fetchFromGitHub -, jre -, cmake, ninja, pkg-config -}: - -# From https://github.com/NixOS/nixpkgs/blob/nixos-24.11/pkgs/development/tools/parsing/antlr/4.nix -let - mkAntlr = { - version, jarHash, srcHash - }: rec { - antlr = stdenv.mkDerivation { - pname = "antlr"; - inherit version; - - src = fetchurl { - url = "https://www.antlr.org/download/antlr-${version}-complete.jar"; - hash = jarHash; - }; - - dontUnpack = true; - - installPhase = '' - mkdir -p "$out"/{share/java,bin} - ln -s "$src" "$out/share/java/antlr-${version}-complete.jar" - - echo "#! ${stdenv.shell}" >> "$out/bin/antlr" - echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' -Xmx500M org.antlr.v4.Tool \"\$@\"" >> "$out/bin/antlr" - - echo "#! ${stdenv.shell}" >> "$out/bin/antlr-parse" - echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' -Xmx500M org.antlr.v4.gui.Interpreter \"\$@\"" >> "$out/bin/antlr-parse" - - echo "#! ${stdenv.shell}" >> "$out/bin/grun" - echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' org.antlr.v4.gui.TestRig \"\$@\"" >> "$out/bin/grun" - - chmod a+x "$out/bin/antlr" "$out/bin/antlr-parse" "$out/bin/grun" - ln -s "$out/bin/antlr"{,4} - ln -s "$out/bin/antlr"{,4}-parse - ''; - - inherit jre; - - passthru = { - inherit runtime; - jarLocation = antlr.src; - }; - }; - - runtime.cpp = stdenv.mkDerivation { - pname = "antlr-runtime-cpp"; - inherit version; - - src = fetchFromGitHub { - owner = "antlr"; - repo = "antlr4"; - rev = version; - hash = srcHash; - }; - - outputs = [ "out" "dev" "doc" ]; - - nativeBuildInputs = [ cmake ninja pkg-config ]; - - cmakeDir = "../runtime/Cpp"; - cmakeFlags = [ - "-DANTLR4_INSTALL=ON" - "-DANTLR_BUILD_CPP_TESTS=OFF" - ]; - }; - }; -in - -mkAntlr { - version = "4.13.0"; - jarHash = "sha256-vG9KvA0iWidXASbFFAJWnwAKje2jSHtw52QoQOVw5KY="; - srcHash = "sha256-s1yAdScMYg1wFpYNsBAtpifIhQsnSAgJg7JjPDx+htc="; -} diff --git a/tools/nix/cxxopts.nix b/tools/nix/cxxopts.nix deleted file mode 100644 index 36f0a91..0000000 --- a/tools/nix/cxxopts.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ stdenv -, fetchFromGitHub -, icu -, cmake, pkg-config -}: - -# From https://github.com/NixOS/nixpkgs/blob/nixos-24.11/pkgs/by-name/cx/cxxopts/package.nix -stdenv.mkDerivation rec { - pname = "cxxopts"; - version = "3.2.0"; - - src = fetchFromGitHub { - owner = "jarro2783"; - repo = "cxxopts"; - rev = "v${version}"; - hash = "sha256-tOO0YCIG3MxSJZhurNcDR1pWIUEO/Har9mrCrZs3iVk="; - }; - -# buildInputs = [ icu.dev ]; - cmakeFlags = [ - "-DCXXOPTS_BUILD_EXAMPLES=OFF" - "-DCXXOPTS_USE_UNICODE_HELP=FALSE" - ]; - nativeBuildInputs = [ cmake pkg-config ]; - - doCheck = true; - dontUserCmakeBuildDir = true; - - postPatch = '' - substituteInPlace packaging/pkgconfig.pc.in \ - --replace '$'{prefix}/@CMAKE_INSTALL_INCLUDEDIR@ @CMAKE_INSTALL_FULL_INCLUDEDIR@ - ''; -} diff --git a/tools/nix/default.nix b/tools/nix/default.nix new file mode 100644 index 0000000..608d77b --- /dev/null +++ b/tools/nix/default.nix @@ -0,0 +1,5 @@ +let + pkgs = import ./pin-nixpkgs.nix { }; +in { + filc = pkgs.callPackage ./filc.nix { }; +} diff --git a/tools/nix/filc.nix b/tools/nix/filc.nix new file mode 100644 index 0000000..0a9875b --- /dev/null +++ b/tools/nix/filc.nix @@ -0,0 +1,28 @@ +{ stdenvNoCC +, fetchFromGitHub +, cmake +, ninja +, clang +, cxxopts +, antlr4_13 +, llvmPackages_18 +}: + +let + cxxopts_filc = cxxopts.override { enableUnicodeHelp = false; }; +in + +stdenvNoCC.mkDerivation rec { + pname = "filc"; + version = "0.1.0"; + + src = fetchFromGitHub { + owner = "Fil-Language"; + repo = "filc"; + rev = "v${version}"; + hash = "sha256-MB6ABwxVYdJ4YxLHKNvDLrFUN6M/u2/vk1+x3rjktPU="; + }; + + nativeBuildInputs = [ cmake ninja clang ]; + buildInputs = [ cxxopts_filc antlr4_13 antlr4_13.runtime.cpp llvmPackages_18.libllvm ]; +}