-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
57 lines (52 loc) · 1.33 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
{
description = "Nix Flake Template for Go using GoMod2Nix";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
gomod2nix = {
url = "github:nix-community/gomod2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
gomod2nix,
}: let
systems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
forEachSystem = nixpkgs.lib.genAttrs systems;
pkgs = forEachSystem (system:
import nixpkgs {
inherit system;
overlays = [
gomod2nix.overlays.default
];
});
in {
formatter = forEachSystem (system: nixpkgs.legacyPackages.${system}.alejandra);
devShells = forEachSystem (system: let
goEnv = pkgs.${system}.mkGoEnv {pwd = ./.;};
in {
default = pkgs.${system}.mkShell {
packages = [
goEnv
gomod2nix.packages.${system}.default
];
};
});
packages = forEachSystem (system: {
default = pkgs.${system}.buildGoApplication {
pname = "hello";
version = "0.1.0";
pwd = ./.;
src = ./.;
modules = ./gomod2nix.toml;
};
});
apps = forEachSystem (system: {
default = {
type = "app";
program = "${self.packages.${system}.default}/bin/src";
};
});
};
}