|
| 1 | +# Legacy API |
| 2 | +In earlier versions of nix-prisma-utils the API was more like a factory pattern. |
| 3 | +This API still works, but is now deprecated and we recommend switching to the new API. |
| 4 | +We still try to support the legacy API for backwards compatibility, though. |
| 5 | + |
| 6 | +## Using `npm` |
| 7 | + |
| 8 | +```nix |
| 9 | +{ |
| 10 | + inputs = { |
| 11 | + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; |
| 12 | + prisma-utils.url = "github:VanCoding/nix-prisma-utils"; |
| 13 | + }; |
| 14 | +
|
| 15 | + outputs = |
| 16 | + { nixpkgs, prisma-utils, ... }: |
| 17 | + let |
| 18 | + system = "x86_64-linux"; |
| 19 | + pkgs = nixpkgs.legacyPackages.${system}; |
| 20 | + prisma = |
| 21 | + (prisma-utils.lib.prisma-factory { |
| 22 | + inherit pkgs; |
| 23 | + # just copy these hashes for now, and then change them when nix complains about the mismatch |
| 24 | + prisma-fmt-hash = "sha256-4zsJv0PW8FkGfiiv/9g0y5xWNjmRWD8Q2l2blSSBY3s="; |
| 25 | + query-engine-hash = "sha256-6ILWB6ZmK4ac6SgAtqCkZKHbQANmcqpWO92U8CfkFzw="; |
| 26 | + libquery-engine-hash = "sha256-n9IimBruqpDJStlEbCJ8nsk8L9dDW95ug+gz9DHS1Lc="; |
| 27 | + schema-engine-hash = "sha256-j38xSXOBwAjIdIpbSTkFJijby6OGWCoAx+xZyms/34Q="; |
| 28 | + }).fromNpmLock |
| 29 | + ./package-lock.json; # <--- path to our package-lock.json file that contains the version of prisma-engines |
| 30 | + in |
| 31 | + { |
| 32 | + devShells.${system}.default = pkgs.mkShell { |
| 33 | + env = prisma.env; |
| 34 | + # or, you can use `shellHook` instead of `env` to load the same environment variables. |
| 35 | + # shellHook = prisma.shellHook; |
| 36 | + }; |
| 37 | + }; |
| 38 | +} |
| 39 | +
|
| 40 | +``` |
| 41 | + |
| 42 | +## Using `yarn` |
| 43 | + |
| 44 | +both yarn v1 and yarn-berry should work. |
| 45 | + |
| 46 | +```nix |
| 47 | +{ |
| 48 | + inputs = { |
| 49 | + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; |
| 50 | + prisma-utils.url = "github:VanCoding/nix-prisma-utils"; |
| 51 | + }; |
| 52 | +
|
| 53 | + outputs = |
| 54 | + { nixpkgs, prisma-utils, ... }: |
| 55 | + let |
| 56 | + system = "x86_64-linux"; |
| 57 | + pkgs = nixpkgs.legacyPackages.${system}; |
| 58 | + prisma = |
| 59 | + (prisma-utils.lib.prisma-factory { |
| 60 | + inherit pkgs; |
| 61 | + # just copy these hashes for now, and then change them when nix complains about the mismatch |
| 62 | + prisma-fmt-hash = "sha256-4zsJv0PW8FkGfiiv/9g0y5xWNjmRWD8Q2l2blSSBY3s="; |
| 63 | + query-engine-hash = "sha256-6ILWB6ZmK4ac6SgAtqCkZKHbQANmcqpWO92U8CfkFzw="; |
| 64 | + libquery-engine-hash = "sha256-n9IimBruqpDJStlEbCJ8nsk8L9dDW95ug+gz9DHS1Lc="; |
| 65 | + schema-engine-hash = "sha256-j38xSXOBwAjIdIpbSTkFJijby6OGWCoAx+xZyms/34Q="; |
| 66 | + }).fromYarnLock |
| 67 | + ./yarn.lock; # <--- path to our yarn.lock file that contains the version of prisma-engines |
| 68 | + in |
| 69 | + { |
| 70 | + devShells.${system}.default = pkgs.mkShell { |
| 71 | + shellHook = prisma.shellHook; |
| 72 | + }; |
| 73 | + }; |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +## Using `pnpm` |
| 78 | + |
| 79 | +```nix |
| 80 | +{ |
| 81 | + inputs = { |
| 82 | + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; |
| 83 | + prisma-utils.url = "github:VanCoding/nix-prisma-utils"; |
| 84 | + }; |
| 85 | +
|
| 86 | + outputs = |
| 87 | + { nixpkgs, prisma-utils, ... }: |
| 88 | + let |
| 89 | + system = "x86_64-linux"; |
| 90 | + pkgs = nixpkgs.legacyPackages.${system}; |
| 91 | + prisma = |
| 92 | + (prisma-utils.lib.prisma-factory { |
| 93 | + inherit pkgs; |
| 94 | + # just copy these hashes for now, and then change them when nix complains about the mismatch |
| 95 | + prisma-fmt-hash = "sha256-4zsJv0PW8FkGfiiv/9g0y5xWNjmRWD8Q2l2blSSBY3s="; |
| 96 | + query-engine-hash = "sha256-6ILWB6ZmK4ac6SgAtqCkZKHbQANmcqpWO92U8CfkFzw="; |
| 97 | + libquery-engine-hash = "sha256-n9IimBruqpDJStlEbCJ8nsk8L9dDW95ug+gz9DHS1Lc="; |
| 98 | + schema-engine-hash = "sha256-j38xSXOBwAjIdIpbSTkFJijby6OGWCoAx+xZyms/34Q="; |
| 99 | + }).fromPnpmLock |
| 100 | + ./pnpm-lock.yaml; # <--- path to our pnpm-lock.yaml file that contains the version of prisma-engines |
| 101 | + in |
| 102 | + { |
| 103 | + devShells.${system}.default = pkgs.mkShell { |
| 104 | + env = prisma.env; |
| 105 | + # or, you can use `shellHook` instead of `env` to load the same environment variables. |
| 106 | + # shellHook = prisma.shellHook; |
| 107 | + }; |
| 108 | + }; |
| 109 | +} |
| 110 | +
|
| 111 | +``` |
| 112 | + |
| 113 | +## Using `bun` |
| 114 | + |
| 115 | +```nix |
| 116 | +{ |
| 117 | + inputs = { |
| 118 | + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; |
| 119 | + prisma-utils.url = "github:VanCoding/nix-prisma-utils"; |
| 120 | + }; |
| 121 | +
|
| 122 | + outputs = |
| 123 | + { nixpkgs, prisma-utils, ... }: |
| 124 | + let |
| 125 | + system = "x86_64-linux"; |
| 126 | + pkgs = nixpkgs.legacyPackages.${system}; |
| 127 | + prisma = |
| 128 | + (prisma-utils.lib.prisma-factory { |
| 129 | + inherit pkgs; |
| 130 | + # just copy these hashes for now, and then change them when nix complains about the mismatch |
| 131 | + prisma-fmt-hash = "sha256-4zsJv0PW8FkGfiiv/9g0y5xWNjmRWD8Q2l2blSSBY3s="; |
| 132 | + query-engine-hash = "sha256-6ILWB6ZmK4ac6SgAtqCkZKHbQANmcqpWO92U8CfkFzw="; |
| 133 | + libquery-engine-hash = "sha256-n9IimBruqpDJStlEbCJ8nsk8L9dDW95ug+gz9DHS1Lc="; |
| 134 | + schema-engine-hash = "sha256-j38xSXOBwAjIdIpbSTkFJijby6OGWCoAx+xZyms/34Q="; |
| 135 | + }).fromBunLock |
| 136 | + ./bun.lock; # <--- path to our bun.lock file that contains the version of prisma-engines. |
| 137 | + # NOTE: does not work with bun.lockb! |
| 138 | + in |
| 139 | + { |
| 140 | + devShells.${system}.default = pkgs.mkShell { |
| 141 | + env = prisma.env; |
| 142 | + # or, you can use `shellHook` instead of `env` to load the same environment variables. |
| 143 | + # shellHook = prisma.shellHook; |
| 144 | + }; |
| 145 | + }; |
| 146 | +} |
| 147 | +``` |
0 commit comments