From 8aa8775fd63aab44eb9ef79a1af80a560a1d1bf3 Mon Sep 17 00:00:00 2001 From: Xinyang Li Date: Sat, 8 Apr 2023 11:25:29 +0800 Subject: [PATCH] Initial support for building with nix. (#106) Add flake.nix to project, so this project can be built with nix. Also: - Fix a died link in README. - Add missing dependencies in docs for Ubuntu and Arch (not tested). --- README.md | 2 +- docs/dev/compile.rst | 11 +++++++++-- flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/README.md b/README.md index 9564b6dd..5988b684 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ ___ ## 如何构建 -关于如何从头构建FreeKill,详见[编译教程](./doc/dev/compile.md)。 +关于如何从头构建FreeKill,详见[编译教程](https://notify-ctrl.github.io/FreeKill/dev/compile.html)。 ___ diff --git a/docs/dev/compile.rst b/docs/dev/compile.rst index 8bfef1b9..db60d92d 100644 --- a/docs/dev/compile.rst +++ b/docs/dev/compile.rst @@ -46,13 +46,13 @@ Debian一家子: .. code:: sh - $ sudo apt install liblua5.4-dev libsqlite3-dev libssl-dev swig flex bison + $ sudo apt install liblua5.4-dev libsqlite3-dev libreadline-dev libssl-dev swig flex bison Arch Linux: .. code:: sh - $ sudo pacman -Sy lua sqlite swig openssl flex bison + $ sudo pacman -Sy lua sqlite swig openssl flex bison libgit2 然后使用配置好的QtCreator环境即可编译。 @@ -71,6 +71,13 @@ Arch Linux: $ cmake .. $ make -j8 +如果你使用 Nix/NixOs 的话,可以在clone repo后直接使用 nix flake 构建: + +.. code:: sh + + $ git clone https://github.com/Notify-ctrl/FreeKill + $ nix build '.?submodules=1' + -------------- Linux服务器 diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..666168a3 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1680724564, + "narHash": "sha256-eeUUGOTKTelYKDbUxKs0V7GUa186L2fym7jM2QQ4Oss=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "36adaa6aaa6b03e59102df0c1b12cdc3f23fd112", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..45e59b2d --- /dev/null +++ b/flake.nix @@ -0,0 +1,38 @@ +{ + description = "Sanguosha (a.k.a. Legend of Three Kingdoms, LTK) written in Qt and Lua."; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11"; + }; + + outputs = { self, nixpkgs }: { + defaultPackage.x86_64-linux = + with import nixpkgs { system = "x86_64-linux"; }; + stdenv.mkDerivation { + name = "freekill"; + version = "0.0.7"; + src = self; + + buildInputs = with qt6; [ + qtbase + qtdeclarative + qt5compat + qtmultimedia + qttools + sqlite + swig + openssl + flex + bison + readline + libgit2 + lua5_4 + ]; + nativeBuildInputs = [ cmake qt6.wrapQtAppsHook ]; + + postPatch = '' + substituteInPlace src/CMakeLists.txt --replace "LUA_LIB lua5.4" "LUA_LIB lua"; + ''; + }; + }; +}