{ description = "User management system."; inputs = { flake-utils.url = "github:numtide/flake-utils"; }; outputs = inputs @ { self, nixpkgs, ... }: inputs.flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; myGo = "${pkgs.go}/bin/go"; myProtoc = "${pkgs.grpc-tools}/bin/protoc"; myUsersDir = "$MY_USERS_DIR"; myUsersBuild = pkgs.writeShellScriptBin "users-build" '' pushd ${myUsersDir} > /dev/null && ${myProtoc} --proto_path=${myUsersDir} \ --go_out=. --go_opt=paths=source_relative \ --go-grpc_out=. --go-grpc_opt=paths=source_relative \ proto/users.proto && ${myGo} build -o ${myUsersDir}/bin/users-server ${myUsersDir}/cmd/server/main.go && ${myGo} build -o ${myUsersDir}/bin/users-gateway ${myUsersDir}/cmd/gateway/main.go && popd > /dev/null ''; myUsersTest = pkgs.writeShellScriptBin "users-test" '' pushd ${myUsersDir} > /dev/null && ${pkgs.parallel}/bin/parallel ::: ${myUsersDir}/bin/users-server ${myUsersDir}/bin/users-gateway popd > /dev/null ''; in rec { devShells.default = pkgs.mkShell { buildInputs = with pkgs; [ go gopls protoc-gen-go protoc-gen-go-grpc grpc grpcui grpcurl grpc-tools myUsersBuild myUsersTest ]; shellHook = '' export MY_USERS_DIR="$(pwd)" export GO111MODULE=on export GOPATH=$XDG_DATA_HOME/go export PATH=$GOPATH/bin:$PATH export PATH=$MY_USERS_DIR/bin:$PATH ''; }; } ); }