Skip to content

Commit edfa135

Browse files
authored
Add Nix flake and corresponding direnv config (#10)
1 parent 83a59c2 commit edfa135

5 files changed

Lines changed: 139 additions & 5 deletions

File tree

.envrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if command -v nix >/dev/null 2>/dev/null; then
2+
use flake
3+
fi

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@
1313

1414
# Dependency directories (remove the comment below to include it)
1515
# vendor/
16+
17+
# Nix direnv cache
18+
/.direnv/

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ Currently we only support choosing a single repository at launch, athough maybe
2424

2525
## How to Use?
2626

27-
You can run this in three easy ways.
28-
29-
1. Download the release from the Github page, and run it on any linux server.
30-
2. Use the container `sktan/aws-codeartifact-proxy` and run it on any capable host (AWS ECS, AWS EC2, Linux / Windows VM)
31-
3. Use the pre-built CDK template found in the `cdk` directory and deploy it to your environment (requires Python)
27+
There are a variety of options for running `aws-codeartifact-proxy`:
28+
29+
- Download the release from the Github page and run it directly on any Linux server.
30+
- Run the container `sktan/aws-codeartifact-proxy` on any capable host (AWS ECS, AWS EC2, Linux / Windows VM)
31+
- The [`cdk` directory](./cdk) contains a CDK template for deployment to AWS (requires Python)
32+
- Run as a [Nix flake](https://nixos.wiki/wiki/Flakes):
33+
```shell
34+
nix run github:sktan/aws-codeartifact-proxy
35+
```
3236

3337
Configuration is done via Environment Variables:
3438

flake.lock

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
description =
3+
"An AWS code artifact proxy to allow unauthenticated read access to your code artifacts";
4+
5+
inputs = {
6+
nixpkgs.url = "github:NixOS/nixpkgs";
7+
flake-utils.url = "github:numtide/flake-utils";
8+
};
9+
10+
outputs = { self, nixpkgs, flake-utils }:
11+
{
12+
overlays.default = (final: prev: {
13+
inherit (self.packages.${final.system}) aws-codeartifact-proxy;
14+
});
15+
} // flake-utils.lib.eachDefaultSystem (system:
16+
let
17+
package-name = "aws-codeartifact-proxy";
18+
urn = "github.com/sktan/${package-name}";
19+
20+
pkgs = import nixpkgs { inherit system; };
21+
22+
aws-codeartifact-proxy = pkgs.buildGoModule {
23+
pname = package-name;
24+
name = package-name;
25+
src = ./src;
26+
vendorSha256 = "3MO+mRCstXw0FfySiyMSs1vaao7kUYIyJB2gAp1IE48=";
27+
meta = with pkgs.lib; {
28+
description =
29+
"An AWS code artifact proxy to allow unauthenticated read access to your code artifacts";
30+
homepage = "https://${urn}";
31+
license = licenses.mit;
32+
maintainers = with maintainers; [ lafrenierejm ];
33+
};
34+
};
35+
in rec {
36+
packages = flake-utils.lib.flattenTree {
37+
# `nix build .#aws-codeartifact-proxy`
38+
inherit aws-codeartifact-proxy;
39+
# `nix build`
40+
default = aws-codeartifact-proxy;
41+
# Build an OCI image.
42+
# `nix build .#aws-codeartifact-proxy-oci`
43+
aws-codeartifact-proxy-docker = pkgs.dockerTools.buildLayeredImage {
44+
name = "aws-codeartifact-proxy";
45+
tag = "latest";
46+
config = {
47+
Entrypoint =
48+
[ "${aws-codeartifact-proxy}/bin/aws-codeartifact-proxy" ];
49+
WorkingDir = "/data";
50+
Volumes = { "/data" = { }; };
51+
};
52+
};
53+
};
54+
55+
# `nix run`
56+
apps.default =
57+
flake-utils.lib.mkApp { drv = packages.aws-codeartifact-proxy; };
58+
59+
# `nix develop`
60+
devShells.default = pkgs.mkShell {
61+
buildInputs = with pkgs; [ go gopls gotools go-tools nixfmt ];
62+
};
63+
});
64+
}

0 commit comments

Comments
 (0)