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