-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
93 lines (86 loc) · 2.56 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
84
85
86
87
88
89
90
91
92
{
description = "flutties";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
templ = {
url = "github:a-h/templ";
inputs.nixpkgs.follows = "nixpkgs";
};
gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
gomod2nix = {
url = "github:nix-community/gomod2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, gitignore, gomod2nix, templ, ... }:
let
allSystems = [
"x86_64-linux" # 64-bit Intel/AMD Linux
"aarch64-linux" # 64-bit ARM Linux
"x86_64-darwin" # 64-bit Intel macOS
"aarch64-darwin" # 64-bit ARM macOS
];
forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
inherit system;
pkgs = import nixpkgs { inherit system; };
});
in
{
packages = forAllSystems
({ system, pkgs, ... }:
let
buildGoApplication = gomod2nix.legacyPackages.${system}.buildGoApplication;
in
rec {
default = flutties;
flutties = buildGoApplication
{
name = "flutties";
src = gitignore.lib.gitignoreSource ./.;
go = pkgs.go;
pwd = ./.;
CGO_ENABLED = 0;
flags = [ "-trimpath" ];
ldflags = [
"-s"
"-w"
"-extldflags -static"
];
};
});
# `nix develop` provides a shell containing development tools.
devShell = forAllSystems ({ system, pkgs }:
let
templPkg = templ.packages.${system}.templ;
gomod2nixPkg = gomod2nix.legacyPackages.${system}.gomod2nix;
in
pkgs.mkShell {
buildInputs = with pkgs; [
(golangci-lint.override { buildGoModule = buildGo122Module; })
cosign # Used to sign container images.
go_1_22
gopls
goreleaser
gotestsum
ko # Used to build Docker images.
templPkg
gomod2nixPkg
wgo
];
});
# This flake outputs an overlay that can be used to add templ and
# templ-docs to nixpkgs as per https://templ.guide/quick-start/installation/#nix
#
# Example usage:
#
# nixpkgs.overlays = [
# inputs.templ.overlays.default
# ];
overlays.default = final: prev: {
flutties = self.packages.${final.stdenv.system}.flutties;
};
};
}