Skip to content

Commit

Permalink
cleanup: Add tor to home; fix inject-repo for cirrus.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Nov 6, 2023
1 parent 2c79bff commit 9fa6249
Show file tree
Hide file tree
Showing 24 changed files with 160 additions and 127 deletions.
5 changes: 4 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ build:docker-sandbox --strategy=Javac=docker
#
# TODO(https://github.com/tweag/rules_haskell/issues/1265): Enable this by
# default once rules_haskell supports it.
build:sandboxfs --experimental_use_sandboxfs=auto
build:sandboxfs --experimental_sandboxfs_path=/home/builder/.bin/sandboxfs
build:sandboxfs --experimental_use_sandboxfs
build:sandboxfs --experimental_use_windows_sandbox=auto

##############################################################################
Expand Down Expand Up @@ -158,6 +159,8 @@ build:release -c opt
# NDEBUG disables asserts.
#build:release --copt='-Wno-unused-variable'

build:strace --run_under="/run/current-system/sw/bin/strace -f"

build:dynamic-analysis --jobs=4
build:dynamic-analysis --test_timeout=300
build:dynamic-analysis --strip=never
Expand Down
21 changes: 0 additions & 21 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
[submodule "dockerfiles"]
path = dockerfiles
url = https://github.com/TokTok/dockerfiles
[submodule "echobot-jvm"]
path = echobot-jvm
url = https://github.com/TokTok/echobot-jvm
[submodule "experimental"]
path = experimental
url = https://github.com/TokTok/experimental
Expand Down Expand Up @@ -64,21 +61,6 @@
[submodule "js-toxcore-c"]
path = js-toxcore-c
url = https://github.com/TokTok/js-toxcore-c
[submodule "jtox"]
path = jtox
url = https://github.com/TokTok/jtox
[submodule "jvm-macros"]
path = jvm-macros
url = https://github.com/TokTok/jvm-macros
[submodule "jvm-sbt-plugins"]
path = jvm-sbt-plugins
url = https://github.com/TokTok/jvm-sbt-plugins
[submodule "jvm-toxcore-api"]
path = jvm-toxcore-api
url = https://github.com/TokTok/jvm-toxcore-api
[submodule "jvm-toxcore-c"]
path = jvm-toxcore-c
url = https://github.com/TokTok/jvm-toxcore-c
[submodule "py-toxcore-c"]
path = py_toxcore_c
url = https://github.com/TokTok/py-toxcore-c
Expand All @@ -88,9 +70,6 @@
[submodule "spec"]
path = spec
url = https://github.com/TokTok/spec
[submodule "streambot-jvm"]
path = streambot-jvm
url = https://github.com/TokTok/streambot-jvm
[submodule "tools/.github"]
path = tools/.github
url = https://github.com/TokTok/.github
Expand Down
33 changes: 33 additions & 0 deletions .ycm_extra_conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import os.path as p

GLIBC_FLAGS = [
"-isystem",
"/nix/store/rfw51dqr3qn7b6fjy8hmx6f0x3hfwbx6-glibc-2.37-8-dev/include",
]

database = None

compilation_database_folder = p.abspath(p.dirname(__file__))

def Settings(**kwargs):
import ycm_core

global database
if database is None and p.exists(compilation_database_folder):
database = ycm_core.CompilationDatabase(compilation_database_folder)

language = kwargs['language']

if language == 'cfamily':
filename = kwargs['filename']

compilation_info = database.GetCompilationInfoForFile(filename)
if not compilation_info.compiler_flags_:
return {}

return {
'flags': list(compilation_info.compiler_flags_) + GLIBC_FLAGS,
'include_paths_relative_to_dir': compilation_info.compiler_working_dir_,
}

return {}
10 changes: 8 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ go_rules_dependencies()
github_archive(
name = "rules_haskell",
repo = "tweag/rules_haskell",
sha256 = "dfb99ad2788a65bba2400b7801c3241839220c033eb41a141f7fc434f4796543",
version = "48df56b32710e7894079cde1a91b2701667fa518",
sha256 = "c9c2dc3d1a97e8b16d85c73d45d7f8c3a8d3bb7b35783c4305e61e0aed8a3ea5",
version = "2d0942ec1d9ad239c44c6cfc635fa7e51cd0f0f3",
)

