Skip to content

Commit f5469f2

Browse files
ryuheechulStrum355
andauthored
Add nix flake support (#965)
* Add nix flake support * Apply suggestions from code review Co-authored-by: Noah S-C <[email protected]> * Move nix files to /contrib --------- Co-authored-by: Noah S-C <[email protected]>
1 parent 3c38e81 commit f5469f2

File tree

4 files changed

+102
-0
lines changed

4 files changed

+102
-0
lines changed

contrib/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# for `nix build`
2+
result

contrib/default.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(import
2+
(
3+
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
4+
fetchTarball {
5+
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
6+
sha256 = lock.nodes.flake-compat.locked.narHash;
7+
}
8+
)
9+
{ src = ./.; }
10+
).defaultNix

contrib/flake.lock

Lines changed: 59 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contrib/flake.nix

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
description = "Sourcegraph CLI";
3+
4+
inputs = {
5+
nixpkgs.url = "nixpkgs/nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
flake-compat = {
8+
url = "github:edolstra/flake-compat";
9+
flake = false;
10+
};
11+
};
12+
13+
outputs = { self, nixpkgs, flake-utils, ... }:
14+
flake-utils.lib.eachDefaultSystem (system:
15+
let
16+
pkgs = import nixpkgs { inherit system; };
17+
in
18+
rec {
19+
packages.src-cli = with pkgs; buildGoModule.override { go = pkgs.go_1_19; } {
20+
pname = "src-cli";
21+
version = self.shortRev or "dirty";
22+
src = ../.;
23+
24+
subPackages = [ "cmd/src" ];
25+
26+
vendorSha256 = "sha256-NMLrBYGscZexnR43I4Ku9aqzJr38z2QAnZo0RouHFrc=";
27+
};
28+
packages.default = packages.src-cli;
29+
}
30+
);
31+
}

0 commit comments

Comments
 (0)