Skip to content

Instantly share code, notes, and snippets.

@bew
Last active August 20, 2021 11:41
Show Gist options
  • Save bew/7f8e585f82473b2ae8d720927444ce62 to your computer and use it in GitHub Desktop.
Save bew/7f8e585f82473b2ae8d720927444ce62 to your computer and use it in GitHub Desktop.
{
description = "virtual environments";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-21.05";
inputs.devshell.url = "github:numtide/devshell";
outputs = { self, devshell, nixpkgs }: let
system = "x86_64-linux"; # We only care about a single system
in {
devShell.${system} = let
# (overlay alternative) pkgs = import nixpkgs { inherit system; overlays = [ devshell.overlay ]; };
mkDevShell = devshell.legacyPackages.${system}.mkShell;
pkgs = nixpkgs.legacyPackages.${system};
# --- Arbitrary derivations
# NOTE: I can't find how to make them flake inputs, `nix flake lock` tells me
# the input url is unsupported.
# Used for openapi v2 files
swagger-codegen-cli = builtins.fetchurl {
url = "https://url-to-artifactory/some-repo/swagger-codegen-cli.jar";
sha256 = "1s2fvq9v35w1ilysraw78q617nrxnmgvrpxqwnv9507p0n6wflz2";
};
# Used for openapi v3 files
openapi-generator-cli = builtins.fetchurl {
url = "https://url-to-artifactory/some-repo/openapi-generator-cli.jar";
sha256 = "1kkv1d2c5f64fxvfr1bgaxyyfy84b5m7wq84sgjfnn1ga60c7a9v";
};
# NOTE: These URLs are not version specific, so when the files are updated in artifactory,
# the sha256 hashes will need to be updated.
# (overlay alternative) in pkgs.devshell.mkShell {
in mkDevShell {
packages = [
pkgs.jdk8_headless
pkgs.go_1_16
pkgs.just
];
env = [
# Ensure go builds will stay local to this folder
{ name = "GOCACHE"; eval = ''"$PWD/go-cache"''; }
{ name = "GOPATH"; eval = ''"$PWD/go-path"''; }
# Point the lowlevel generator to the swagger/openapi generator clis
{ name = "SWAGGER_CODEGEN_CLI_PATH"; value = swagger-codegen-cli; }
{ name = "OPENAPI_GENERATOR_CLI_PATH"; value = openapi-generator-cli; }
];
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment