forked from vood/nhost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
135 lines (115 loc) · 3.96 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nix-filter.url = "github:numtide/nix-filter";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, nix-filter }:
flake-utils.lib.eachDefaultSystem (system:
let
version = "v1.1.0";
dist = {
aarch64-darwin = rec {
url = "https://github.com/nhost/cli/releases/download/${version}/cli-${version}-darwin-arm64.tar.gz";
sha256 = "sha256-tF40CEkA357yzg2Gmc9ubjHJ5FlI9qQTdVdWNY/+f+Y=";
};
x86_64-linux = rec {
url = "https://github.com/nhost/cli/releases/download/${version}/cli-${version}-linux-amd64.tar.gz";
sha256 = "sha256-KLv06dI7A+5KGJ5F8xM1qC+oqHRmJ4kMaifLvaTFqak=";
};
};
overlays = [
(final: prev: rec {
hasura-cli = prev.hasura-cli.override {
buildGoModule = args: final.buildGoModule (args // rec {
version = "2.15.2";
src = final.fetchFromGitHub {
owner = "hasura";
repo = "graphql-engine";
rev = "v${version}";
sha256 = "sha256-q5Pk8K6WlkPMsegdKAqXXTFtPlN65Y1luoAsvjoW+20=";
};
ldflags = [
"-X github.com/hasura/graphql-engine/cli/v2/version.BuildVersion=${version}"
"-X github.com/hasura/graphql-engine/cli/v2/plugins.IndexBranchRef=master"
"-s"
"-w"
"-extldflags"
"\"-static\""
];
vendorSha256 = "sha256-vZKPVQ/FTHnEBsRI5jOT6qm7noGuGukWpmrF8fK0Mgs=";
});
};
nhost = final.stdenvNoCC.mkDerivation rec {
pname = "nhost-cli";
inherit version;
src = final.fetchurl {
inherit (dist.${final.stdenvNoCC.hostPlatform.system} or
(throw "Unsupported system: ${final.stdenvNoCC.hostPlatform.system}")) url sha256;
};
sourceRoot = ".";
nativeBuildInputs = [
final.makeWrapper
final.installShellFiles
];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
mv cli $out/bin/nhost
wrapProgram $out/bin/nhost --set HASURACLI ${final.hasura-cli}/bin/hasura
installShellCompletion --cmd nhost \
--bash <($out/bin/nhost completion bash) \
--fish <($out/bin/nhost completion fish) \
--zsh <($out/bin/nhost completion zsh)
runHook postInstall
'';
meta = with final.lib; {
description = "Nhost CLI";
homepage = "https://nhost.io";
license = licenses.mit;
maintainers = [ "@nhost" ];
};
};
}
)
];
pkgs = import nixpkgs {
inherit system overlays;
};
nix-src = nix-filter.lib.filter {
root = ./.;
include = [
(nix-filter.lib.matchExt "nix")
];
};
buildInputs = with pkgs; [
];
nativeBuildInputs = with pkgs; [
];
in
{
checks = {
nixpkgs-fmt = pkgs.runCommand "check-nixpkgs-fmt"
{
nativeBuildInputs = with pkgs;
[
nixpkgs-fmt
];
}
''
mkdir $out
nixpkgs-fmt --check ${nix-src}
'';
};
devShells = flake-utils.lib.flattenTree rec {
default = pkgs.mkShell {
buildInputs = with pkgs; [
nhost
nodejs_18
nodePackages.pnpm
] ++ buildInputs ++ nativeBuildInputs;
};
};
}
);
}