Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat: add nix shell environments (#8329)
Kashife3233c67fc01
diff --git a/docs/try_local_system.md b/docs/try_local_system.mdindex 24ea5b9da6..5feedd4d7c 100644--- a/docs/try_local_system.md+++ b/docs/try_local_system.md@@ -127,17 +127,34 @@ This will start the following services using `process-compose`- Creates database and an user to be used by the application- Redis-### Develop in a Nix environment (coming soon)+### Develop in a Nix environment-Nix development environment ensures all the required project dependencies, including both the tools and services are readily available, eliminating the need for manual setup.+The Nix development environment, defined in `flake.nix`, provides a consistent and reproducible setup with all necessary dependencies for building and testing Hyperswitch.-Run below command in hyperswitch directory+**Available Development Shells:**+Hyperswitch offers three distinct Nix shells tailored for different activities:++1. **Default Shell (`hyperswitch-shell`):**```shell- nix develop+ nix develop```+ * **Purpose:** Minimal shell for compiling and running the server.+ * **Usage:** Within this shell, you can run DB migrations, compile and run different components. It uses MSRV of `rust` defined for the project.++2. **Development Shell (`hyperswitch-dev-shell`):**+ ```shell+ nix develop .#dev+ ```+ * **Purpose:** Extends the default shell with packages required during active development of the project.+ * **Usage:** Within this shell, you can run clippy checks and validate OpenAPI specs. This shell uses the latest version of `rust` at the time of commit.-**NOTE:** This is a work in progress, and only a selected commands are available at the moment. Look in `flake.nix` (hyperswitch-shell) for a full list of packages.+3. **QA Shell (`hyperswitch-qa-shell`):**+ ```shell+ nix develop .#qa+ ```+ * **Purpose:** Extends the default shell with tools specifically required for executing Cypress tests.+ * **Usage:** Within this shell, you can execute cypress tests. This also uses MSRV of `rust` defined in the project.## Set up a Rust environment and other dependenciesdiff --git a/flake.lock b/flake.lockindex 6bdae43576..36c888e7db 100644--- a/flake.lock+++ b/flake.lock@@ -8,11 +8,11 @@"rust-overlay": "rust-overlay"},"locked": {- "lastModified": 1655189312,- "narHash": "sha256-gpJ57OgIebUpO+7F00VltxSEy6dz2x6HeJ5BcRM8rDA=",+ "lastModified": 1742755793,+ "narHash": "sha256-nz3zSO5a/cB/XPcP4c3cddUceKH9V3LNMuNpfV3TDeE=","owner": "cargo2nix","repo": "cargo2nix",- "rev": "c149357cc3d17f2849c73eb7a09d07a307cdcfe8",+ "rev": "f7b2c744b1e6ee39c7b4528ea34f06db598266a6","type": "github"},"original": {@@ -25,11 +25,11 @@"flake-compat": {"flake": false,"locked": {- "lastModified": 1650374568,- "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",+ "lastModified": 1696426674,+ "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=","owner": "edolstra","repo": "flake-compat",- "rev": "b4a34015c698c7793d592d66adbab377907a2be8",+ "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33","type": "github"},"original": {@@ -43,11 +43,11 @@"nixpkgs-lib": "nixpkgs-lib"},"locked": {- "lastModified": 1675933616,- "narHash": "sha256-/rczJkJHtx16IFxMmAWu5nNYcSXNg1YYXTHoGjLrLUA=",+ "lastModified": 1749398372,+ "narHash": "sha256-tYBdgS56eXYaWVW3fsnPQ/nFlgWi/Z2Ymhyu21zVM98=","owner": "hercules-ci","repo": "flake-parts",- "rev": "47478a4a003e745402acf63be7f9a092d51b83d7",+ "rev": "9305fe4e5c2a6fcf5ba6a3ff155720fbe4076569","type": "github"},"original": {@@ -57,12 +57,15 @@}},"flake-utils": {+ "inputs": {+ "systems": "systems"+ },"locked": {- "lastModified": 1653893745,- "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",+ "lastModified": 1694529238,+ "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=","owner": "numtide","repo": "flake-utils",- "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",+ "rev": "ff7b65b44d01cf9ba6a71320833626af21126384","type": "github"},"original": {@@ -73,45 +76,42 @@},"nixpkgs": {"locked": {- "lastModified": 1654275867,- "narHash": "sha256-pt14ZE4jVPGvfB2NynGsl34pgXfOqum5YJNpDK4+b9E=",+ "lastModified": 1705099185,+ "narHash": "sha256-SxJenKtvcrKJd0TyJQMO3p6VA7PEp+vmMnmlKFzWMNs=","owner": "nixos","repo": "nixpkgs",- "rev": "7a20c208aacf4964c19186dcad51f89165dc7ed0",+ "rev": "2bce5ccff0ad7abda23e8bb56434b6877a446694","type": "github"},"original": {"owner": "nixos",- "ref": "release-22.05",+ "ref": "release-23.11","repo": "nixpkgs","type": "github"}},"nixpkgs-lib": {"locked": {- "dir": "lib",- "lastModified": 1675183161,- "narHash": "sha256-Zq8sNgAxDckpn7tJo7V1afRSk2eoVbu3OjI1QklGLNg=",- "owner": "NixOS",- "repo": "nixpkgs",- "rev": "e1e1b192c1a5aab2960bf0a0bd53a2e8124fa18e",+ "lastModified": 1748740939,+ "narHash": "sha256-rQaysilft1aVMwF14xIdGS3sj1yHlI6oKQNBRTF40cc=",+ "owner": "nix-community",+ "repo": "nixpkgs.lib",+ "rev": "656a64127e9d791a334452c6b6606d17539476e2","type": "github"},"original": {- "dir": "lib",- "owner": "NixOS",- "ref": "nixos-unstable",- "repo": "nixpkgs",+ "owner": "nix-community",+ "repo": "nixpkgs.lib","type": "github"}},"nixpkgs_2": {"locked": {- "lastModified": 1728888510,- "narHash": "sha256-nsNdSldaAyu6PE3YUA+YQLqUDJh+gRbBooMMekZJwvI=",+ "lastModified": 1749285348,+ "narHash": "sha256-frdhQvPbmDYaScPFiCnfdh3B/Vh81Uuoo0w5TkWmmjU=","owner": "NixOS","repo": "nixpkgs",- "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c",+ "rev": "3e3afe5174c561dee0df6f2c2b2236990146329f","type": "github"},"original": {@@ -123,11 +123,11 @@},"nixpkgs_3": {"locked": {- "lastModified": 1718428119,- "narHash": "sha256-WdWDpNaq6u1IPtxtYHHWpl5BmabtpmLnMAx0RdJ/vo8=",+ "lastModified": 1744536153,+ "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=","owner": "NixOS","repo": "nixpkgs",- "rev": "e6cea36f83499eb4e9cd184c8a8e823296b50ad5",+ "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11","type": "github"},"original": {@@ -139,11 +139,11 @@},"process-compose-flake": {"locked": {- "lastModified": 1728868941,- "narHash": "sha256-yEMzxZfy+EE9gSqn++SyZeAVHXYupFT8Wyf99Z/CXXU=",+ "lastModified": 1749418557,+ "narHash": "sha256-wJHHckWz4Gvj8HXtM5WVJzSKXAEPvskQANVoRiu2w1w=","owner": "Platonic-Systems","repo": "process-compose-flake",- "rev": "29301aec92d73c9b075fcfd06a6fb18665bfe6b5",+ "rev": "91dcc48a6298e47e2441ec76df711f4e38eab94e","type": "github"},"original": {@@ -174,11 +174,11 @@]},"locked": {- "lastModified": 1653878966,- "narHash": "sha256-T51Gck/vrJZi1m+uTbhEFTRgZmE59sydVONadADv358=",+ "lastModified": 1705112162,+ "narHash": "sha256-IAM0+Uijh/fwlfoeDrOwau9MxcZW3zeDoUHc6Z3xfqM=","owner": "oxalica","repo": "rust-overlay",- "rev": "8526d618af012a923ca116be9603e818b502a8db",+ "rev": "9e0af26ffe52bf955ad5575888f093e41fba0104","type": "github"},"original": {@@ -192,11 +192,11 @@"nixpkgs": "nixpkgs_3"},"locked": {- "lastModified": 1726626348,- "narHash": "sha256-sYV7e1B1yLcxo8/h+/hTwzZYmaju2oObNiy5iRI0C30=",+ "lastModified": 1749695868,+ "narHash": "sha256-debjTLOyqqsYOUuUGQsAHskFXH5+Kx2t3dOo/FCoNRA=","owner": "oxalica","repo": "rust-overlay",- "rev": "6fd52ad8bd88f39efb2c999cc971921c2fb9f3a2",+ "rev": "55f914d5228b5c8120e9e0f9698ed5b7214d09cd","type": "github"},"original": {@@ -207,11 +207,11 @@},"services-flake": {"locked": {- "lastModified": 1728811751,- "narHash": "sha256-IrwycNtt6jxJGCi+QJ8Bbzt9flg0vNeGLAR0KBbj4a8=",+ "lastModified": 1749343305,+ "narHash": "sha256-K4bK5OOJJlSWbJB7TbVzZQzJ694Qm7iGxOr0BpbqRpc=","owner": "juspay","repo": "services-flake",- "rev": "e9f663036f3b1b1a12b0f136628ef93a8be92443",+ "rev": "62ef1d7436e7f07667a9b979c95ac2f706fdf3bb","type": "github"},"original": {@@ -219,6 +219,21 @@"repo": "services-flake","type": "github"}+ },+ "systems": {+ "locked": {+ "lastModified": 1681028828,+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",+ "owner": "nix-systems",+ "repo": "default",+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",+ "type": "github"+ },+ "original": {+ "owner": "nix-systems",+ "repo": "default",+ "type": "github"+ }}},"root": "root",diff --git a/flake.nix b/flake.nixindex 9516d0c81a..e9bcb936d7 100644--- a/flake.nix+++ b/flake.nix@@ -20,27 +20,61 @@perSystem = { self', pkgs, lib, system, ... }:letcargoToml = lib.importTOML ./Cargo.toml;- rustVersion = cargoToml.workspace.package.rust-version;- frameworks = pkgs.darwin.apple_sdk.frameworks;+ rustDevVersion = "1.87.0";+ rustMsrv = cargoToml.workspace.package.rust-version;++ # Common packages+ base = with pkgs; [+ diesel-cli+ just+ jq+ openssl+ pkg-config+ postgresql # for libpq+ ];++ # Minimal packages for running hyperswitch+ runPackages = base ++ (with pkgs; [+ rust-bin.stable.${rustMsrv}.default+ ]);++ # Development packages+ devPackages = base ++ (with pkgs; [+ nixd+ rust-bin.stable.${rustDevVersion}.default+ swagger-cli+ ]);++ # QA packages+ qaPackages = devPackages ++ (with pkgs; [+ cypress+ nodejs+ parallel+ ]);+in{_module.args.pkgs = import inputs.nixpkgs {inherit system;overlays = [ inputs.cargo2nix.overlays.default (import inputs.rust-overlay) ];};++ # Minimal shelldevShells.default = pkgs.mkShell {name = "hyperswitch-shell";- packages = with pkgs; [- just- nixd- openssl- pkg-config- rust-bin.stable.${rustVersion}.default- ] ++ lib.optionals stdenv.isDarwin [- # arch might have issue finding these libs.- frameworks.CoreServices- frameworks.Foundation- ];+ packages = base;+ };++ # Development shell+ devShells.dev = pkgs.mkShell {+ name = "hyperswitch-dev-shell";+ packages = devPackages;+ };++ # QA development shell+ devShells.qa = pkgs.mkShell {+ name = "hyperswitch-qa-shell";+ packages = qaPackages;};/* For running external services