Created
May 14, 2026 09:15
-
-
Save mausch/26506e6ba0c588e02b763ffef6b500c8 to your computer and use it in GitHub Desktop.
difit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| description = "Standalone flake for yoshiko-pg/difit"; | |
| inputs = { | |
| nixpkgs.url = "github:NixOS/nixpkgs/da5ad661ba4e5ef59ba743f0d112cbc30e474f32"; | |
| }; | |
| outputs = | |
| { self, nixpkgs }: | |
| let | |
| lib = nixpkgs.lib; | |
| systems = [ | |
| "x86_64-linux" | |
| "aarch64-linux" | |
| "x86_64-darwin" | |
| "aarch64-darwin" | |
| ]; | |
| forAllSystems = lib.genAttrs systems; | |
| in | |
| { | |
| packages = forAllSystems ( | |
| system: | |
| let | |
| pkgs = import nixpkgs { inherit system; }; | |
| pnpmPkg = pkgs.pnpm_10 or pkgs.pnpm; | |
| difit = pkgs.stdenv.mkDerivation (finalAttrs: { | |
| pname = "difit"; | |
| version = "5.0.0"; | |
| src = pkgs.fetchFromGitHub { | |
| owner = "yoshiko-pg"; | |
| repo = "difit"; | |
| tag = "v${finalAttrs.version}"; | |
| hash = "sha256-4YFja6wQmWfRlUmXnUwxAO2IF9T17azNEXn5X4i+YMc="; | |
| }; | |
| pnpmDeps = pkgs.fetchPnpmDeps { | |
| inherit (finalAttrs) pname version src; | |
| pnpm = pnpmPkg; | |
| fetcherVersion = 3; | |
| hash = "sha256-EIugUnOyVDZ7tWXeoUdYcp0q4xaEKeC+Hx3yIL0UGbs="; | |
| }; | |
| nativeBuildInputs = [ | |
| pkgs.nodejs | |
| pkgs.pnpmConfigHook | |
| pnpmPkg | |
| pkgs.makeWrapper | |
| ]; | |
| postPatch = '' | |
| ${pkgs.jq}/bin/jq 'del(.scripts.prepare)' package.json > package.json.tmp | |
| mv package.json.tmp package.json | |
| ''; | |
| buildPhase = '' | |
| runHook preBuild | |
| pnpm build | |
| CI=true pnpm prune --prod | |
| find node_modules -xtype l -delete | |
| rm -f node_modules/.modules.yaml | |
| runHook postBuild | |
| ''; | |
| installPhase = '' | |
| runHook preInstall | |
| appdir="$out/lib/difit" | |
| mkdir -p "$appdir" "$out/bin" | |
| cp -r dist node_modules package.json "$appdir"/ | |
| find "$appdir/node_modules" -xtype l -delete | |
| makeWrapper ${pkgs.nodejs}/bin/node "$out/bin/difit" \ | |
| --add-flags "$appdir/dist/cli/index.js" \ | |
| --set NODE_PATH "$appdir/node_modules" \ | |
| --prefix PATH : ${lib.makeBinPath [ pkgs.git ]} | |
| runHook postInstall | |
| ''; | |
| nativeInstallCheckInputs = [ pkgs.versionCheckHook ]; | |
| doInstallCheck = true; | |
| versionCheckProgramArg = "--version"; | |
| meta = { | |
| description = "CLI tool to view local git diffs in a GitHub-style web viewer"; | |
| homepage = "https://github.com/yoshiko-pg/difit"; | |
| changelog = "https://github.com/yoshiko-pg/difit/releases/tag/v${finalAttrs.version}"; | |
| license = lib.licenses.mit; | |
| mainProgram = "difit"; | |
| platforms = lib.platforms.unix; | |
| }; | |
| }); | |
| in | |
| { | |
| default = difit; | |
| difit = difit; | |
| } | |
| ); | |
| apps = forAllSystems (system: { | |
| default = { | |
| type = "app"; | |
| program = "${self.packages.${system}.default}/bin/difit"; | |
| }; | |
| }); | |
| }; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/yoshiko-pg/difit