From 073d6f426dbf2970ba198ae1b292ea0b79c4b11f Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 22 Jun 2026 20:55:42 +0900 Subject: feat(mo): init at 1.6.1 --- default.nix | 1 + pkgs/hgrep/default.nix | 2 +- pkgs/mo/default.nix | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 pkgs/mo/default.nix diff --git a/default.nix b/default.nix index 65d7bdb..9cb84b3 100644 --- a/default.nix +++ b/default.nix @@ -4,6 +4,7 @@ { claude-code = pkgs.callPackage ./pkgs/claude-code { }; hgrep = pkgs.callPackage ./pkgs/hgrep { }; + mo = pkgs.callPackage ./pkgs/mo { }; git-helpers = pkgs.callPackage ./pkgs/git-helpers { }; nvim-setcellwidths-table-for-udev-gothic = diff --git a/pkgs/hgrep/default.nix b/pkgs/hgrep/default.nix index ed4c531..33f986d 100644 --- a/pkgs/hgrep/default.nix +++ b/pkgs/hgrep/default.nix @@ -47,7 +47,7 @@ rustPlatform.buildRustPackage rec { ''; meta = { - description = "hgrep is a grep tool with human-friendly search output. This is similar to `-C` option of `grep` command, but its output is enhanced with syntax highlighting focusing on human readable outputs."; + description = "Grep tool with human-friendly search output. This is similar to `-C` option of `grep` command, but its output is enhanced with syntax highlighting focusing on human readable outputs."; homepage = "https://github.com/rhysd/hgrep"; changelog = "https://github.com/rhysd/hgrep/raw/v${version}/CHANGELOG.md"; license = lib.licenses.mit; diff --git a/pkgs/mo/default.nix b/pkgs/mo/default.nix new file mode 100644 index 0000000..9f62deb --- /dev/null +++ b/pkgs/mo/default.nix @@ -0,0 +1,97 @@ +{ + lib, + stdenvNoCC, + buildGoModule, + fetchFromGitHub, + fetchPnpmDeps, + jq, + nodejs_22, + pnpm_10, + pnpmConfigHook, +}: + +let + version = "1.6.1"; + + src = fetchFromGitHub { + owner = "k1LoW"; + repo = "mo"; + rev = "v${version}"; + hash = "sha256-/PiMYllj0l3XwIkqT/sc7U/vGXdNmTD8RowZWe9ZDR8="; + }; + + frontend = stdenvNoCC.mkDerivation (finalAttrs: { + pname = "mo-frontend"; + inherit version src; + sourceRoot = "${src.name}/internal/frontend"; + + nativeBuildInputs = [ + jq + nodejs_22 + pnpm_10 + pnpmConfigHook + ]; + + # Remove .pnpm.executionEnv to prevent pnpm from downloading Node.js binary. + # Drop pnpm's executionEnv.nodeVersion pin. With it set, pnpm insists on + # managing its own Node.js and downloads it from nodejs.org at build time + # (which fails offline) -- it does this even when the pinned version equals + # the Node.js already on PATH, so matching the version does not help. Remove + # the pin instead and let pnpm use the nixpkgs Node.js from nativeBuildInputs. + postPatch = '' + jq 'del(.pnpm.executionEnv)' package.json > package.json.tmp + mv package.json.tmp package.json + + chmod -R u+w ../static + ''; + + pnpmDeps = fetchPnpmDeps { + inherit (finalAttrs) + pname + version + src + sourceRoot + ; + pnpm = pnpm_10; + fetcherVersion = 3; + hash = "sha256-473ftja7cEzU/FrMN2xti/ChZ/j2KGhb8Gk+TIa+Pv8="; + }; + + buildPhase = '' + runHook preBuild + pnpm run build + runHook postBuild + ''; + + # vite emits to ../static/dist. + installPhase = '' + runHook preInstall + cp -r ../static/dist $out + runHook postInstall + ''; + }); +in +buildGoModule { + pname = "mo"; + inherit version src; + + vendorHash = "sha256-rmtJswO3DWWxpb2uk91aIatc7ugNmsqzwlEeKdX7ITE="; + + preBuild = '' + cp -r ${frontend} internal/static/dist + ''; + + ldflags = [ + "-s" + "-w" + "-X github.com/k1LoW/mo/version.Revision=v${version}" + ]; + + meta = { + description = "Markdown viewer that opens .md files in a browser"; + homepage = "https://github.com/k1LoW/mo"; + changelog = "https://github.com/k1LoW/mo/raw/v${version}/CHANGELOG.md"; + license = lib.licenses.mit; + mainProgram = "mo"; + }; +} -- cgit v1.3.1