Make the project build completely with nix
This commit is contained in:
parent
5cf0b95d8b
commit
9360695883
|
@ -1,16 +1,20 @@
|
|||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
||||
import 'package:sqlite3/open.dart';
|
||||
|
||||
import 'jmdict/parser.dart';
|
||||
import 'kanjidic/parser.dart';
|
||||
import 'radkfile/parser.dart';
|
||||
|
||||
Future<void> main(List<String> arguments) async {
|
||||
final db = await databaseFactoryFfi
|
||||
final db = await createDatabaseFactoryFfi(ffiInit: () {
|
||||
open.overrideForAll(() => DynamicLibrary.open(arguments[0]));
|
||||
})
|
||||
.openDatabase(Directory.current.uri.resolve('main.db').path);
|
||||
await addDataFromJMdict(db);
|
||||
await addDataFromRADKFILE(db);
|
||||
await addDataFromKANJIDIC(db);
|
||||
// await addDataFromKANJIDIC(db);
|
||||
}
|
||||
|
||||
|
|
16
flake.lock
16
flake.lock
|
@ -3,7 +3,7 @@
|
|||
"JMdictSrc": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"narHash": "sha256-TAkT98/lC1zBAJ/ublGi/gK965pwxoHJrnWRaKKBq7I=",
|
||||
"narHash": "sha256-aa0EeHVNQjqwKsvWo8OzE5eYic3DAKB8Gz4kbGnHL44=",
|
||||
"type": "file",
|
||||
"url": "http://ftp.edrdg.org/pub/Nihongo/JMdict.gz"
|
||||
},
|
||||
|
@ -15,7 +15,7 @@
|
|||
"JMdictWithExamplesSrc": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"narHash": "sha256-GfClwLR4uoxPKxRbI5qgELurAdpegCbZO5lEORb3EvA=",
|
||||
"narHash": "sha256-FjIn+OwwWPLGyheOP0FhKpyZuOMLBvzx2tMkXR7vf4k=",
|
||||
"type": "file",
|
||||
"url": "http://ftp.edrdg.org/pub/Nihongo/JMdict_e_examp.gz"
|
||||
},
|
||||
|
@ -38,11 +38,11 @@
|
|||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1649676176,
|
||||
"narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=",
|
||||
"lastModified": 1659877975,
|
||||
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "a4b154ebbdc88c8498a5c7b01589addc9e9cb678",
|
||||
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -77,11 +77,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1655456688,
|
||||
"narHash": "sha256-j2trI5gv2fnHdfUQFBy957avCPxxzCqE8R+TOYHPSRE=",
|
||||
"lastModified": 1660661643,
|
||||
"narHash": "sha256-WlgPb7KLTZUeY31o9HWhu37pvgA76MKwakaXefkaIB4=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "d17a56d90ecbd1b8fc908d49598fb854ef188461",
|
||||
"rev": "a82127cea64fd801c5e138ae23dfd444ec1e06d1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
37
flake.nix
37
flake.nix
|
@ -93,16 +93,16 @@
|
|||
|
||||
nativeBuildInputs = with pkgs; [ xmlformat ];
|
||||
buildPhase = ''
|
||||
gzip -dkc ${JMdictSrc} > jmdict.xml
|
||||
gzip -dkc ${JMdictWithExamplesSrc} > jmdict_with_examples.xml
|
||||
xmlformat -i jmdict.xml
|
||||
xmlformat -i jmdict_with_examples.xml
|
||||
gzip -dkc ${JMdictSrc} > JMdict.xml
|
||||
gzip -dkc ${JMdictWithExamplesSrc} > JMdict_with_examples.xml
|
||||
xmlformat -i JMdict.xml
|
||||
xmlformat -i JMdict_with_examples.xml
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
cp jmdict.xml $out
|
||||
cp jmdict_with_examples.xml $out
|
||||
cp JMdict.xml $out
|
||||
cp JMdict_with_examples.xml $out
|
||||
'';
|
||||
|
||||
meta = edrdgMetadata // {
|
||||
|
@ -119,10 +119,12 @@
|
|||
|
||||
buildPhase = ''
|
||||
gzip -dkc $src > radkfile
|
||||
iconv -f EUC-JP -t UTF-8 -o radkfile_utf8 radkfile
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
iconv -f EUC-JP -t UTF-8 -o $out radkfile
|
||||
mkdir $out
|
||||
cp radkfile_utf8 $out
|
||||
'';
|
||||
|
||||
meta = edrdgMetadata // {
|
||||
|
@ -131,13 +133,20 @@
|
|||
};
|
||||
};
|
||||
|
||||
database_generator = (nix-dart.builders.${system}.buildDartPackage {
|
||||
database_generator = let
|
||||
buildDartPackage = nix-dart.builders.${system}.buildDartPackage.override {
|
||||
dart = nix-dart.packages.${system}.dart-dev;
|
||||
};
|
||||
in buildDartPackage {
|
||||
pname = "database_generator";
|
||||
version = "1.0";
|
||||
|
||||
buildInputs = [ nix-dart.packages.${system}.dart-dev ];
|
||||
|
||||
src = builtins.filterSource (path: type: baseNameOf path != ".dart_tool") ./.;
|
||||
|
||||
preBuild = ''
|
||||
dart --version
|
||||
'';
|
||||
|
||||
specFile = ./pubspec.yaml;
|
||||
lockFile = ./pub2nix.lock;
|
||||
}).overrideAttrs(old: {
|
||||
|
@ -148,16 +157,20 @@
|
|||
database = mkDerivation {
|
||||
name = "database";
|
||||
src = builtins.filterSource (path: type: baseNameOf path != dbName) ./.;
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
sqlite
|
||||
self.packages.${system}.database_generator
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
mkdir -p data
|
||||
ln -s ${self.packages.${system}.JMdict}/* data
|
||||
ln -s ${self.packages.${system}.RADKFILE} data
|
||||
ln -s ${self.packages.${system}.RADKFILE}/* data
|
||||
|
||||
sqlite3 ${dbName} < migrations/0001_initial.sql
|
||||
sqlite3 ${dbName} < migrations/0002_insert_info_values.sql
|
||||
|
||||
ja_db ${pkgs.sqlite.out}/lib/libsqlite3.so
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
|
|
Loading…
Reference in New Issue