Changes
13 changed files (+544/-14)
-
-
@@ -37,3 +37,13 @@ indent_size = 2[*.nix] indent_style = space indent_size = 2 # elm-format は 2 スペース以外の指定ができない。 [*.elm] indent_style = space indent_size = 4 # Zig は正しくタブ文字を扱えない。 [*.zig] indent_style = space indent_size = 4
-
-
-
@@ -37,3 +37,12 @@ override.tf.json# 雑すぎる名前な上カレントディレクトリに吐かれ、変更するためには # 都度 CLI オプションを指定する必要がある。 result # What: Elm の公式ツール群が利用するキャッシュやらのディレクトリ。 elm-stuff # What: Zig のビルドキャッシュディレクトリ。 .zig-cache # What: Zig のビルド成果物。 zig-out
-
-
demo/Caddyfile (new)
-
@@ -0,0 +1,20 @@# SPDX-License-Identifier: AGPL-3.0-only # Copyright 2026 Shota FUJI # # This program is free software: you can redistribute it and/or modify it under the terms # of the GNU Affero General Public License as published by the Free Software Foundation, # either version 3 of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License along # with this program. If not, see <http://www.gnu.org/licenses/>. :8080 { encode root * zig-out try_files {path} /index.html file_server }
-
-
demo/build.zig (new)
-
@@ -0,0 +1,57 @@// SPDX-License-Identifier: AGPL-3.0-only // Copyright 2026 Shota FUJI // // This program is free software: you can redistribute it and/or modify it under the terms // of the GNU Affero General Public License as published by the Free Software Foundation, // either version 3 of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A // PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License along // with this program. If not, see <http://www.gnu.org/licenses/>. const std = @import("std"); const Elm = @import("./build/Elm.zig"); pub fn build(b: *std.Build) !void { const optimize = b.standardOptimizeOption(.{}); const elm_main = elm_main: { const compile = Elm.init(b, .{ .optimize = optimize, }); compile.addElmSourceFile(b.path("src/Main.elm")); break :elm_main compile.output_js; }; const index_html = index_html: { const html = b.path("src/index.html"); break :index_html html; }; const dist = dist: { const dir = b.addWriteFiles(); _ = dir.addCopyFile(index_html, "index.html"); _ = dir.addCopyFile(elm_main, "main.js"); break :dist dir; }; // デフォルトインストール { const install = b.addInstallDirectory(.{ .source_dir = dist.getDirectory(), .install_dir = .{ .custom = "" }, .install_subdir = "", }); b.default_step.dependOn(&install.step); } }
-
-
demo/build/Elm.zig (new)
-
@@ -0,0 +1,80 @@// SPDX-License-Identifier: AGPL-3.0-only // Copyright 2026 Shota FUJI // // This program is free software: you can redistribute it and/or modify it under the terms // of the GNU Affero General Public License as published by the Free Software Foundation, // either version 3 of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A // PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License along // with this program. If not, see <http://www.gnu.org/licenses/>. //! Elm ファイルを JS にコンパイルするモジュール。 //! //! ```zig //! // 利用例 //! const Elm = @import("./build/Elm.zig"); //! //! const elm = Elm.init(b, .{ //! .optimize = optimize, //! }); //! //! elm.addElmSourceFile(b.path("src/Main.elm")); //! //! const install_js = b.installFile(elm.output_js, "elm.js"); //! ``` const Elm = @This(); const std = @import("std"); elm_make: *std.Build.Step.Run, output_js: std.Build.LazyPath, const InitOptions = struct { /// 最適化モード。 /// /// * `Debug` ... Elm のデバッガー UI が有効になる。 /// * `Release*` ... 出力される JS ファイルが最小化・最適化される。 optimize: std.builtin.OptimizeMode, }; pub fn init(b: *std.Build, opts: InitOptions) Elm { const elm_make = b.addSystemCommand(&.{ "elm", "make" }); if (opts.optimize == .Debug) { elm_make.addArg("--debug"); } else { elm_make.addArg("--optimize"); } elm_make.expectExitCode(0); const output_js = elm_make.addPrefixedOutputFileArg("--output=", "elm.js"); if (opts.optimize == .Debug) { return .{ .elm_make = elm_make, .output_js = output_js, }; } else { const closure_compiler = b.addSystemCommand(&.{"closure-compiler"}); closure_compiler.addPrefixedFileArg("--js=", output_js); const minified_js = closure_compiler.addPrefixedOutputFileArg("--js_output_file=", "elm.min.js"); return .{ .elm_make = elm_make, .output_js = minified_js, }; } } /// コンパイルする Elm のソースコードを追加する。 /// `main` のあるエントリーポイント以外のファイルも追加する必要がある。 pub fn addElmSourceFile(self: Elm, path: std.Build.LazyPath) void { self.elm_make.addFileArg(path); }
-
-
demo/default.nix (new)
-
@@ -0,0 +1,56 @@# SPDX-License-Identifier: AGPL-3.0-only # Copyright 2026 Shota FUJI # # This program is free software: you can redistribute it and/or modify it under the terms # of the GNU Affero General Public License as published by the Free Software Foundation, # either version 3 of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License along # with this program. If not, see <http://www.gnu.org/licenses/>. { mkElmDerivation, lib, closurecompiler, elmPackages, swc, zig, }: mkElmDerivation { name = "yamori-demo"; nativeBuildInputs = [ # > Delightful language for reliable webapps # https://elm-lang.org/ elmPackages.elm # > Tool for making JavaScript download and run faster # https://developers.google.com/closure/compiler/ closurecompiler # > General-purpose programming language and toolchain for maintaining robust, # > optimal, and reusable software # https://ziglang.org/ zig ]; src = with lib.fileset; toSource { root = ./.; fileset = unions [ ./src ./build.zig ./build ./elm.json ]; }; buildPhase = '' zig build "-j$NIX_BUILD_CORES" -Doptimize=ReleaseFast --prefix $out ''; }
-
-
demo/elm.json (new)
-
@@ -0,0 +1,22 @@{ "type": "application", "source-directories": ["src"], "elm-version": "0.19.1", "dependencies": { "direct": { "elm/browser": "1.0.2", "elm/core": "1.0.5", "elm/html": "1.0.1", "elm/url": "1.0.0" }, "indirect": { "elm/json": "1.1.4", "elm/time": "1.0.0", "elm/virtual-dom": "1.0.5" } }, "test-dependencies": { "direct": {}, "indirect": {} } }
-
-
demo/elm.json.license (new)
-
@@ -0,0 +1,2 @@SPDX-License-Identifier: AGPL-3.0-only SPDX-FileCopyrightText: 2026 Shota FUJI
-
-
demo/src/Main.elm (new)
-
@@ -0,0 +1,98 @@-- SPDX-License-Identifier: AGPL-3.0-only -- Copyright 2026 Shota FUJI -- -- This program is free software: you can redistribute it and/or modify it under the terms -- of the GNU Affero General Public License as published by the Free Software Foundation, -- either version 3 of the License, or (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, but WITHOUT ANY -- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -- PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. -- -- You should have received a copy of the GNU Affero General Public License along -- with this program. If not, see <http://www.gnu.org/licenses/>. module Main exposing (main) import Browser import Browser.Navigation import Html exposing (p, text) import Url main : Program Flags Model Msg main = Browser.application { init = init , view = view , update = update , subscriptions = subscriptions , onUrlChange = OnUrlChange , onUrlRequest = OnUrlRequest } -- FLAGS type alias Flags = () -- MODEL type alias Model = { name : String } init : Flags -> Url.Url -> Browser.Navigation.Key -> ( Model, Cmd Msg ) init _ _ _ = ( { name = "World" }, Cmd.none ) -- UPDATE type Msg = NoOp | OnUrlChange Url.Url | OnUrlRequest Browser.UrlRequest update : Msg -> Model -> ( Model, Cmd Msg ) update msg model = case msg of NoOp -> ( model, Cmd.none ) OnUrlChange _ -> ( model, Cmd.none ) OnUrlRequest _ -> ( model, Cmd.none ) -- VIEW view : Model -> Browser.Document Msg view model = { title = "Yamori デモ" , body = [ p [] [ text ("Hello, " ++ model.name ++ "!") ] ] } -- SUBSCRIPTIONS subscriptions : Model -> Sub Msg subscriptions _ = Sub.none
-
-
demo/src/index.html (new)
-
@@ -0,0 +1,17 @@<!DOCTYPE html> <!-- SPDX-FileCopyrightText: 2026 Shota FUJI <pockawoooh@gmail.com> SPDX-License-Identifier: AGPL-3.0-only --> <html lang="ja"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="color-scheme" content="light dark" /> <title>Yamori デモ</title> <script src="/main.js"></script> <script type="module"> Elm.Main.init(); </script> </head> </html>
-
-
-
@@ -36,6 +36,18 @@{ "exts": ["nix"], "command": "nixfmt --strict --width={{line_width}} --indent={{indent_width}}" }, { "exts": ["zig"], "command": "zig fmt --stdin" }, { "exts": ["zon"], "command": "zig fmt --zon --stdin" }, { "exts": ["elm"], "command": "elm-format --stdin" } ] },
-
@@ -45,6 +57,7 @@}, "markup": { "useTabs": true, "scriptIndent": true, "styleIndent": true }, "malva": {
-
-
-
@@ -1,5 +1,49 @@{ "nodes": { "elm-spa": { "inputs": { "nixpkgs": [ "mkElmDerivation", "nixpkgs" ] }, "locked": { "lastModified": 1706301604, "narHash": "sha256-n6LDjnPCTLbKTrRgeZhlLTfY6V45xNYcb4NYEMuO4jg=", "owner": "jeslie0", "repo": "elm-spa", "rev": "4c82e18d5fcf9d4c027f0ef0e89204dd87584f7f", "type": "github" }, "original": { "owner": "jeslie0", "repo": "elm-spa", "type": "github" } }, "elm-watch": { "inputs": { "nixpkgs": [ "mkElmDerivation", "nixpkgs" ], "npm-fix": "npm-fix", "npmlock2nix": "npmlock2nix" }, "locked": { "lastModified": 1706304401, "narHash": "sha256-992cypnhoRbsGkDc5/X241rafBML4EP0EuT6cBcaY/8=", "owner": "jeslie0", "repo": "elm-watch", "rev": "2f1c6c0e69b163c15e2ce66f543c38021b2a0ea3", "type": "github" }, "original": { "owner": "jeslie0", "repo": "elm-watch", "type": "github" } }, "flake-utils": { "inputs": { "systems": "systems"
-
@@ -18,6 +62,28 @@"type": "github" } }, "mkElmDerivation": { "inputs": { "elm-spa": "elm-spa", "elm-watch": "elm-watch", "nixpkgs": [ "nixpkgs" ] }, "locked": { "lastModified": 1769306638, "narHash": "sha256-++1aTjbdU64Mb/mQrT/gQ44cJBabmTi/fR5iMIcR5IE=", "owner": "jeslie0", "repo": "mkElmDerivation", "rev": "ab5affe77b6c94015e3a54f83f45e8f77a98518e", "type": "github" }, "original": { "owner": "jeslie0", "repo": "mkElmDerivation", "type": "github" } }, "nixpkgs": { "locked": { "lastModified": 1769527094,
-
@@ -34,9 +100,48 @@"type": "github" } }, "npm-fix": { "inputs": { "nixpkgs": [ "mkElmDerivation", "elm-watch", "nixpkgs" ] }, "locked": { "lastModified": 1706304213, "narHash": "sha256-XN9ESRSOANR0iFbEMMY1C1jvgZlYJsXQYVAHxxRmn+c=", "owner": "jeslie0", "repo": "npm-lockfile-fix", "rev": "e9851274afa12b04d98e694ed089aa9cde8d7349", "type": "github" }, "original": { "owner": "jeslie0", "repo": "npm-lockfile-fix", "type": "github" } }, "npmlock2nix": { "flake": false, "locked": { "lastModified": 1673447413, "narHash": "sha256-sJM82Sj8yfQYs9axEmGZ9Evzdv/kDcI9sddqJ45frrU=", "owner": "nix-community", "repo": "npmlock2nix", "rev": "9197bbf397d76059a76310523d45df10d2e4ca81", "type": "github" }, "original": { "owner": "nix-community", "repo": "npmlock2nix", "type": "github" } }, "root": { "inputs": { "flake-utils": "flake-utils", "mkElmDerivation": "mkElmDerivation", "nixpkgs": "nixpkgs" } },
-
-
-
@@ -16,6 +16,10 @@inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; flake-utils.url = "github:numtide/flake-utils"; mkElmDerivation = { url = "github:jeslie0/mkElmDerivation"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs =
-
@@ -23,14 +27,19 @@self, nixpkgs, flake-utils, mkElmDerivation, }: flake-utils.lib.eachDefaultSystem ( system: let pkgs = nixpkgs.legacyPackages.${system}; pkgs = import nixpkgs { overlays = [ mkElmDerivation.overlays.default ]; inherit system; }; in rec { packages = { demo = pkgs.callPackage ./demo { }; docs = pkgs.callPackage ./docs/package.nix { }; };
-
@@ -44,6 +53,10 @@# https://dprint.dev/ dprint # > A source code formatter for Elm # https://github.com/avh4/elm-format elmPackages.elm-format # Official formatter for Nix code # https://github.com/NixOS/nixfmt nixfmt
-
@@ -51,6 +64,8 @@# Tool for building, changing, and versioning infrastructure # https://opentofu.org/ opentofu zig ]; };
-
@@ -140,19 +155,45 @@}; devShell = pkgs.mkShell { packages = with pkgs; [ # Code formatting platform written in Rust # https://dprint.dev/ dprint # Official formatter for Nix code # https://github.com/NixOS/nixfmt nixfmt # Copyright and license linter based on SPDX # https://github.com/fsfe/reuse-tool reuse ]; packages = with pkgs; [ # Code formatting platform written in Rust # https://dprint.dev/ dprint # Official formatter for Nix code # https://github.com/NixOS/nixfmt nixfmt # Copyright and license linter based on SPDX # https://github.com/fsfe/reuse-tool reuse # > Language server implementation for Elm # https://github.com/elm-tooling/elm-language-server elmPackages.elm-language-server # > Zig LSP implementation + Zig Language Server # https://github.com/zigtools/zls zls # "demo" の "zig build serve" で利用する。 # > Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS # https://caddyserver.com/ caddy ] ++ packages.demo.nativeBuildInputs; # "pkgs.zig" が $ZIG_GLOBAL_CACHE_DIR を本来設定すべきでない状況でも設定するバグにより # zig のコマンドが権限エラーで起動しなくなる。以前は zig.hook を除外するだけでよかった # が、 zig.hook を "pkgs.zig" に含める PR が件のバグを放置したまま取り込まれたため利用 # 側で回避が必要となっている。 # https://github.com/NixOS/nixpkgs/issues/270415 # https://github.com/NixOS/nixpkgs/pull/473413 shellHook = '' unset ZIG_GLOBAL_CACHE_DIR ''; }; } );
-