diff options
author | Vincent Ambo <mail@tazj.in> | 2020-06-16T03·26+0100 |
---|---|---|
committer | tazjin <mail@tazj.in> | 2020-06-16T13·40+0000 |
commit | 654f13d40575d2c51a215d9654e9d5a319cdac45 (patch) | |
tree | 31deac2a054484f15fb42db2fa9846f539e3864c /ops/nixos/sourcegraph.nix | |
parent | ba945dadf89bf14f23f083201291181cfefbde74 (diff) |
feat(nixos/sourcegraph): Add a module for running SourceGraph r/995
This module spins up the Sourcegraph container. Builds: Note that this is contrary to how our other deployments work, but packaging Sourcegraph is quite difficult (it's a Gitlab style deployment with a lot of moving parts and third-party things that it bundles). If we decide to keep it around, we will want to look at packaging it in Nix in the future. Deployment: The deployment is a hack. Sourcegraph does not support public instances, but we want it to be public. To work around this we have configured HTTP-proxy based authentication (i.e. auth via a header) and hardcoded a static header. This works, but lets anonymous users change the "Anonymous" user's settings. We can expect this to get defaced (profile picture, name etc), until we figure out how to write some nginx configuration to drop those requests. See git-bug for details. The Sourcegraph configuration is also not checked in to the repository. It's unclear where in the data directory it is stored. Change-Id: I414ff11c3b49989b6792d697bffc8a0edf96c9cb Reviewed-on: https://cl.tvl.fyi/c/depot/+/425 Reviewed-by: lukegb <lukegb@tvl.fyi>
Diffstat (limited to 'ops/nixos/sourcegraph.nix')
-rw-r--r-- | ops/nixos/sourcegraph.nix | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/ops/nixos/sourcegraph.nix b/ops/nixos/sourcegraph.nix new file mode 100644 index 000000000000..dcb12f2c1060 --- /dev/null +++ b/ops/nixos/sourcegraph.nix @@ -0,0 +1,26 @@ +# Run sourcegraph, including its entire machinery, in a container. +# Running it outside of a container is a futile endeavour for now. +{ config, pkgs, lib, ... }: + +let cfg = config.services.depot.sourcegraph; +in { + options.services.depot.sourcegraph = { + enable = lib.mkEnableOption "SourceGraph code search engine"; + }; + + config = lib.mkIf cfg.enable { + virtualisation.oci-containers.containers.sourcegraph = { + image = "sourcegraph/server:3.16.1"; + + ports = [ + "127.0.0.1:3463:7080" + "127.0.0.1:3370:3370" + ]; + + volumes = [ + "/var/lib/sourcegraph/etc:/etc/sourcegraph" + "/var/lib/sourcegraph/data:/var/opt/sourcegraph" + ]; + }; + }; +} |