You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.5 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. {
  2. description = "User management system.";
  3. inputs = {
  4. flake-utils.url = "github:numtide/flake-utils";
  5. };
  6. outputs = inputs @ { self, nixpkgs, ... }:
  7. inputs.flake-utils.lib.eachDefaultSystem (system:
  8. let pkgs = nixpkgs.legacyPackages.${system};
  9. myGo = "${pkgs.go}/bin/go";
  10. myBuf = "${pkgs.buf}/bin/buf";
  11. myDir = "$MY_USERS_DIR";
  12. myBuild = pkgs.writeShellScriptBin "users-build" ''
  13. pushd ${myDir} > /dev/null &&
  14. sed -n 's,https://petstore.swagger.io/v2/swagger.json,swagger.json,g' \
  15. ${myDir}/modules/swagger-ui/dist/swagger-initializer.js &&
  16. ${myBuf} build &&
  17. ${myBuf} generate &&
  18. ${myGo} build -o ${myDir}/bin/users-server ${myDir}/cmd/server/main.go &&
  19. popd > /dev/null
  20. '';
  21. in
  22. rec {
  23. devShells.default = pkgs.mkShell {
  24. buildInputs = with pkgs; [
  25. go
  26. gopls
  27. protoc-gen-go
  28. protoc-gen-go-grpc
  29. buf
  30. grpc
  31. grpcui
  32. grpcurl
  33. grpc-tools
  34. grpc-gateway
  35. myBuild
  36. ];
  37. shellHook = ''
  38. export MY_USERS_DIR="$(pwd)"
  39. export GO111MODULE=on
  40. export GOPATH=$XDG_DATA_HOME/go
  41. export PATH=$GOPATH/bin:$PATH
  42. export PATH=$MY_USERS_DIR/bin:$PATH
  43. '';
  44. };
  45. }
  46. );
  47. }