From dd440799879b7c2934e1fd1631305f85ab9ecb15 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Mon, 12 Jun 2023 00:45:53 -0500 Subject: [PATCH] nix --- .envrc | 6 +- .gitignore | 3 +- flake.lock | 112 ++++++++++++++++++++++++++++++++++++++ flake.nix | 62 +++++++++++++++++++++ src-tauri/tauri.conf.json | 5 +- 5 files changed, 183 insertions(+), 5 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc index bf2d0c5..396b001 100644 --- a/.envrc +++ b/.envrc @@ -1,4 +1,4 @@ -strict_env - export HOUHOU_SRC=$PWD -export DATABASE_URL=$HOUHOU_SRC/src-tauri/SrsDatabase.sqlite \ No newline at end of file +export DATABASE_URL=$HOUHOU_SRC/src-tauri/SrsDatabase.sqlite + +use flake diff --git a/.gitignore b/.gitignore index 7fdac4a..e259467 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,5 @@ dist-ssr *.sw? houhou.db -src/data/kanadata.json \ No newline at end of file +src/data/kanadata.json +.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..db26b9d --- /dev/null +++ b/flake.lock @@ -0,0 +1,112 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "nixpkgs": "nixpkgs", + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1686464419, + "narHash": "sha256-2hnB1rRENavNQRmroJqRJlAXJxaUxFuNKxWTHtXBUlE=", + "owner": "nix-community", + "repo": "fenix", + "rev": "f7169edb93ce396ff1f0d94620241c6390f49f54", + "type": "github" + }, + "original": { + "id": "fenix", + "type": "indirect" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1686412476, + "narHash": "sha256-inl9SVk6o5h75XKC79qrDCAobTD1Jxh6kVYTZKHzewA=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "21951114383770f96ae528d0ae68824557768e81", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1686544600, + "narHash": "sha256-QRSZuGex5W+41zqm7NHXcokkgev8WULS8xGyQEpMXtI=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "c1944ee51b8d6885aaa5470fbb010b86c01d6470", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "fenix": "fenix", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs_2" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1686406537, + "narHash": "sha256-dLR+WVwKTwmzCVx0N91BkILXhNPlZ3uuUVg6GFvusME=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "68bdf609f37a74547d9fbdf28ed22c10f9bcca45", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..9c5137e --- /dev/null +++ b/flake.nix @@ -0,0 +1,62 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils, fenix }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ fenix.overlays.default ]; + }; + + toolchain = pkgs.fenix.stable; + + libraries = with pkgs; [ + webkitgtk + gtk3 + cairo + gdk-pixbuf + glib.out + dbus.lib + openssl.out + libayatana-appindicator + ]; + + packages = with pkgs; [ + pkg-config + dbus + openssl + glib + gtk3 + libsoup + webkitgtk + appimagekit + ]; + in { + devShell = pkgs.mkShell { + buildInputs = packages; + + packages = (with pkgs; [ ]) ++ (with toolchain; [ + rustc + cargo + # rust-analyzer + # rust-src + # rust-std + + # Get the nightly version of rustfmt so we can wrap comments + pkgs.fenix.default.rustfmt + ]); + + shellHook = let + joinLibs = libs: + builtins.concatStringsSep ":" (builtins.map (x: "${x}/lib") libs); + libs = joinLibs libraries; + in '' + export LD_LIBRARY_PATH=${libs}:$LD_LIBRARY_PATH + ''; + }; + }); +} diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 393ae21..d6eadf5 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -31,6 +31,9 @@ "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico" + ], + "resources": [ + "./KanjiDatabase.sqlite" ] }, "security": { @@ -50,4 +53,4 @@ } ] } -} \ No newline at end of file +}