Skip to content

Commit

Permalink
perf: Don't install haskell documentation.
Browse files Browse the repository at this point in the history
This is an attempt at reducing the size of the docker images.
  • Loading branch information
iphydf committed Nov 5, 2024
1 parent 966eb0c commit 7198bbf
Show file tree
Hide file tree
Showing 12 changed files with 164 additions and 113 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install mypy
Expand Down
23 changes: 13 additions & 10 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
workspace(name = "toktok")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//third_party:nixpkgs.bzl", "GCC_LIB", "GHC_VERSION", "LD_LINUX", "NIXOS_SHA256", "NIXOS_VERSION", "PATCHELF")
load("//tools/workspace:github.bzl", "github_archive", "new_github_archive")

# https://github.com/bazelbuild/bazel-skylib
Expand Down Expand Up @@ -196,8 +197,8 @@ load(

nixpkgs_git_repository(
name = "nixpkgs",
revision = "23.11",
sha256 = "bc9a0a74e8d7fb0e11434dd3abaa0cb0572ccd3a65b5a192eea41832b286e8a0",
revision = NIXOS_VERSION,
sha256 = NIXOS_SHA256,
)

nixpkgs_cc_configure(
Expand Down Expand Up @@ -267,7 +268,7 @@ nixpkgs_package(
# =========================================================

nixpkgs_java_configure(
attribute_path = "jdk11.home",
attribute_path = "jdk11_headless.home",
repository = "@nixpkgs",
toolchain = True,
toolchain_name = "nixpkgs_java",
Expand Down Expand Up @@ -295,16 +296,16 @@ http_archive(
patch_cmds = [
"chmod 755 java_tools/ijar/ijar",
"{patchelf} --set-interpreter {ld_linux} --add-rpath {gcc_lib} java_tools/ijar/ijar".format(
gcc_lib = "/nix/store/myw67gkgayf3s2mniij7zwd79lxy8v0k-gcc-12.3.0-lib/lib",
ld_linux = "/nix/store/qn3ggz5sf3hkjs2c797xf7nan3amdxmp-glibc-2.38-27/lib64/ld-linux-x86-64.so.2",
patchelf = "/nix/store/85jldj870vzcl72yz03labc93bwvqayx-patchelf-0.15.0/bin/patchelf",
gcc_lib = GCC_LIB,
ld_linux = LD_LINUX,
patchelf = PATCHELF,
),
"chmod 555 java_tools/ijar/ijar",
"chmod 755 java_tools/src/tools/singlejar/singlejar_local",
"{patchelf} --set-interpreter {ld_linux} --add-rpath {gcc_lib} java_tools/src/tools/singlejar/singlejar_local".format(
gcc_lib = "/nix/store/myw67gkgayf3s2mniij7zwd79lxy8v0k-gcc-12.3.0-lib/lib",
ld_linux = "/nix/store/qn3ggz5sf3hkjs2c797xf7nan3amdxmp-glibc-2.38-27/lib64/ld-linux-x86-64.so.2",
patchelf = "/nix/store/85jldj870vzcl72yz03labc93bwvqayx-patchelf-0.15.0/bin/patchelf",
gcc_lib = GCC_LIB,
ld_linux = LD_LINUX,
patchelf = PATCHELF,
),
"chmod 555 java_tools/src/tools/singlejar/singlejar_local",
],
Expand Down Expand Up @@ -380,13 +381,15 @@ haskell_register_ghc_nixpkgs(
"-fdiagnostics-color=always",
# TODO(iphydf): Move to hs-cimple.
"-Wno-redundant-constraints",
# TODO(iphydf): Move to hs-schema.
"-Wno-unused-imports",
"-optc=-Wno-unused-command-line-argument",
"-optl=-Wl,--no-fatal-warnings",
],
nix_file = "//:ghc.nix",
repositories = {"nixpkgs": "@nixpkgs"},
#static_runtime = True,
version = "9.4.8",
version = GHC_VERSION,
)

[nixpkgs_package(
Expand Down
2 changes: 1 addition & 1 deletion ci-tools
2 changes: 1 addition & 1 deletion dockerfiles
182 changes: 92 additions & 90 deletions ghc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,94 +2,96 @@
with (import <nixpkgs> { });

{
ghc = haskellPackages.ghcWithPackages (p: with p; [
aeson
aeson-pretty
ansi-wl-pprint
array
async
base
base16-bytestring
binary
binary-conduit
brick
bytestring
case-insensitive
casing
clock
conduit
conduit-extra
containers
cryptohash
data-binary-ieee754
data-default-class
data-fix
deepseq
Diff
directory
edit-distance
entropy
exceptions
expiring-cache-map
extra
file-embed
filepath
generic-arbitrary
github
groom
hashable
hspec
html
http-client
http-client-tls
http-media
http-types
integer-gmp
iproute
insert-ordered-containers
language-c
lens-family
microlens
microlens-mtl
microlens-th
monad-control
monad-parallel
MonadRandom
monad-validate
mtl
network
parallel
pretty
process
QuickCheck
quickcheck-instances
quickcheck-text
random
recursion-schemes
saltine
scientific
servant
servant-server
split
suspend
tabular
text
text-zipper
time
timers
transformers
transformers-compat
unix
unliftio-core
unordered-containers
uuid
vector
vty
wai
wai-cors
wai-extra
warp
word-wrap
yaml
]);
ghc = haskellPackages.ghcWithPackages.override { installDocumentation = false; } (
p: with p; [
aeson
aeson-pretty
ansi-wl-pprint
array
async
base
base16-bytestring
binary
binary-conduit
brick
bytestring
case-insensitive
casing
clock
conduit
conduit-extra
containers
cryptohash
data-binary-ieee754
data-default-class
data-fix
deepseq
Diff
directory
edit-distance
entropy
exceptions
expiring-cache-map
extra
file-embed
filepath
generic-arbitrary
github
groom
hashable
hspec
html
http-client
http-client-tls
http-media
http-types
integer-gmp
iproute
insert-ordered-containers
language-c
lens-family
microlens
microlens-mtl
microlens-th
monad-control
monad-parallel
MonadRandom
monad-validate
mtl
network
parallel
pretty
process
QuickCheck
quickcheck-instances
quickcheck-text
random
recursion-schemes
saltine
scientific
servant
servant-server
split
suspend
tabular
text
text-zipper
time
timers
transformers
transformers-compat
unix
unliftio-core
unordered-containers
uuid
vector
vty
wai
wai-cors
wai-extra
warp
word-wrap
yaml
]
);
}
4 changes: 0 additions & 4 deletions heroku.yml

This file was deleted.

4 changes: 4 additions & 0 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"include": ["/src/workspace"],
"exclude": ["bazel-*"]
}
35 changes: 35 additions & 0 deletions third_party/nixpkgs.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
Hard-coded paths to Nixpkgs binaries.
"""

# 23.11

NIXOS_VERSION = "23.11"
NIXOS_SHA256 = "bc9a0a74e8d7fb0e11434dd3abaa0cb0572ccd3a65b5a192eea41832b286e8a0"

GHC_VERSION = "9.4.8"

# Need to add this to rpath.
GCC_LIB = "/nix/store/myw67gkgayf3s2mniij7zwd79lxy8v0k-gcc-12.3.0-lib/lib"

# Need to change the interpreter to the one from glibc.
LD_LINUX = "/nix/store/qn3ggz5sf3hkjs2c797xf7nan3amdxmp-glibc-2.38-27/lib64/ld-linux-x86-64.so.2"

# Tool to patch the binary with the above two changes.
PATCHELF = "/nix/store/85jldj870vzcl72yz03labc93bwvqayx-patchelf-0.15.0/bin/patchelf"

# # 24.05

# NIXOS_VERSION = "24.05"
# NIXOS_SHA256 = "911314b81780f26fdaf87e17174210bdbd40c86bac1795212f257cdc236a1e78"

# GHC_VERSION = "9.6.5"

# # Need to add this to rpath.
# GCC_LIB = "/nix/store/d4dzkmwkyrkc1l8z9x7vcdj193fx4g45-gcc-12.3.0-lib/lib"

# # Need to change the interpreter to the one from glibc.
# LD_LINUX = "/nix/store/k7zgvzp2r31zkg9xqgjim7mbknryv6bs-glibc-2.39-52/lib64/ld-linux-x86-64.so.2"

# # Tool to patch the binary with the above two changes.
# PATCHELF = "/nix/store/nbad47q0m0m9c5xid7zh05hiknwircbp-patchelf-0.15.0/bin/patchelf"
15 changes: 13 additions & 2 deletions third_party/zig/toolchains.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
"""
Toolchain definitions for Zig.
"""

load("@rules_zig//zig:toolchain.bzl", "zig_target_toolchain")
load("//third_party:nixpkgs.bzl", "LD_LINUX")

CPUS = {
"aarch64": {
Expand All @@ -7,11 +12,17 @@ CPUS = {
},
"x86_64": {
"cpu": "x86_64",
"dynamic_linker": "/nix/store/qn3ggz5sf3hkjs2c797xf7nan3amdxmp-glibc-2.38-27/lib/ld-linux-x86-64.so.2",
"dynamic_linker": LD_LINUX,
},
}

def zig_nix_toolchains():
def zig_nix_toolchains(name = "zig_nix_toolchains"):
"""
Define toolchains for each supported CPU.
Args:
name: The name of the rule (unused).
"""
for arch in CPUS:
native.platform(
name = arch + "-linux-gnu",
Expand Down
4 changes: 2 additions & 2 deletions tools/built/src/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ FROM toxchat/toktok-stack:latest-fastbuild
ENV USER=builder

RUN sudo nix-daemon --daemon & sleep 1 \
&& nix-channel --add https://github.com/NixOS/nixpkgs/archive/refs/tags/23.11.tar.gz nixpkgs \
&& nix-channel --add https://github.com/nix-community/home-manager/archive/release-23.11.tar.gz home-manager \
&& nix-channel --add "https://github.com/NixOS/nixpkgs/archive/refs/tags/$NIXOS_VERSION.tar.gz" nixpkgs \
&& nix-channel --add "https://github.com/nix-community/home-manager/archive/release-$NIXOS_VERSION.tar.gz" home-manager \
&& nix-channel --update \
&& nix-shell '<home-manager>' -A install

Expand Down
2 changes: 1 addition & 1 deletion tools/built/src/Dockerfile.third_party
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ WORKDIR /src/workspace
RUN sudo nix-daemon --daemon & bazel aquery --output=proto --show_timestamps //... > /dev/null

# TODO(https://github.com/tweag/rules_nixpkgs/issues/439): Remove.
RUN sudo sed -Eie "s!\b(mktemp|rm)\b!$(echo -n /nix/store/*-coreutils-9.3/bin/)\1!" /nix/store/*-clang-wrapper-*/bin/cc
RUN sudo sed -Eie 's!\b(mktemp |rm )!'"$(echo -n /nix/store/*-coreutils-*/bin/)"'\1!' /nix/store/*-clang-wrapper-*/bin/cc

# vim:ft=dockerfile

0 comments on commit 7198bbf

Please sign in to comment.