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.

57 lines
1.9 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 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. myProtoc = "${pkgs.grpc-tools}/bin/protoc";
  11. myUsersDir = "$MY_USERS_DIR";
  12. myUsersBuild = pkgs.writeShellScriptBin "users-build" ''
  13. pushd ${myUsersDir} > /dev/null &&
  14. ${myProtoc} --proto_path=${myUsersDir} \
  15. --go_out=. --go_opt=paths=source_relative \
  16. --go-grpc_out=. --go-grpc_opt=paths=source_relative \
  17. proto/users.proto &&
  18. ${myGo} build -o ${myUsersDir}/bin/users-server ${myUsersDir}/cmd/server/main.go &&
  19. ${myGo} build -o ${myUsersDir}/bin/users-gateway ${myUsersDir}/cmd/gateway/main.go &&
  20. popd > /dev/null
  21. '';
  22. myUsersTest = pkgs.writeShellScriptBin "users-test" ''
  23. pushd ${myUsersDir} > /dev/null &&
  24. ${pkgs.parallel}/bin/parallel ::: ${myUsersDir}/bin/users-server ${myUsersDir}/bin/users-gateway
  25. popd > /dev/null
  26. '';
  27. in
  28. rec {
  29. devShells.default = pkgs.mkShell {
  30. buildInputs = with pkgs; [
  31. go
  32. gopls
  33. protoc-gen-go
  34. protoc-gen-go-grpc
  35. grpc
  36. grpcui
  37. grpcurl
  38. grpc-tools
  39. myUsersBuild
  40. myUsersTest
  41. ];
  42. shellHook = ''
  43. export MY_USERS_DIR="$(pwd)"
  44. export GO111MODULE=on
  45. export GOPATH=$XDG_DATA_HOME/go
  46. export PATH=$GOPATH/bin:$PATH
  47. export PATH=$MY_USERS_DIR/bin:$PATH
  48. '';
  49. };
  50. }
  51. );
  52. }