-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
93 lines (82 loc) · 2.67 KB
/
Copy pathflake.nix
File metadata and controls
93 lines (82 loc) · 2.67 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
{
description = "Open the web URL of the current Git repository in a browser";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs =
{ self, nixpkgs }:
let
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems = nixpkgs.lib.genAttrs systems;
# Keep in sync with the latest release tag when packaging.
packageVersion = "2.4.2";
in
{
packages = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
commit = self.shortRev or self.dirtyShortRev or "dirty";
in
{
default = self.packages.${system}.git-open;
git-open = pkgs.buildGoModule {
pname = "git-open";
version = packageVersion;
src = self;
# Bump this after changing go.mod / go.sum:
# nix build 2>&1 | rg 'got:'
vendorHash = "sha256-WaM79VI/0eSCj4t6Myji/WPrjRSUFfaQjHfqPXGULgM=";
# Needed by worktree-related tests in checkPhase.
nativeBuildInputs = [ pkgs.git ];
ldflags = [
"-s"
"-w"
"-X github.com/zhaochunqi/git-open/cmd.Version=${packageVersion}"
"-X github.com/zhaochunqi/git-open/cmd.CommitHash=${commit}"
"-X github.com/zhaochunqi/git-open/cmd.BuildDate=unknown"
];
# ldflags inject release version, so skip tests that assert the
# default "dev" values from source.
checkFlags = [ "-skip=^Test_rootCmd_VersionFlag$" ];
meta = with pkgs.lib; {
description = "Open the web URL of the Git repository";
homepage = "https://github.com/zhaochunqi/git-open";
changelog = "https://github.com/zhaochunqi/git-open/releases/tag/v${packageVersion}";
license = licenses.mit;
mainProgram = "git-open";
platforms = platforms.unix ++ platforms.windows;
};
};
}
);
apps = forAllSystems (system: {
default = {
type = "app";
program = "${self.packages.${system}.git-open}/bin/git-open";
};
});
devShells = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
default = pkgs.mkShell {
packages = with pkgs; [
go
gopls
gotools
git
];
};
}
);
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
};
}