{"id":15365436,"url":"https://github.com/epiphone/serverless-nim","last_synced_at":"2025-04-15T07:31:16.650Z","repository":{"id":42301146,"uuid":"227616202","full_name":"epiphone/serverless-nim","owner":"epiphone","description":"Serverless Framework Nim language plugin","archived":false,"fork":false,"pushed_at":"2023-01-24T01:11:49.000Z","size":1442,"stargazers_count":20,"open_issues_count":11,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T18:49:36.498Z","etag":null,"topics":["aws-lambda","nim","nim-web","serverless","serverless-framework"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/epiphone.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-12T13:42:00.000Z","updated_at":"2024-05-29T18:43:34.000Z","dependencies_parsed_at":"2023-01-24T02:45:30.109Z","dependency_job_id":null,"html_url":"https://github.com/epiphone/serverless-nim","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiphone%2Fserverless-nim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiphone%2Fserverless-nim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiphone%2Fserverless-nim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiphone%2Fserverless-nim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/epiphone","download_url":"https://codeload.github.com/epiphone/serverless-nim/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249026763,"owners_count":21200504,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda","nim","nim-web","serverless","serverless-framework"],"created_at":"2024-10-01T13:14:45.952Z","updated_at":"2025-04-15T07:31:16.255Z","avatar_url":"https://github.com/epiphone.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Serverless Nim plugin\n[![npm version](https://badge.fury.io/js/%40epiphone%2Fserverless-nim.svg)](https://badge.fury.io/js/%40epiphone%2Fserverless-nim)\n\nEasier builds/packaging for Nim Lambda functions on the AWS `provided` runtime.\n\n- Compile Nim functions automatically on serverless workflow commands such as `deploy` or `package` - no need for a manual build step\n- Choose between local or dockerized builds ([see below](#build-in-docker))\n\nBuilt upon [lambci/awslambda.nim](https://github.com/lambci/awslambda.nim), adapted from [softprops/serverless-rust](https://github.com/softprops/serverless-rust/).\n\nCheck the **sample project** at https://github.com/epiphone/serverless-nim-sample.\n\n## Setup\n\n### Template\n\nThe easiest way to get started is via [the template](https://github.com/epiphone/serverless-nim-template):\n\n```bash\nserverless create --template-url https://github.com/epiphone/serverless-nim-template --path my-service-path --name my-service\n\ncd my-service-path\n\nyarn install # or npm install\n\nserverless deploy\n```\n\nAlternatively try cloning the sample project from https://github.com/epiphone/serverless-nim-sample.\n\n### Manual setup\n\nFirst install the NPM dependency with\n\n```bash\nyarn add @epiphone/serverless-nim\n```\n\nand then include the following configuration in  `serverless.yml`:\n\n```yaml\nprovider:\n  name: aws\n  runtime: nim # or use function-specific runtime option\n\npackage:\n  excludeDevDependencies: false # Not necessary, but speeds up builds since dev dependencies are anyway ignored in case of Nim functions\n  individually: true\n\nplugins:\n  - \"@epiphone/serverless-nim\" # Note the parenthesis\n```\n\nYou also need set up a `.nimble` file with the [`awslambda`](https://github.com/lambci/awslambda.nim) dependency to integrate Nim functions with the custom Lambda runtime.\n\n## Configuration\n\n### Compile flags\n\nUse the `nim.flags` configuration property to set `nimble compile` command flags (defaults to `['-d:release']`):\n\n```yaml\n# either globally:\ncustom:\n  nim:\n    flags:\n      - -d:unsafe\n\n# or per individual function:\nfunctions:\n  myFunction:\n    nim:\n      flags:\n        - -d:unsafe\n    ...\n```\n\n### Build in Docker\n\nDepending on your OS you might want to build Nim functions inside a Docker container to better match the Lambda runtime. Use the following configuration properties to achieve this:\n\n```yaml\ncustom:\n  nim:\n    dockerFlags: [] # defaults to []\n    dockerTag: nimlang/nim # defaults to nimlang/nim\n    useDocker: true # defaults to false\n```\n\nOne way to speed up Docker builds is to mount your local `~/.nimble` folder as a Docker volume and thus avoid re-fetching dependencies for every Nim function build:\n\n```yaml\ncustom:\n  nim:\n    dockerFlags:\n      - -v\n      - /home/user/.nimble/pkgs:/root/.nimble/pkgs\n      - -v\n      - /home/user/.nimble/packages_official.json:/root/.nimble/packages_official.json\n    useDocker: true\n```\n\n### Include files in Lambda package\n\n`serverless-nim` overrides Nim functions packaging configuration with the following configuration:\n\n```yaml\nexclude:\n  - '**/*'\ninclude:\n  - bootstrap\n```\n\nIf you want to include other files such as static assets in the package, use the [`include` configuration in `serverless.yml`](https://serverless.com/framework/docs/providers/aws/guide/packaging/#exclude--include):\n\n```yaml\n# either globally:\npackage:\n  include:\n    - assets/configuration.json\n\n# or per individual function:\nfunctions:\n  myFunction:\n    package:\n      include:\n        - assets/configuration.json\n```\n\nThe Nim binary gets automatically included in the package.\n\n### Optimize binary size\n\nNim compiler already produces pretty compact binaries, but the output can be further minimized with the `--opt:size` compiler flag or with external tools like `strip` or `upx`. The easiest way to enable all these is to add [this `config.nims` Nimscript file](https://github.com/epiphone/serverless-nim-sample/blob/master/config.nims) to your service root directory. You'll also of course need to install the external tools, or if building in Docker make sure the Docker image contains the tools.\n\nRead more about optimizing binary size [here](https://scripter.co/nim-deploying-static-binaries/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepiphone%2Fserverless-nim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fepiphone%2Fserverless-nim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepiphone%2Fserverless-nim/lists"}