-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
106 lines (93 loc) · 2.9 KB
/
flake.nix
File metadata and controls
106 lines (93 loc) · 2.9 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
{
description = "Nix flake for siiway-cli";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
systems.url = "github:nix-systems/default";
};
outputs =
inputs@{
self,
flake-parts,
systems,
...
}:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = import systems;
perSystem =
{ pkgs, system, ... }:
let
goToolchain = if pkgs ? go_1_26 then pkgs.go_1_26 else pkgs.go;
mkPackage =
{
targetGoos ? null,
targetGoarch ? null,
}:
pkgs.buildGoModule rec {
pname = "siiway-cli";
version =
if self ? shortRev then
self.shortRev
else if self ? dirtyShortRev then
self.dirtyShortRev
else
"dev";
src = self;
vendorHash = "sha256-f247K347OFddpKF6nME/AqoDqwBLOJGfW/IpNRU6gds=";
nativeBuildInputs = [ pkgs.makeWrapper ];
buildInputs = [ pkgs.git ];
env = pkgs.lib.optionalAttrs (targetGoos != null && targetGoarch != null) {
GOOS = targetGoos;
GOARCH = targetGoarch;
CGO_ENABLED = "0";
};
ldflags = [
"-s"
"-w"
"-X github.com/SiiWay/siiway-cli/cmd.Version=${version}"
];
postFixup = ''
wrapProgram $out/bin/siiway-cli \
--prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.git ]}
'';
};
package = mkPackage { };
packageLinuxAmd64 = mkPackage {
targetGoos = "linux";
targetGoarch = "amd64";
};
packageLinuxArm64 = mkPackage {
targetGoos = "linux";
targetGoarch = "arm64";
};
packageDarwinAmd64 = mkPackage {
targetGoos = "darwin";
targetGoarch = "amd64";
};
packageDarwinArm64 = mkPackage {
targetGoos = "darwin";
targetGoarch = "arm64";
};
in
{
packages.default = package;
packages.siiway-cli = package;
packages.siiway-cli-linux-amd64 = packageLinuxAmd64;
packages.siiway-cli-linux-arm64 = packageLinuxArm64;
packages.siiway-cli-darwin-amd64 = packageDarwinAmd64;
packages.siiway-cli-darwin-arm64 = packageDarwinArm64;
apps.default = {
type = "app";
program = "${package}/bin/siiway-cli";
};
devShells.default = pkgs.mkShell {
packages = [
goToolchain
pkgs.gopls
pkgs.git
];
};
formatter = pkgs.nixpkgs-fmt;
};
};
}