-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathflake.nix
58 lines (49 loc) · 1.61 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
{
description = "beanstalkd_exporter flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
gomod2nix = {
url = "github:nix-community/gomod2nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = {
self,
nixpkgs,
flake-utils,
gomod2nix,
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = nixpkgs.legacyPackages.${system};
# The current default sdk for macOS fails to compile go projects, so we use a newer one for now.
# This has no effect on other platforms.
callPackage = pkgs.darwin.apple_sdk_11_0.callPackage or pkgs.callPackage;
in {
formatter = pkgs.alejandra;
packages = {
default = callPackage ./. {
inherit (gomod2nix.legacyPackages.${system}) buildGoApplication;
};
docker = let
beanstalkd_exporter = self.packages.${system}.default;
in
pkgs.dockerTools.buildLayeredImage {
name = beanstalkd_exporter.pname;
tag = beanstalkd_exporter.version;
contents = [beanstalkd_exporter];
config = {
Cmd = ["/bin/beanstalkd_exporter"];
WorkingDir = "/";
};
};
};
apps.default = flake-utils.lib.mkApp {drv = self.packages.${system}.default;};
devShells.default = callPackage ./shell.nix {
inherit (gomod2nix.legacyPackages.${system}) mkGoEnv gomod2nix;
};
}
);
}