Skip to content

Commit

Permalink
add openapi-typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
lostbean committed Dec 6, 2023
1 parent 4b7741e commit ff18dbe
Show file tree
Hide file tree
Showing 4 changed files with 342 additions and 0 deletions.
4 changes: 4 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import ./nix-pkgs/grpc-tools-node.nix { inherit pkgs; };
protoc-gen-ts =
import ./nix-pkgs/protoc-gen-ts.nix { inherit pkgs; };
openapi-typescript =
# import ./nix-pkgs/openapi-typescript.nix { inherit pkgs; };
import ./nix-pkgs/openapi-ts { inherit pkgs; };
in [
goreleaser
go_1_20
Expand Down Expand Up @@ -50,6 +53,7 @@
# local definition (see above)
grpc-tools-node
protoc-gen-ts
openapi-typescript
];

shellHook = ''
Expand Down
37 changes: 37 additions & 0 deletions nix-pkgs/openapi-ts/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{ pkgs ? import <nixpkgs> { } }:
with pkgs;
let
pname = "openapi-typescript";
nodejs = pkgs.nodejs_18;

openapi-ts = pkgs.buildNpmPackage {
name = "${pname}_node_modules";

# The packages required by the build process
buildInputs = [ nodejs ];
dontNpmBuild = true;

# The code sources for the package
src = ./.;
npmDepsHash = "sha256-yZcriNNQnin0IHHypPq46gdMzdT5j3J2cs40NVldfwY=";

# How the output of the build phase
installPhase = ''
mkdir $out
cp -r node_modules/ $out
'';
};

openapi-ts-bin = pkgs.writeScript "${pname}_wrapper" ''
#! ${pkgs.stdenv.shell}
${nodejs}/bin/npm exec --prefix ${openapi-ts}/node_modules -- openapi-typescript "$@"
'';

in stdenv.mkDerivation {
name = pname;
src = ./.;
installPhase = ''
mkdir -p $out/bin
cp -r ${openapi-ts-bin} $out/bin/openapi-typescript
'';
}
293 changes: 293 additions & 0 deletions nix-pkgs/openapi-ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions nix-pkgs/openapi-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"devDependencies": {
"openapi-typescript": "^7.0.0-next.5"
},
"dependencies": {
"openapi-fetch": "^0.8.2"
}
}

0 comments on commit ff18dbe

Please sign in to comment.