Commit Graph

53 Commits

Author SHA1 Message Date
William Bezuidenhout
d7db73f0cd
fix(nix/p4-fusion): update p4-fusion helix-api hashes (#63805)
Failed run here
https://github.com/sourcegraph/p4-fusion/actions/runs/9890851838/job/27320002177.

I tried looking at the sha256 hashes here -
https://filehost.perforce.com/perforce/r22.2/bin.macosx12arm64/SHA256SUMS

But there is no clear way to convert to the nix format. There is `nix
hash convert` but it's not available in my nix version.

So ... I took the values reported in the workflow and used them in this
PR

## Test plan
CI
## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-15 10:20:33 +02:00
Keegan Carruthers-Smith
d42a99b5a3
nix: use go1.22.4 (#63372)
Tired of seeing the go toolchain being easier to use than nix.

Test Plan: nix develop on linux amd64 and macbook arm64 followed by
running "go test ./internal/search" working. Also confirming that "go
env GOROOT" points into the nix store.
2024-06-20 11:12:17 +02:00
Noah S-C
ad082497f2
nix: build pg-utils with nix [static edition] (#61734)
Turns out we can do this after all! And thankfully so, because our buildkite runners have an older glibc version than what Nix was building our bins against which was resulting in `dropdb: /lib/x86_64-linux-gnu/libc.so.6: version GLIBC_2.32' not found (required by dropdb)` when bazel was running in buildkite

## Test plan

Much local `nix build`'ing, `ldd` and `patchelf`'ing
2024-04-09 20:24:19 +01:00
Noah S-C
1fcc1f0e32
nix: build pg-utils with nix & upload to GCS (#61658)
Lets get rid of PG_UTILS_PATH! :allthethings: 🎉 

## Test plan

CI and a _lot_ of  `nix build .#pg-utils && ldd ./result/bin/pg_dump`
also tested e2e with the following diff: 61e0eb0d55
2024-04-09 11:54:17 +01:00
Noah S-C
2f8990e745
nix: bump to bazel 7.1 (#61326)
Using my fork with open PR: https://github.com/NixOS/nixpkgs/pull/295615

Im needing 7.1 sooner than later, given its new features and this repo also using 7.1 (so all new features are fair game for it!)

Cached version is pushed to sourcegraph-noah.cachix.org, which I've added at the top here so you too can avoid building it locally 🙂 

## Test plan

Tested locally 😎
2024-03-22 16:57:50 +00:00
Will Dollman
9d918d6393
Update perforce CDN urls to use stable versions (#60784)
See https://github.com/orgs/Homebrew/discussions/4686#discussioncomment-6628463

Thanks @jac !

## Test plan

- Ensure CI builds correctly

<!-- All pull requests REQUIRE a test plan: https://docs.sourcegraph.com/dev/background-information/testing_principles 

Why does it matter? 

These test plans are there to demonstrate that are following industry standards which are important or critical for our customers. 
They might be read by customers or an auditor. There are meant be simple and easy to read. Simply explain what you did to ensure 
your changes are correct!

Here are a non exhaustive list of test plan examples to help you:

- Making changes on a given feature or component: 
  - "Covered by existing tests" or "CI" for the shortest possible plan if there is zero ambiguity
  - "Added new tests" 
  - "Manually tested" (if non trivial, share some output, logs, or screenshot)
- Updating docs: 
  - "previewed locally" 
  - share a screenshot if you want to be thorough
- Updating deps, that would typically fail immediately in CI if incorrect
  - "CI" 
  - "locally tested" 
-->
2024-03-07 16:51:59 +00:00
Noah S-C
07c493fd9d
nix: mount /tmp/zig-cache RW in sandbox actions (#60018)
Non-hermetic /tmp disabled until we're on bazel 7.0.1
https://github.com/bazelbuild/bazel/issues/20527

## Test plan

`bazel build //:gazelle-buf`
2024-01-31 18:38:58 +02:00
Noah S-C
354982865f
nix: mount /tmp/zig-cache in sandbox actions (#59992)
As detailed in the shell hook:
Without this, zig cc is forced to rebuild on every sandboxed GoLink action, which adds ~1m of time to GoLink actions. The reason it's on _every_ GoLink action is because sandboxes are ephemeral and don't persist non-mounted paths between actions.

We're already doing this for `darwin-docker` config, so this only affects us nixos users

--- 

Smuggling in a libtool fix for macos that would otherwise yield the following error when building rust with bazel:

<details>
<summary>Details</summary>

```
cargo:rerun-if-env-changed=AR_aarch64-apple-darwin
AR_aarch64-apple-darwin = None
cargo:rerun-if-env-changed=AR_aarch64_apple_darwin
AR_aarch64_apple_darwin = None
cargo:rerun-if-env-changed=HOST_AR
HOST_AR = None
cargo:rerun-if-env-changed=AR
AR = Some("/nix/store/42yck6r7y2jhcrd0ay0glz30w6pw4wzh-libtool-2.4.7")
cargo:rerun-if-env-changed=ARFLAGS_aarch64-apple-darwin
ARFLAGS_aarch64-apple-darwin = None
cargo:rerun-if-env-changed=ARFLAGS_aarch64_apple_darwin
ARFLAGS_aarch64_apple_darwin = None
cargo:rerun-if-env-changed=HOST_ARFLAGS
HOST_ARFLAGS = None
cargo:rerun-if-env-changed=ARFLAGS
ARFLAGS = None
running: ZERO_AR_DATE="1" "/nix/store/42yck6r7y2jhcrd0ay0glz30w6pw4wzh-libtool-2.4.7" "cq" "/private/var/tmp/_bazel_noah/dcf2fbfa8ce2981c9fc4201fa6327d3b/sandbox/darwin-sandbox/6091/execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/external/crate_index__tree-sitter-kotlin-0.2.11/tree-sitter-kotlin_build_script.out_dir/libparser.a" "/private/var/tmp/_bazel_noah/dcf2fbfa8ce2981c9fc4201fa6327d3b/sandbox/darwin-sandbox/6091/execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/external/crate_index__tree-sitter-kotlin-0.2.11/tree-sitter-kotlin_build_script.out_dir/src/parser.o" "/private/var/tmp/_bazel_noah/dcf2fbfa8ce2981c9fc4201fa6327d3b/sandbox/darwin-sandbox/6091/execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/external/crate_index__tree-sitter-kotlin-0.2.11/tree-sitter-kotlin_build_script.out_dir/src/scanner.o"

--stderr:


error occurred: Command ZERO_AR_DATE="1" "/nix/store/42yck6r7y2jhcrd0ay0glz30w6pw4wzh-libtool-2.4.7" "cq" "/private/var/tmp/_bazel_noah/dcf2fbfa8ce2981c9fc4201fa6327d3b/sandbox/darwin-sandbox/6091/execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/external/crate_index__tree-sitter-kotlin-0.2.11/tree-sitter-kotlin_build_script.out_dir/libparser.a" "/private/var/tmp/_bazel_noah/dcf2fbfa8ce2981c9fc4201fa6327d3b/sandbox/darwin-sandbox/6091/execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/external/crate_index__tree-sitter-kotlin-0.2.11/tree-sitter-kotlin_build_script.out_dir/src/parser.o" "/private/var/tmp/_bazel_noah/dcf2fbfa8ce2981c9fc4201fa6327d3b/sandbox/darwin-sandbox/6091/execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/external/crate_index__tree-sitter-kotlin-0.2.11/tree-sitter-kotlin_build_script.out_dir/src/scanner.o" with args "" failed to start: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }
```

</details>

## Test plan

Observing `bazel build //dev/sg` times
2024-01-30 16:47:55 -08:00
Noah S-C
694f174511
nix: patch bazel_7 with hardcoded bin paths (#59359)
bazel (and its community of rules) is a bit of a mess when it comes to passing around env values, including $PATH, resulting in some actions not receiving the $PATH value set via `--action_path=PATH=...` that we rely on. Bazel 6 in nixpkgs had [the following patch](https://sourcegraph.com/github.com/NixOS/nixpkgs/-/blob/pkgs/development/tools/build-managers/bazel/bazel_6/actions_path.patch) that hardcodes a set of packages to include in that case, which is currently missing from Bazel 7 in nixpkgs, so we (temporarily, hopefully) reintroduce that patch locally. 

See: https://github.com/NixOS/nixpkgs/pull/262152#issuecomment-1879053113 and https://github.com/NixOS/nixpkgs/issues/94222 for some reading

I plan to move more bazel stuff out of shell.nix perhaps, into bazel.nix, as its a tad messy all-in-one

## Test plan

`bazel build //client/web/dist` is successful
2024-01-16 20:58:22 +00:00
Noah S-C
30cf61e1bf
nix: use interactive bash instead of non-interactive in shell (#59280)
standard bash is a non-interactive shell meant for a build environment instead of an interactive environment.

Also bumping nixpkgs while we're here

## Test plan

run `bash` in `nix develop`
2024-01-02 16:37:00 +00:00
Keegan Carruthers-Smith
3e0bd9f85a
nix: empty out before writing to it .bazelrc-nix (#58825)
Currently on non-nixos hosts we will append to .bazelrc-nix everytime
the shell hook runs. This leads to the file growing quite large, I am
unsure on the impact on bazel. This was an accidental regression when we
removed bazel from the nix darwin environment.

Test Plan: ran nix develop and I didn't have duplicated lines.
2023-12-07 15:23:27 +02:00
Noah S-C
5c27500580
bazel: remove unused rules_rust patch (#58747) 2023-12-04 17:56:45 +00:00
William Bezuidenhout
9cd7ae3525
nix: update flake for clang 16 and assert typescript 5.3.2 (#58702)
update flake and assert typescript 5.3.2
2023-12-01 13:00:41 +02:00
Keegan Carruthers-Smith
315eaf32ed
nix: assert typescript version and reduce repetition in nodejs.nix (#58044) 2023-11-01 14:05:22 +00:00
William Bezuidenhout
b33b596506
nix: upgrade node and pnpm (#58015)
* nix: upgrade node and pnpm
* nix fmt
2023-10-31 17:55:55 +02:00
Keegan Carruthers-Smith
2783f0093b
all: use universal-ctags v6.0.0 (#57725)
This is the latest release from December 2022. I see important bug fixes
between our tagged version and this release.

A follow up commit needs to update the bazel shas once CI has built the
artifacts on main.

Test Plan: CI
2023-10-24 16:16:15 +02:00
William Bezuidenhout
c5b31f789e
ctags: fix push branch target (#57339) 2023-10-04 15:48:26 +02:00
William Bezuidenhout
9660ae5534
ctags actions: only upload when a change to ctags nix is pushed to main (#57296)
* only upload when a change to ctags nix is pushed to main

* change to trigger workflow

* use apple specific shasum

* binaries get uploaded when branch matches

* use github.head_ref

* use ref_name for push events

* add short sha to filename
2023-10-04 14:45:34 +02:00
Noah S-C
a172701e1a
nix: fix shellhook and add extra libs for jetbrains plugin (#57038) 2023-09-26 12:30:20 +00:00
Noah S-C
831c06ca16
nix: separate nixpkgs-unstable pin from nixpkgs pin for static binaries (#56959)
We want to get newer stuff in the devshell, but keep a stabler pin for the static binaries (until darwin stdenv stabilizes, most notably the big brain work over at https://github.com/NixOS/nixpkgs/pull/256590)

## Test plan

N/A nix stuff :clueless:
2023-09-22 17:12:18 +00:00
Noah S-C
4a7b1c61ab
nix: set bazel action env on non-nixos nix shell users too (#56313) 2023-08-31 15:07:48 -05:00
William Bezuidenhout
17051dcdf6
nix: add ln to ctags without version (#56019) 2023-08-18 19:30:23 +00:00
Dave Try
f882023227
sg: use bazel run universtal-ctags (#55944)
Use nix to compile and upload universal-ctags to a gcloud bucket. We then pull this down using a bazel http_file and can run it with bazel also. Removed all of the old bash logic that was hard to follow and maintain also. 

---------

Co-authored-by: Noah Santschi-Cooney <noah@santschi-cooney.ch>
Co-authored-by: William Bezuidenhout <william.bezuidenhout@sourcegraph.com>
2023-08-18 16:02:46 +00:00
Noah S-C
36eacfd5ae
nix: fix direnv hanging when starting redis (#55866) 2023-08-15 12:30:35 +00:00
Bolaji Olajide
2431551a23
update hash for p4-fusion.nix (#55488)
While setting up p4-fusion locally, I ran into the hash mismatch error.
I updated the hash here.

## Test plan

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->
Hash update.
2023-08-04 13:30:29 +01:00
Noah S-C
bfd4cfbbce
nix: fix direnv hanging when starting postgres (#55156)
See related issues: https://github.com/direnv/direnv/issues/755,
https://discourse.nixos.org/t/devenv-sh-starting-postgres/24272/7,
https://github.com/shelljs/shelljs/issues/770

Long-standing issue where on first-boot, direnv wouldnt return to the
shell, forcing me to kill the shell and then cd into sg/sg again

## Test plan

NA/, nix stuff
2023-07-20 15:30:38 +02:00
Keegan Carruthers-Smith
14ab37783a
nix: fix bazel test (#52939)
I had some bazel tests commands which failed to find the "find" binary.
Additionally it was not respecting my configured PG* settings. This
makes it so we pass those envvars on. To be honest, I'm surprised this
isn't the default in a devenv.

Test Plan: bazel test //internal/database:database_test
2023-06-05 18:33:27 +02:00
Noah S-C
2aeac3bdac
nix: bump pnpm hash (#52844)
le bump

## Test plan

N/A
2023-06-02 15:05:37 +00:00
Valery Bugakov
4c4228b076
ci: improve pnpm dedupe CI check (#52741)
Make the `pnpm deduplicate` exit with the error code on CI by upgrading
`pnpm` and using `pnpm dedupe --check`. Fixes the issue reported
[here](https://sourcegraph.slack.com/archives/C01C3NCGD40/p1685565664285879).
2023-06-01 06:02:20 +00:00
Noah S-C
35a8f87c7e
nix: reorganizing (#52273)
Re-organizing a couple of things to make the individual files nicer,
consolidated some things in ctags.nix, extracted forEachSystem stuff to
flake.nix instead of the individual files, overlay for our specific
nodejs requirements, some more comments to stuff

## Test plan

N/A, nix stuff
2023-05-31 16:20:32 +01:00
William Bezuidenhout
d08b09ef85
nix: update p4 fusion openssl3 (#51913)
Mostly just updating shasums and checking that it still builds.
## Test plan
Tested on Mac and Linux
<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->

---------

Co-authored-by: Noah S-C <noah@sourcegraph.com>
2023-05-23 12:49:08 +02:00
Noah S-C
184d1a27d2
nix: run bazel in fhs environment (#52115)
Uses zig-cc as a hermetic c/c++ toolchain, and wraps bazel in an FHS
environment for nixos. This lets us drop some hacks and workarounds
needed to address gaps in hermeticity in some bazel-provisioned tools
(mostly around FHS env requirements)

## Test plan

Built :allthethings: many times over many days. Not tested on darwin but
we're deferring entirely to bazelisk there anyways
2023-05-19 09:52:37 +01:00
Noah S-C
530b5bb5ef
nix: pass through NIX_LD and NIX_LD_LIBRARY_PATH from cargo-bazel (#51635)
When using nix-ld instead of symlinking /lib64/ld-linux-x86-64.so.2 to
glibc's ld.so, we need to pass through NIX_LD and NIX_LD_LIBRARY_PATH
for it to work. cargo-bazel doesnt pass through stuff by default, so we
have to do it ourselves

## Test plan

N/A, nix stuff
2023-05-09 15:16:20 +01:00
Noah S-C
f6fcd3628b
nix: print warning if /lib64/ld-linux-x86-64.so.2 not found (#51554)
Does what it says in the help text


![image](https://github.com/sourcegraph/sourcegraph/assets/18282288/97f47ede-0273-4a5e-a691-fec6ac453cc6)

## Test plan

N/A, nix
2023-05-09 13:28:28 +00:00
Noah S-C
c7fd31a138
nix: set custom PATH for bazel actions (#51556)
We're now looking up some less-than-hermetically provided tools in files
such as
https://sourcegraph.com/github.com/sourcegraph/sourcegraph/-/blob/client/shared/dev/buildCodeIntelExtensions.js?L15
that are invoked as part of the bazel build. These must be in the
"strict" path defined [in this
function](https://sourcegraph.com/github.com/bazelbuild/bazel@6.1.2/-/blob/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java?L532-547),
HOWEVER as these dont exist on nixos, they're overridden by nix already
to contain the paths of [the following
tools](https://sourcegraph.com/github.com/NixOS/nixpkgs/-/blob/pkgs/development/tools/build-managers/bazel/bazel_6/default.nix?L83-124).
This is missing some such as curl that we need, so we can pass in a
custom PATH instead as in this PR

## Test plan

N/A, nix stuff
2023-05-08 13:13:35 +01:00
Keegan Carruthers-Smith
afdb818ec3
nix: start redis on localhost (#51462)
This is to avoid the macos firewall popups. Also its just better to use
localhost for local dev.

Test Plan: Killed the running server then ensured the started server was
listening on localhost
2023-05-04 15:14:24 +02:00
Keegan Carruthers-Smith
31e12ec55c
nix: run nix fmt (#51463)
Test Plan: n/a
2023-05-04 15:14:03 +02:00
Noah S-C
884dcbe833
bazel: make work on nixos ❇️ (#51154)
Some sprinkling of special sauce for the NixOS (and nix shell) users in
the house. Much care has been taken so that there should be no
interference with anyone running bazel on a non-nixos machine, and that
it also works as (mostly) expected for nix shell users on macos.

## Test plan

Ran main dry-run, all green, so it shouldnt interfere with anyone on a
non-nixos machine
2023-04-28 20:06:33 +00:00
Noah S-C
46caf922a0
nix: tidy & static comby+ctags+p4-fusion on linux+darwin (#49884)
## How to build

`nix build .#ctags .#p4-fusion .#comby` with outputs in
`./result{,-1,-2}/bin`

## Static? Prove it

Linux:
```
$ ldd ./result/bin/comby ./result-1/bin/p4-fusion ./result-2/bin/ctags 
./result/bin/comby:
        not a dynamic executable
./result-1/bin/p4-fusion:
        not a dynamic executable
./result-2/bin/ctags:
        not a dynamic executable
```

Darwin (libiconv and libxml are in dylib cache, libSystem.B cannot be
statically linked, and the rest are core system libraries):
```
otool -L ./result-1/bin/p4-fusion ./result/bin/comby ./result-2/bin/ctags
./result-1/bin/p4-fusion:
        /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork (compatibility version 1.0.0, current version 1209.1.0)
        /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1770.255.0)
        /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 23.0.0)
        /System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 59754.60.13)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)
./result/bin/comby:
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)
./result-2/bin/ctags:
        @rpath/libxml2.2.dylib (compatibility version 13.0.0, current version 13.3.0)
        @rpath/libiconv.dylib (compatibility version 7.0.0, current version 7.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)
```

Review with whitespace changes hidden

## Test plan

Built many many times, checked ldd & otool many many times
2023-04-28 00:52:57 +01:00
Peter Guy
5240196382
Update hashes of dependencies for building p4-fusion (#48765)
The p4-fusion archives were updated without versioning, so their hashes
changed. Updating the build file with the new hashes.



## Test plan
Follow [the docs for building
p4-fusion](https://docs.sourcegraph.com/dev/background-information/build_p4_fusion)
to build it without hash mismatch errors
<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->
2023-03-07 06:42:07 -08:00
Noah S-C
f8d96a83d9
nix: add p4-fusion building (#44588) 2022-11-23 16:06:28 +00:00
Keegan Carruthers-Smith
4ff5fc7ec6
nix: up max_connections and enforce no locale for postgres (#42979)
I had to do both of these to make "go test ./..." happy on my devenv.

Test Plan: go test ./... passes.
2022-10-14 12:26:49 +01:00
Keegan Carruthers-Smith
061c217e47
nix: set REDIS_ENDPOINT envvar (#42971)
Some of our tests seem to depend on this environment variable being set.
It not being set doesn't lead to them failing, but rather a lot of log
spam. Setting this avoids the logspam.

Test Plan: go test ./internal/repos has less noise
2022-10-14 10:34:43 +01:00
Noah S-C
b071fb8103
nix: postgres listen on localhost (#34464) 2022-04-27 15:34:18 +01:00
Keegan Carruthers-Smith
31e0e1f5b4
nix: specify PGUSER (#25546)
sg adds a default PGUSER=sourcegraph. However, our auto database support
in nix uses the current user since it is via a unix socket.
2021-09-30 13:23:43 +02:00
Chris Wendt
3221127616
symbols: replace pcre lib with a Go function (fixup 2) (#25421) 2021-09-27 19:38:37 -06:00
Chris Wendt
b8d53fe0f2
Revert "symbols: replace pcre lib with a Go function (fixup) (#25401)" (#25410)
This reverts commit 853892694f.
2021-09-27 18:48:04 +00:00
Chris Wendt
853892694f
symbols: replace pcre lib with a Go function (fixup) (#25401) 2021-09-27 17:24:18 +00:00
Chris Wendt
30a83db7dd
Revert "symbols: replace pcre lib with a Go function (#25374)" (#25398)
This reverts commit 9f78493c78.
2021-09-27 16:23:23 +00:00
Chris Wendt
9f78493c78
symbols: replace pcre lib with a Go function (#25374) 2021-09-27 15:26:34 +00:00