-
Notifications
You must be signed in to change notification settings - Fork 126
/
flake.nix
102 lines (89 loc) · 3.06 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
93
94
95
96
97
98
99
100
101
102
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2405.*.tar.gz";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
devenv.url = "github:cachix/devenv";
devenv.inputs.nixpkgs.follows = "nixpkgs-unstable";
gomod2nix.url = "github:nix-community/gomod2nix/master";
gomod2nix.inputs.nixpkgs.follows = "nixpkgs-unstable";
gomod2nix.inputs.flake-utils.follows = "flake-utils";
};
outputs =
{
self,
nixpkgs,
nixpkgs-unstable,
flake-utils,
devenv,
gomod2nix,
...
}@inputs:
flake-utils.lib.eachDefaultSystem (
system:
let
overlays = [ gomod2nix.overlays.default ];
pkgs = import nixpkgs { inherit system overlays; };
pkgsUnstable = import nixpkgs-unstable { inherit system overlays; };
# match go x.x in go.mod
gomod = builtins.readFile ./go.mod;
goVersion = builtins.match ".*[\n]go ([[:digit:]]*)\.([[:digit:]]*)[\.]*([[:digit:]]*)[\n].*" gomod;
go = pkgs."go_${builtins.head goVersion}_${builtins.elemAt goVersion 1}";
in
{
packages = rec {
nixos-test = pkgs.callPackage ./nix/test { overlay = self.overlays.default; };
haqq = pkgsUnstable.callPackage ./nix/package.nix {
inherit (pkgsUnstable) buildGoApplication;
inherit go;
rev = if (self ? rev) then self.rev else self.dirtyRev;
};
haqq-with-tests = haqq.overrideAttrs (_: {
subPackages = null;
doCheck = true;
});
default = haqq;
};
devShells = {
default = devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
(import ./nix/devshell/common.nix { inherit pkgs pkgsUnstable go; })
(import ./nix/devshell { inherit pkgs pkgsUnstable; })
];
};
ci = devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
(import ./nix/devshell/common.nix { inherit pkgs pkgsUnstable go; })
(import ./nix/devshell/ci.nix { inherit pkgs pkgsUnstable go; })
];
};
};
}
)
// {
overlays.default = prev: final: {
inherit (inputs.cosmos.packages.${prev.system}) cosmovisor;
inherit (self.packages.${prev.system}) haqq;
grafana-agent-unstable = inputs.nixpkgs-unstable.legacyPackages.${prev.system}.grafana-agent;
};
nixosModules = {
haqqdSupervised = {
imports = [ ./nix/nixos-module ];
nixpkgs.overlays = [ self.overlays.default ];
};
};
nixConfig = {
extra-trusted-public-keys = [
"devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="
"haqq.cachix.org-1:m8QJypf2boIKRBz4BvVyGPo7gHQoj4D6iMGCmGozNEg="
];
extra-substituters = [
"https://devenv.cachix.org"
"https://haqq.cachix.org"
];
};
};
}