load(
Expand Down Expand Up @@ -556,6 +556,12 @@ QT_LIBS = [
"svg",
]

nixpkgs_package(
name = "qt5.qtbase.bin",
build_file = "//third_party/qt:BUILD.qtbase.bin",
repository = "@nixpkgs",
)

[nixpkgs_package(
name = "qt5.qt%s.out" % lib,
build_file = "//third_party/qt:BUILD.qt%s.out" % lib,
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles
11 changes: 10 additions & 1 deletion third_party/BUILD.diffutils
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@ alias(
visibility = ["//visibility:public"],
)

alias(
name = "diff",
actual = "bin/diff",
visibility = ["//visibility:public"],
)

filegroup(
name = "diffutils",
srcs = [":cmp"],
srcs = [
":cmp",
":diff",
],
visibility = ["//visibility:public"],
)
6 changes: 6 additions & 0 deletions third_party/BUILD.qt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ package(features = ["layering_check"])
"lconvert",
]]

alias(
name = "qt_platform",
actual = "@qt5.qtbase.bin//:platforms",
visibility = ["//visibility:public"],
)

[alias(
name = "qt_" + mod.lower(),
actual = "@qt5.qtbase.dev//:" + mod.lower(),
Expand Down
5 changes: 5 additions & 0 deletions third_party/qt/BUILD.qtbase.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
filegroup(
name = "platforms",
srcs = glob(["lib/qt-*/plugins/platforms/*offscreen*"]),
visibility = ["//visibility:public"],
)
3 changes: 3 additions & 0 deletions third_party/qt/build_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ def qt_test(name, src, deps, copts = [], mocopts = [], size = None):
size = size,
srcs = [src],
copts = copts + ["-I$(GENDIR)/%s/%s" % (native.package_name(), src[:src.rindex("/")])],
# TODO(iphydf): Infer this, rather than hard-coding the Qt version number.
env = {"QT_PLUGIN_PATH": "external/qt5.qtbase.bin/lib/qt-5.15.9/plugins"},
data = ["@qt//:qt_platform"],
deps = deps + [
":%s_moc" % name,
"@qt//:qt_test",
Expand Down
10 changes: 10 additions & 0 deletions tools/built/build-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

set -eux

# Build the entire set of docker images for the toktok dev container.
(cd dockerfiles/buildfarm/bazel && ./build.sh)
docker build -t toxchat/toktok-stack:latest-third_party -f tools/built/src/Dockerfile.third_party .
docker build -t toxchat/toktok-stack:latest -f tools/built/src/Dockerfile .
docker build -t toxchat/toktok-stack:latest-fastbuild -f tools/built/src/Dockerfile.fastbuild .
docker build -t toxchat/toktok-stack:latest-dev -f tools/built/src/Dockerfile.dev .
6 changes: 5 additions & 1 deletion tools/built/dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ FROM toxchat/toktok-stack:latest-dev

# Add user config overrides and keys.
COPY --chown=builder:users home /home/builder/

# Also for local development: add this file again, so local changes are
# reflected.
COPY --chown=builder:users workspace/tools/built/dev/setup-local.sh /src/workspace/tools/built/dev/
# Set up Vundle and any plugins the user may want.
RUN ["/src/workspace/tools/built/src/setup-local.sh"]
RUN ["/src/workspace/tools/built/dev/setup-local.sh"]

# Return to root, so that "docker run" can run /usr/sbin/init.
# hadolint ignore=DL3002
Expand Down
2 changes: 1 addition & 1 deletion tools/built/dev/deploy_dev_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ shift
if [ "$*" = "-u" ]; then
docker pull toxchat/toktok-stack:latest-dev
fi
tar c home workspace/tools/built/dev/Dockerfile |
tar c home workspace/tools/built/dev |
docker build -t "$IMAGE" -f workspace/tools/built/dev/Dockerfile -
sudo systemctl restart docker-toktok
sudo journalctl -f -u docker-toktok
File renamed without changes.
File renamed without changes.
9 changes: 1 addition & 8 deletions tools/built/src/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,7 @@ ENV BAZEL_COMPDB_BAZEL_PATH=bazel-nomodules
# extension of the Dockerfile, so we copy it here. On CI builds, they are
# the same file.
COPY tools/built/src/setup-dev.sh /src/workspace/tools/built/src/
#RUN ["/src/workspace/tools/built/src/setup-dev.sh"]

# Also for local development: add this file again, so local changes are
# reflected.
COPY tools/built/src/init.sh tools/built/src/setup-local.sh /src/workspace/tools/built/src/
#CMD ["/src/workspace/tools/built/src/init.sh"]

#RUN ["sudo", "usermod", "-s", "/home/builder/.nix-profile/bin/zsh", "builder"]
RUN ["/src/workspace/tools/built/src/setup-dev.sh"]

VOLUME [ "/sys/fs/cgroup" ]
EXPOSE 22/tcp
Expand Down
24 changes: 22 additions & 2 deletions tools/built/src/home/.config/home-manager/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
home.username = "builder";
home.homeDirectory = "/home/builder";
home.sessionVariables = { EDITOR = "nvim"; };
home.sessionPath = [ "/src/workspace/hs-github-tools/tools" ];
home.sessionPath = [
"${config.home.homeDirectory}/.bin"
"/src/workspace/hs-github-tools/tools"
];

# Packages that should be installed to the user profile.
home.packages = with pkgs; [
connect # for ssh proxy via tor
gnupg
openssh
screen # terminal window manager
tor
];

# This value determines the Home Manager release that your
Expand Down Expand Up @@ -44,15 +48,31 @@

programs.neovim = {
enable = true;
plugins = with pkgs.vimPlugins; [ jellybeans-vim vim-nix YouCompleteMe ];
plugins = with pkgs.vimPlugins; [
jellybeans-vim
vim-bazel
vim-nix
YouCompleteMe
];

extraConfig = ''
colorscheme jellybeans
set expandtab
set nowrap
set viminfo='500,\"800
set scrolloff=5
set sidescrolloff=3
set cursorline
set backup
set backupdir=~/.local/state/nvim/backup/
let g:ycm_extra_conf_globlist = ['/src/workspace/.ycm_extra_conf.py']
nnoremap <C-l> :noh<CR><C-l>
map Q gqap
au FileType bzl set ts=4 sw=4
'';
};

Expand Down
23 changes: 0 additions & 23 deletions tools/built/src/init.sh

This file was deleted.

22 changes: 16 additions & 6 deletions tools/built/src/setup-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ set -eux
BUILDTOOLS_VERSION="v6.3.3"
BCDB_VERSION="0.5.2"

mkdir -p "$HOME/.bin"
export PATH="$PATH:$HOME/.bin"

for prog in buildifier buildozer unused_deps; do
wget -q -O "$prog" "https://github.com/bazelbuild/buildtools/releases/download/$BUILDTOOLS_VERSION/$prog-linux-amd64"
sudo install -o root -g root -m 755 "$prog" "/usr/local/bin/$prog"
curl -L -s -o "$prog" "https://github.com/bazelbuild/buildtools/releases/download/$BUILDTOOLS_VERSION/$prog-linux-amd64"
sudo install -o root -g root -m 755 "$prog" "$HOME/.bin/$prog"
rm -f "$prog"
done

sudo install -o root -g root -m 755 tools/built/src/bazel-nomodules /usr/local/bin/bazel-nomodules
sudo install -o root -g root -m 755 tools/built/src/bazel-nomodules "$HOME/.bin/bazel-nomodules"

echo "export BAZEL_COMPDB_BAZEL_PATH=$BAZEL_COMPDB_BAZEL_PATH" >>~/.zlogin

INSTALL_DIR="/usr/local/bin"
INSTALL_DIR="$HOME/.bin"

# Download and symlink.
(
Expand All @@ -27,6 +31,12 @@ INSTALL_DIR="/usr/local/bin"
# that in the toktok-stack builds. It's checked in the submodule builds.
tools/project/update_versions.sh

bazel-compdb
# Start nix-daemon if it isn't running yet.
if [ ! -f /nix/var/nix/daemon-socket/socket ]; then
sudo nix-daemon --daemon &
sleep 1
fi

nix-shell -p python3 --run "python3 $HOME/.bin/bazel-compdb"
bazel build --show_timestamps //...
# tools/retry 5 bazel test --show_timestamps -- //...
tools/retry 5 bazel test --show_timestamps -- //...
29 changes: 0 additions & 29 deletions tools/git-remotes
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ our %REPOS = (
upstream => 'toktok',
repo 'iphydf',
}],
'echobot-jvm' => ['echobot-jvm', {
upstream => 'toktok',
repo 'iphydf',
}],
'experimental' => ['experimental', {
upstream => 'toktok',
repo 'iphydf',
Expand Down Expand Up @@ -135,27 +131,6 @@ our %REPOS = (
upstream => 'toktok',
repo 'iphydf',
}],
'jtox' => ['jtox', {
upstream => 'toktok',
repo 'iphydf',
}],
'jvm-macros' => ['jvm-macros', {
upstream => 'toktok',
repo 'iphydf',
}],
'jvm-sbt-plugins' => ['jvm-sbt-plugins', {
upstream => 'toktok',
repo 'iphydf',
}],
'jvm-toxcore-c' => ['jvm-toxcore-c', {
upstream => 'toktok',
repo 'iphydf',
repo 'zoff99',
}],
'jvm-toxcore-api' => ['jvm-toxcore-api', {
upstream => 'toktok',
repo 'iphydf',
}],
'py_toxcore_c' => ['py-toxcore-c', {
upstream => 'toktok',
repo ['aitjcize', 'PyTox'],
Expand All @@ -170,10 +145,6 @@ our %REPOS = (
upstream => 'toktok',
repo 'iphydf',
}],
'streambot-jvm' => ['streambot-jvm', {
upstream => 'toktok',
repo 'iphydf',
}],
'tools/.github' => ['.github', {
upstream => 'toktok',
repo 'iphydf',
Expand Down
2 changes: 1 addition & 1 deletion tools/inject-repo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

set -eux

Expand Down
Loading

0 comments on commit 9fa6249

Please sign in to comment.