From aee22b6b522f5dce96aa15f51cd5d1d106d42b49 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Tue, 7 Apr 2026 16:21:51 +0900 Subject: [PATCH] Add flake.nix --- .gitignore | 2 + flake.lock | 26 ++++++++++++ flake.nix | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 .gitignore create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..750baeb --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +result +result-* diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..cdb1c6c --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1775423009, + "narHash": "sha256-vPKLpjhIVWdDrfiUM8atW6YkIggCEKdSAlJPzzhkQlw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "68d8aa3d661f0e6bd5862291b5bb263b2a6595c9", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..dd1a26a --- /dev/null +++ b/flake.nix @@ -0,0 +1,115 @@ +{ + inputs = { + nixpkgs.url = "nixpkgs/nixos-unstable"; + }; + + outputs = { self, nixpkgs }: let + inherit (nixpkgs) lib; + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + "armv7l-linux" + ]; + + forAllSystems = f: lib.genAttrs systems (system: f system nixpkgs.legacyPackages.${system}); + in { + packages = let + edrdgMetadata = { + license = [{ + shortName = "EDRDG"; + fullName = "Electronic Dictionary Research and Development Group General Dictionary Licence"; + url = "http://www.csse.monash.edu.au/~jwb/edrdg/licence.html"; + }]; + maintainers = [ lib.maintainers.h7x4 ]; + platforms = lib.platforms.all; + }; + in forAllSystems (system: pkgs: { + jmdict = pkgs.stdenvNoCC.mkDerivation { + pname = "jmdict"; + version = lib.fileContents ./jmdict/version.txt; + + dontUnpack = true; + dontBuild = true; + installPhase = '' + runHook preInstall + + install -Dm644 -t "$out" ${./jmdict/jmdict.xml} + + runHook postInstall + ''; + + meta = edrdgMetadata // { + description = "A Japanese-Multilingual Dictionary providing lexical data for japanese words"; + homepage = "https://www.edrdg.org/jmdict/j_jmdict.html"; + }; + }; + + kanjidic2 = pkgs.stdenvNoCC.mkDerivation { + pname = "kanjidic2"; + version = lib.fileContents ./kanjidic2/version.txt; + + dontUnpack = true; + dontBuild = true; + installPhase = '' + runHook preInstall + + install -Dm644 -t "$out" ${./kanjidic2/kanjidic2.xml} + + runHook postInstall + ''; + + meta = edrdgMetadata // { + description = "A consolidated XML-format kanji database"; + homepage = "https://www.edrdg.org/kanjidic/kanjd2index_legacy.html"; + }; + }; + + radkfile = pkgs.stdenvNoCC.mkDerivation { + pname = "radkfile"; + version = lib.fileContents ./radkfile/version.txt; + + dontUnpack = true; + dontBuild = true; + installPhase = '' + runHook preInstall + + install -Dm644 -t "$out" ${./radkfile/radkfile} + + runHook postInstall + ''; + + meta = edrdgMetadata // { + description = "A file providing searchable decompositions of kanji characters"; + homepage = "https://www.edrdg.org/krad/kradinf.html"; + }; + }; + + tanos-jlpt = pkgs.stdenvNoCC.mkDerivation { + pname = "tanos-jlpt"; + version = "2011"; + + dontUnpack = true; + dontBuild = true; + installPhase = '' + runHook preInstall + + for f in ${./tanos-jlpt}/*.csv; do + install -Dm644 -t "$out" "$f" + done + + runHook postInstall + ''; + + meta = { + description = "A CSV file containing JLPT-rated Japanese vocabulary"; + homepage = "https://www.tanos.co.uk/jlpt/"; + license = lib.licenses.cc-by-40; + maintainers = [ lib.maintainers.h7x4 ]; + platforms = lib.platforms.all; + }; + }; + }); + }; +}