Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions 2026-03-28-pr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# PR Title

Add Nix flake support and fix musl build configuration

# PR Body

## Summary

- add a Nix flake with a default package, dev shell, portable musl build, and exported NixOS module
- add a NixOS module plus README and maintainer docs for running `etserver` from declarative config
- fix the non-vcpkg and musl build path by gating Catch2 on `BUILD_TESTING`, adding protobuf/absl/`utf8_range` link handling, and improving static `libunwind` linking
- make `format.sh` work in Nix environments by falling back to `clang-format` or `nix run` when `clang-format-18` is not present

## Testing

- `bash format.sh`
- `nix develop path:. --command bash -lc 'cmake -S . -B build -GNinja -DDISABLE_VCPKG=ON -DDISABLE_TELEMETRY=ON'`
- `nix develop path:. --command bash -lc 'cmake --build build -j"$(nproc)"'`
- `nix develop path:. --command bash -lc 'ctest --test-dir build --parallel "$(nproc)"'`

## Notes

- this keeps the Nix and musl work without reintroducing generated `build-musl/` artifacts or oversized binaries
63 changes: 58 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ project(EternalTCP VERSION 6.2.11 LANGUAGES C CXX)

include(CMakeFindDependencyMacro)

option(BUILD_TESTING "Build tests" ON)

# Add cmake script directory.
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_MODULE_PATH "${EXTERNAL_DIR}/sanitizers-cmake/cmake" ${CMAKE_MODULE_PATH})
Expand All @@ -131,7 +133,9 @@ find_package(Protobuf REQUIRED)
find_package(Unwind)

if(DISABLE_VCPKG)
add_subdirectory(${EXTERNAL_DIR}/Catch2)
if(BUILD_TESTING)
add_subdirectory(${EXTERNAL_DIR}/Catch2)
endif()
add_subdirectory(${EXTERNAL_DIR}/cxxopts)
add_subdirectory(${EXTERNAL_DIR}/cpp-httplib)
add_subdirectory(${EXTERNAL_DIR}/json)
Expand All @@ -144,7 +148,9 @@ if(DISABLE_VCPKG)
${EXTERNAL_DIR}/cxxopts/include
)
else()
find_package(Catch2 CONFIG REQUIRED)
if(BUILD_TESTING)
find_package(Catch2 CONFIG REQUIRED)
endif()
find_package(httplib CONFIG REQUIRED)
find_package(cxxopts CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
Expand Down Expand Up @@ -210,7 +216,6 @@ endif()

option(CODE_COVERAGE "Enable code coverage" OFF)
option(FUZZING "Enable builds for fuzz testing" OFF)
option(BUILD_TESTING "Build tests" ON)
option(DISABLE_CRASH_LOG "Disable installing easylogging crash handler" OFF)
option(INSTALL_BASH_COMPLETION "Install bash completion script" ON)
option(INSTALL_ZSH_COMPLETION "Install zsh completion script" ON)
Expand Down Expand Up @@ -261,8 +266,57 @@ set(PROTOBUF_LIBS protobuf::libprotobuf)
if(Protobuf_VERSION VERSION_GREATER_EQUAL 4)
find_package(absl REQUIRED)
find_package(utf8_range CONFIG REQUIRED)
set(PROTOBUF_ABSL_LIBS
absl::absl_check
absl::absl_log
absl::algorithm
absl::base
absl::bind_front
absl::bits
absl::btree
absl::cleanup
absl::cord
absl::core_headers
absl::debugging
absl::die_if_null
absl::dynamic_annotations
absl::flags
absl::flat_hash_map
absl::flat_hash_set
absl::function_ref
absl::hash
absl::layout
absl::log_globals
absl::log_initialize
absl::log_internal_check_op
absl::log_severity
absl::memory
absl::node_hash_map
absl::node_hash_set
absl::optional
absl::random_distributions
absl::random_random
absl::span
absl::status
absl::statusor
absl::strings
absl::synchronization
absl::time
absl::utility
utf8_range::utf8_validity
utf8_range::utf8_range
)

set(PROTOBUF_LIBS ${PROTOBUF_LIBS} absl::log_internal_check_op utf8_range::utf8_validity utf8_range::utf8_range)
if(Protobuf_USE_STATIC_LIBS)
set(PROTOBUF_LIBS
-Wl,--start-group
${PROTOBUF_LIBS}
${PROTOBUF_ABSL_LIBS}
-Wl,--end-group
)
else()
set(PROTOBUF_LIBS ${PROTOBUF_LIBS} ${PROTOBUF_ABSL_LIBS})
endif()
endif()

if(SELINUX_FOUND)
Expand Down Expand Up @@ -322,7 +376,6 @@ else()
resolv
atomic
stdc++fs
anl
)
endif()

Expand Down
92 changes: 92 additions & 0 deletions NIXOS-readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# EternalTerminal on NixOS

This repo adds Nix support on top of the upstream CMake and Debian-style packaging.

## Changes from base

- `flake.nix` adds:
- `packages.default` and `packages.eternal-terminal`
- `devShells.default`
- `nixosModules.default` and `nixosModules.eternalTerminal`
- `default.nix` adds a NixOS module for running `etserver`
- `CMakeLists.txt` gates Catch2 behind `BUILD_TESTING=ON` so Nix package builds do not pull test-only dependencies

## Nix behavior in this repo

