{"id":16475884,"url":"https://github.com/welteki/faasd-nix","last_synced_at":"2025-03-21T06:32:18.704Z","repository":{"id":39617816,"uuid":"378285090","full_name":"welteki/faasd-nix","owner":"welteki","description":"NixOS modules for faasd","archived":false,"fork":false,"pushed_at":"2024-07-24T22:12:32.000Z","size":100,"stargazers_count":22,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-20T02:08:09.118Z","etag":null,"topics":["containers","edge","faas","faasd","microservices","nix-flake","nixos","openfaas","serverless"],"latest_commit_sha":null,"homepage":"","language":"Nix","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/welteki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-18T23:29:15.000Z","updated_at":"2025-02-19T01:43:11.000Z","dependencies_parsed_at":"2023-01-19T05:50:22.979Z","dependency_job_id":"12e71c9b-1157-4b72-add3-469a9ffa46f9","html_url":"https://github.com/welteki/faasd-nix","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/welteki%2Ffaasd-nix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/welteki%2Ffaasd-nix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/welteki%2Ffaasd-nix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/welteki%2Ffaasd-nix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/welteki","download_url":"https://codeload.github.com/welteki/faasd-nix/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244751701,"owners_count":20504246,"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":["containers","edge","faas","faasd","microservices","nix-flake","nixos","openfaas","serverless"],"created_at":"2024-10-11T12:40:42.778Z","updated_at":"2025-03-21T06:32:18.113Z","avatar_url":"https://github.com/welteki.png","language":"Nix","funding_links":[],"categories":[],"sub_categories":[],"readme":"# faasd-nix - deploy faasd on NixOS\n\nRun serverless functions on NixOS using [faasd](https://github.com/openfaas/faasd) - a lightweight \u0026 portable faas engine.\n\nIf you are new to [faasd](https://github.com/openfaas/faasd) and [OpenFaaS](https://github.com/openfaas/) checkout the following resources to get started:\n\n- [The faasd README](https://github.com/openfaas/faasd#readme)\n- [The OpenFaaS documentation](https://docs.openfaas.com)\n- [The official faasd handbook and docs](https://gumroad.com/l/serverless-for-everyone-else)\n\n## Quick start\n\nThe easiest way to try out faasd-nix is to run a NixOS vm with nixos-shell.\n\n\u003e This guide assumes you have the experimental flake commands enabled.\n\u003e To enable them add the following line to `~/.config/nix/nix.conf`:\n\u003e\n\u003e ```\n\u003e experimental-features = nix-command flakes\n\u003e ```\n\n1. Start a shell with the tools needed to run the faasd-vm.\n   ```sh\n   $ nix develop github:welteki/faasd-nix#faasd-vm\n   ```\n   This will make [nixos-shell](https://github.com/Mic92/nixos-shell) and the [faas-cli](https://github.com/openfaas/faas-cli) available in your shell.\n2. Start the faasd-vm.\n   ```sh\n   $ nixos-shell --flake github:welteki/faasd-nix#faasd-vm\n   ```\n   This spawns a headless qemu virtual machine with faasd running and provides console access in the same terminal window.\n3. Log in as \"root\" with an empty password.\n4. Interact with faasd using the faas-cli.\n\n   ```sh\n   # Login\n   $ cat /var/lib/faasd/secrets/basic-auth-password | faas-cli login --password-stdin\n\n   # Deploy a function from the function store\n   $ faas-cli store deploy figlet\n\n   # Invoke a function\n   $ echo \"faasd-nix\" | faas-cli invoke figlet\n   ```\n\n5. Type `Ctrl-a x` to exit the virtual machine or run the `poweroff` command in the virtual machine console.\n\n## Configuration and options\n\nThe faasd NixOS modules include some options to simplify common faasd configuration tasks.\n\n\u003e Full reference: [faasd NixOS module options](./OPTIONS.md)\n\n### Enabeling the service\n\n```nix\n{\n  services.faasd.enable = true;\n}\n```\n\n### Gateway configuration\n\nAdjust the gateway timeouts.\n\n```nix\n{\n  services.faasd.gateway = {\n    writeTimeout = 30;\n    readTimeout = 30;\n    upstreamTimeout = 35;\n  };\n}\n```\n\n### Additional namespaces\n\nAdd additional function namespaces using the `services.faasd.namespaces` option.\n\n```nix\n{ services.faasd.namespaces = [ \"dev\" ]; }\n```\n\nAll namespaces in this list will be created and labeled `openfaas=true` so they can be used with faasd.\n\n### Additional containers and services\n\nDeclaratively deploy additional containers.\n\nThis is the grafana example taken from the [serverless-book](https://gumroad.com/l/serverless-for-everyone-else).\n\n```nix\n{\n  systemd.tmpfiles.rules = [\n    \"d '/var/lib/faasd/grafana'\"\n  ];\n\n  services.faasd.containers = {\n    grafana = {\n      image = \"docker.io/grafana/grafana:latest\";\n      environment = [\n        \"GF_AUTH_ANONYMOUS_ORG_ROLE=Admin\"\n        \"GF_AUTH_ANONYMOUS_ENABLED=true\"\n        \"GF_AUTH_BASIC_ENABLED=false\"\n      ];\n      volumes = [{\n        type = \"bind\";\n        source = \"./grafana/\";\n        target = \"/etc/grafana/provisioning\";\n      }];\n      cap_add = [ \"CAP_NET_RAW\" ];\n      depends_on = [ \"prometheus\" ];\n      ports = [ \"3000:3000\" ];\n    };\n  };\n}\n```\n\n### Parallelism and multiple queues\n\nIncrease the parallelism for async function invocations.\n\n```nix\n{ services.faasd.defaultQueue.maxInflight = 4; }\n```\n\nEasily deploy and configure multiple queues.\n\n```nix\n{\n  services.faasd.queues.slow-queue = {\n    maxInflight = 1;\n    natsChannel = \"slow-queue\";\n  };\n}\n```\n\n\u003e Check the [OpenFaaS documentation](https://docs.openfaas.com/reference/async/) for more info on asynchronous functions.\n\n## Deploy with terraform and deploy-rs\n\nThe [bootstrap folder](bootstrap) contains an example of how to provision a NixOS instance on hetzner-cloud using terraform and deploy faasd on it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwelteki%2Ffaasd-nix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwelteki%2Ffaasd-nix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwelteki%2Ffaasd-nix/lists"}