Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
100 lines (85 loc) · 3.23 KB
/
Copy pathflake.nix
File metadata and controls
100 lines (85 loc) · 3.23 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
{
description = "gitgetter — a modern TUI for everyday git operations";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, flake-utils, treefmt-nix }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs { inherit system; };
# Formatting
treefmtEval = treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix";
programs = {
gofmt.enable = true; # Go sources
nixpkgs-fmt.enable = true; # Nix files
};
};
# Package
gitgetter = pkgs.buildGoModule rec {
pname = "gitgetter";
version = "1.2.1";
src = self;
vendorHash = "sha256-FA/ttb1dwveAmEIrgOHepP349Q+ST4V0AR3dE8Ku7iE=";
meta = with pkgs.lib; {
description = "A modern TUI for everyday git operations";
homepage = "https://github.com/snapsettle/gitgetter";
license = licenses.mit;
maintainers = [ ];
mainProgram = "gitgetter";
};
};
in
{
# `nix build`
packages.default = gitgetter;
packages.gitgetter = gitgetter;
# `nix run`
apps.default = flake-utils.lib.mkApp { drv = gitgetter; };
# `nix fmt`
formatter = treefmtEval.config.build.wrapper;
# `nix flake check` includes format check
checks = {
formatting = treefmtEval.config.build.check self;
};
# `nix develop`
devShells.default = pkgs.mkShell {
name = "gitgetter-dev";
packages = with pkgs; [
# Go toolchain
go
gopls
golangci-lint
delve # debugger
# Git (runtime dep)
git
# Nix tooling
nil # Nix LSP
nixpkgs-fmt
# Formatting
treefmtEval.config.build.wrapper
];
shellHook = ''
echo ""
echo " ╭───────────────────────────────────────╮"
echo " │ gitgetter dev shell 🐙 │"
echo " │ │"
echo " │ go build ./... – build │"
echo " │ go run . – run │"
echo " │ go test ./... – test │"
echo " │ nix fmt – format all │"
echo " ╰───────────────────────────────────────╯"
echo ""
'';
};
}
) // {
# NixOS / nix-darwin module (see nix/module.nix)
nixosModules.default = import ./nix/module.nix { inherit self; };
darwinModules.default = import ./nix/module.nix { inherit self; };
};
}