- Flake builds use `DISABLE_VCPKG=ON`, `DISABLE_SENTRY=ON`, `DISABLE_TELEMETRY=ON`, and `BUILD_TESTING=OFF`.
- The flake uses `inputs.self.submodules = true`, so consumers fetch the vendored submodules needed by the build.
- The package source is filtered with `lib.cleanSourceWith` so local `build/`, `cov_build/`, and `result/` directories do not leak into Nix builds.

## Using it with Nix

For a local checkout, use `path:.`:

```bash
nix flake show path:.
nix develop path:.
nix build path:. --no-link
```

`nix develop` gives you a shell with the package inputs and the extra developer tools needed for normal CMake work on NixOS.

## Using it with NixOS: module + package

Common setup: import the NixOS module for the service, and add the package if you also want the client tools in `PATH`.

The module manages the server side:

- generates `/etc/et.cfg`
- starts `etserver` from the selected package
- opens the configured port when `openFirewall = true`

Example flake-based NixOS configuration:

```nix
{
inputs.et.url = "github:MisterTea/EternalTerminal";

outputs = { nixpkgs, et, ... }: {
nixosConfigurations.my-host = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
et.nixosModules.default
({ pkgs, ... }: {
environment.systemPackages = [
et.packages.${pkgs.stdenv.hostPlatform.system}.default
];

services.eternalTerminal = {
enable = true;
openFirewall = true;
port = 2022;
settings.Networking.bind_ip = "0.0.0.0";
};
})
];
};
};
}
```

Notes:

- The module runs the server, but it does not add the client tools to `PATH` by itself. Add the package to `environment.systemPackages` if you also want `et`, `htm`, and the other binaries available interactively.
- When imported through the flake, `services.eternalTerminal.package` defaults to the flake package.
- When importing `./default.nix` directly, set `services.eternalTerminal.package` yourself.

## Module options

- `services.eternalTerminal.enable`
- `services.eternalTerminal.package`
- `services.eternalTerminal.port`
- `services.eternalTerminal.openFirewall`
- `services.eternalTerminal.settings`

`services.eternalTerminal.settings` is written as INI sections into `/etc/et.cfg`. `Networking.port` is always taken from `services.eternalTerminal.port`.

## Service checks

```bash
systemctl status eternal-terminal
journalctl -u eternal-terminal -b
```
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,34 @@ make
sudo make install
```

### NixOS

If you use flakes, you can import the bundled NixOS module and let it manage
the package, `/etc/et.cfg`, and the `etserver` service:

```nix
{
inputs.et.url = "github:MisterTea/EternalTerminal";

outputs = { nixpkgs, et, ... }: {
nixosConfigurations.my-host = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
et.nixosModules.default
({ ... }: {
services.eternalTerminal = {
enable = true;
openFirewall = true;
port = 2022;
settings.Networking.bind_ip = "0.0.0.0";
};
})
];
};
};
}
```

### Windows

Eternal Terminal works under WSL (Windows Subsystem for Linux). Follow the ubuntu instructions.
Expand All @@ -148,7 +176,10 @@ You are ready to start using ET!

## Configuring

If you'd like to modify the server settings (e.g. to change the listening port), edit /etc/et.cfg.
If you'd like to modify the server settings (e.g. to change the listening
port), edit `/etc/et.cfg`. On NixOS, set `services.eternalTerminal.settings`
instead so the generated `/etc/et.cfg` stays in sync with your system
configuration.

## Using

Expand Down
19 changes: 18 additions & 1 deletion cmake/FindUnwind.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ if (PKG_CONFIG_FOUND)
pkg_check_modules(PC_UNWIND QUIET libunwind)
endif()

if (PC_UNWIND_FOUND)
set(Unwind_EXTRA_LIBRARIES ${PC_UNWIND_LINK_LIBRARIES})
if (PC_UNWIND_STATIC_LINK_LIBRARIES)
set(Unwind_STATIC_EXTRA_LIBRARIES ${PC_UNWIND_STATIC_LINK_LIBRARIES})
endif()
endif()

find_path (Unwind_INCLUDE_DIR
NAMES unwind.h libunwind.h
HINTS ${PC_UNWIND_INCLUDE_DIRS}
Expand Down Expand Up @@ -89,13 +96,23 @@ find_package_handle_standard_args (Unwind REQUIRED_VARS Unwind_INCLUDE_DIR

if (Unwind_FOUND)
if (NOT TARGET unwind::unwind)
set(_Unwind_LINK_LIBRARIES ${Unwind_LIBRARY} ${Unwind_PLATFORM_LIBRARY})
if (Unwind_LIBRARY MATCHES "\\.a$")
list(APPEND _Unwind_LINK_LIBRARIES ${Unwind_STATIC_EXTRA_LIBRARIES})
if (UNIX)
list(APPEND _Unwind_LINK_LIBRARIES lzma)
endif()
else()
list(APPEND _Unwind_LINK_LIBRARIES ${Unwind_EXTRA_LIBRARIES})
endif()

add_library (unwind::unwind INTERFACE IMPORTED)

set_property (TARGET unwind::unwind PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${Unwind_INCLUDE_DIR}
)
set_property (TARGET unwind::unwind PROPERTY
INTERFACE_LINK_LIBRARIES ${Unwind_LIBRARY} ${Unwind_PLATFORM_LIBRARY}
INTERFACE_LINK_LIBRARIES ${_Unwind_LINK_LIBRARIES}
)
set_property (TARGET unwind::unwind PROPERTY
IMPORTED_CONFIGURATIONS RELEASE
Expand Down
Loading
Loading