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

{
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";
myBuf = "${pkgs.buf}/bin/buf";
myDir = "$MY_USERS_DIR";
myBuild = pkgs.writeShellScriptBin "users-build" ''
pushd ${myDir} > /dev/null &&
sed -n 's,https://petstore.swagger.io/v2/swagger.json,swagger.json,g' \
${myDir}/modules/swagger-ui/dist/swagger-initializer.js &&
${myBuf} build &&
${myBuf} generate &&
${myGo} build -o ${myDir}/bin/users-server ${myDir}/cmd/server/main.go &&
popd > /dev/null
'';
in
rec {
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
go
gopls
protoc-gen-go
protoc-gen-go-grpc
buf
grpc
grpcui
grpcurl
grpc-tools
grpc-gateway
myBuild
];
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
'';
};
}
);
}