Commit 7dd42cc 1 parent 3f0a94c commit 7dd42cc Copy full SHA for 7dd42cc
File tree 2 files changed +126
-0
lines changed
2 files changed +126
-0
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ description = "A flake that builds a repo" ;
3
+
4
+ inputs = {
5
+ nixpkgs . url = "github:NixOS/nixpkgs/nixos-unstable" ;
6
+ flake-utils . url = "github:numtide/flake-utils" ;
7
+ } ;
8
+
9
+ outputs =
10
+ inputs @{
11
+ nixpkgs ,
12
+ flake-utils ,
13
+ ...
14
+ } :
15
+ flake-utils . lib . eachDefaultSystem (
16
+ system :
17
+ let
18
+ pkgs = import nixpkgs { inherit system ; } ;
19
+ buildInputs = with pkgs ; [
20
+ go
21
+ coreutils
22
+ curl
23
+ xmlstarlet
24
+
25
+ # Protobuf + gRPC
26
+ protobuf
27
+ protoc-gen-go
28
+ protoc-gen-go-grpc
29
+ grpc
30
+ ] ;
31
+
32
+ defaultShellHook = ''
33
+ export FLAKE_ROOT=$(nix flake metadata | grep 'Resolved URL' | awk '{print $3}' | awk -F'://' '{print $2}')
34
+ export HISTFILE="$FLAKE_ROOT/.nix_bash_history"
35
+
36
+ export GOROOT="${ pkgs . go } /share/go"
37
+ '' ;
38
+ in
39
+ {
40
+ # run: `nix develop`
41
+ devShells = {
42
+ default = pkgs . mkShell {
43
+ inherit buildInputs ;
44
+ shellHook = defaultShellHook ;
45
+ } ;
46
+
47
+ # Update IDEA paths. Use only if nix installed in whole system.
48
+ # run: `nix develop .#idea`
49
+ idea = pkgs . mkShell {
50
+ inherit buildInputs ;
51
+
52
+ shellHook = pkgs . lib . concatLines [
53
+ defaultShellHook
54
+ ''
55
+ echo "Replace GOPATH"
56
+ xmlstarlet ed -L -u '//project/component[@name="GOROOT"]/@url' -v 'file://${ pkgs . go } /share/go' .idea/workspace.xml
57
+
58
+ exit 0
59
+ ''
60
+ ] ;
61
+ } ;
62
+ } ;
63
+ }
64
+ ) ;
65
+ }
You can’t perform that action at this time.
0 commit comments