-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathflake.nix
83 lines (74 loc) · 1.94 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{
description = "Real world DevOps with Nix";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{ self
, nixpkgs
, flake-utils
}:
let
name = "todos";
goVersion = 19;
# An overlay to set the Go version
goOverlay = self: super: {
go = super."go_1_${toString goVersion}";
};
overlays = [ goOverlay ];
in
# The package and Docker image are only intended to be built on amd64 Linux
flake-utils.lib.eachSystem [ "x86_64-linux" ]
(system:
let
pkgs = import nixpkgs { inherit overlays system; };
in
{
packages = rec {
default = todos;
todos = pkgs.buildGoModule {
name = "todos";
src = ./.;
subPackages = [ "cmd/todos" ];
vendorSha256 = "sha256-fwJTg/HqDAI12mF1u/BlnG52yaAlaIMzsILDDZuETrI=";
};
docker =
# A layered image means better caching and less bandwidth
pkgs.dockerTools.buildLayeredImage {
name = "lucperkins/todos";
config = {
Cmd = [ "${self.packages.${system}.todos}/bin/todos" ];
ExposedPorts."8080/tcp" = { };
};
maxLayers = 120;
};
};
}) //
# The shell environment is intended for all systems
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit overlays system;
};
in
{
devShells.default = pkgs.mkShell {
buildInputs = with pkgs;
[
# Platform-non-specific Go (for local development)
go
# Docker CLI
docker
# Kubernetes
kubectl
kubectx
# Terraform
terraform
tflint
# Digital Ocean
doctl
];
};
});
}