Skip to content

Commit 995a373

Browse files
committed
Convert to Nix flakes and updates some of the dependencies
1 parent 7f17117 commit 995a373

File tree

21 files changed

+765
-302
lines changed

21 files changed

+765
-302
lines changed

.dir-locals.el

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
((nil .
2-
((indent-tabs-mode . nil)
3-
(show-trailing-whitespace . t)))
4-
(c-mode .
5-
((mode . c++)))
6-
(c++-mode .
7-
((eval add-hook 'before-save-hook #'clang-format-buffer nil t))))
1+
((nil
2+
. ((indent-tabs-mode . nil)
3+
(show-trailing-whitespace . t)))
4+
(c-mode
5+
. ((mode . c++)))
6+
(c++-mode
7+
. ((eval add-hook 'before-save-hook #'clang-format-buffer nil t)))
8+
(nix-mode
9+
. ((mode . nixfmt-on-save)))
10+
(cmake-mode
11+
. ((eval add-hook 'before-save-hook #'cmake-format-buffer nil t))))

.envrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DEV_SHELL=${DEV_SHELL:-default}
2+
use flake ".#${DEV_SHELL}"

.github/workflows/test.yml

Lines changed: 33 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,81 @@
11
name: test
22
on: [push, pull_request]
33
jobs:
4-
build:
4+
5+
nix-matrix:
56
runs-on: ubuntu-latest
7+
outputs:
8+
matrix: ${{ steps.set-matrix.outputs.matrix }}
69
steps:
7-
- uses: actions/checkout@v5
10+
- uses: actions/checkout@v4
811
- uses: cachix/install-nix-action@v31
9-
with:
10-
nix_path: nixpkgs=channel:nixos-unstable
11-
- uses: cachix/cachix-action@v12
12-
with:
13-
name: arximboldi
14-
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
15-
- run: nix-build
12+
- id: set-matrix
13+
name: Generate Nix Matrix
14+
run: |
15+
set -Eeu
16+
matrix="$(nix eval --json '.#githubActions.matrix')"
17+
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
1618
17-
macos:
18-
runs-on: macos-latest
19+
build-nix:
20+
name: "nix: ${{ matrix.name }} (${{ matrix.system }})"
21+
needs: nix-matrix
22+
runs-on: ${{ matrix.os }}
23+
strategy:
24+
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
1925
steps:
20-
- uses: actions/checkout@v5
26+
- uses: actions/checkout@v4
2127
- uses: cachix/install-nix-action@v31
22-
with:
23-
nix_path: nixpkgs=channel:nixos-unstable
24-
- uses: cachix/cachix-action@v12
28+
- uses: cachix/cachix-action@v16
2529
with:
2630
name: arximboldi
2731
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
28-
- run: nix-shell --run 'mkdir build-mac'
29-
- name: configure cmake
30-
run: |
31-
nix-shell --run "
32-
cd build-mac && cmake .. \
33-
-DCMAKE_BUILD_TYPE=Debug
34-
"
35-
- run: nix-shell --run "cd build-mac && make check -j`nproc`"
32+
- run: nix build -L '.#${{ matrix.attr }}'
3633

3734
docs:
3835
runs-on: ubuntu-latest
3936
steps:
40-
- uses: actions/checkout@v5
37+
- uses: actions/checkout@v4
4138
with:
4239
submodules: true
4340
- uses: cachix/install-nix-action@v31
44-
with:
45-
nix_path: nixpkgs=channel:nixos-unstable
46-
- uses: cachix/cachix-action@v12
41+
- uses: cachix/cachix-action@v16
4742
with:
4843
name: arximboldi
4944
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
50-
- run: nix-shell --run "mkdir build"
51-
- run: nix-shell --run "cd build && cmake .."
52-
- run: nix-shell --run "cd build && make docs"
45+
- run: nix develop --command cmake -B build
46+
- run: nix develop --command make -C build docs
5347
- uses: shimataro/ssh-key-action@v2
5448
if: github.repository_owner == 'arximboldi' && github.ref == 'refs/heads/master'
5549
with:
5650
key: ${{ secrets.SINUSOIDES_SSH_KEY }}
5751
known_hosts: ${{ secrets.SINUSOIDES_KNOWN_HOSTS }}
58-
- run: nix-shell --run "cd build && make upload-docs"
52+
- run: nix develop --command make -C build upload-docs
5953
if: github.repository_owner == 'arximboldi' && github.ref == 'refs/heads/master'
6054

6155
check:
6256
strategy:
6357
matrix:
6458
type: [Debug, Release]
65-
compiler: [gcc]
59+
toolchain: [gnu, llvm]
6660
opts: [[]]
6761
include:
6862
- type: Debug
69-
compiler: gcc
63+
toolchain: gnu
7064
opts: ['coverage']
71-
- type: Debug
72-
compiler: clang
7365
runs-on: ubuntu-latest
7466
steps:
75-
- uses: actions/checkout@v5
67+
- uses: actions/checkout@v4
7668
- uses: cachix/install-nix-action@v31
77-
with:
78-
nix_path: nixpkgs=channel:nixos-unstable
79-
- uses: cachix/cachix-action@v12
69+
- uses: cachix/cachix-action@v16
8070
with:
8171
name: arximboldi
8272
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
83-
- run: nix-shell --argstr compiler ${{ matrix.compiler }} --run "mkdir build"
8473
- name: configure cmake
8574
run: |
86-
nix-shell --argstr compiler ${{ matrix.compiler }} --run "
87-
cd build && cmake -GNinja .. \
75+
nix develop .#${{ matrix.toolchain }} --command \
76+
cmake -B build -G Ninja \
8877
-DCMAKE_BUILD_TYPE=${{ matrix.type }} \
8978
-DENABLE_COVERAGE=${{ contains(matrix.opts, 'coverage') }}
90-
"
91-
- run: nix-shell --argstr compiler ${{ matrix.compiler }} --run "cd build && ninja check"
92-
- run: nix-shell --argstr compiler ${{ matrix.compiler }} --run "bash <(curl -s https://codecov.io/bash)"
79+
- run: nix develop .#${{ matrix.toolchain }} --command ninja -C build check
80+
- run: nix develop .#${{ matrix.toolchain }} --command bash -c "bash <(curl -s https://codecov.io/bash)"
9381
if: ${{ contains(matrix.opts, 'coverage') }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ doc/_doxygen
1515
tools/travis/ssh-key
1616
*.qmlc
1717
/.vs
18+
.direnv/

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.8)
1+
cmake_minimum_required(VERSION 3.10)
22
cmake_policy(SET CMP0048 NEW) # enable project VERSION
33
cmake_policy(SET CMP0056 NEW) # honor link flags in try_compile()
44
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
@@ -87,7 +87,7 @@ install(TARGETS lager EXPORT LagerConfig)
8787

8888
# requirements for tests and examples
8989
if (lager_BUILD_TESTS OR lager_BUILD_EXAMPLES)
90-
find_package(Boost 1.56 COMPONENTS system REQUIRED)
90+
find_package(Boost 1.56 CONFIG COMPONENTS system REQUIRED)
9191
find_package(Threads REQUIRED)
9292
find_package(Immer REQUIRED)
9393
find_package(Zug REQUIRED)

default.nix

Lines changed: 23 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,27 @@
1-
with import <nixpkgs> {};
1+
{
2+
flake ? import ./nix/flake-compat.nix { },
3+
pkgs ? import flake.inputs.nixpkgs { },
4+
}:
25

36
let
4-
deps = import ./nix/deps.nix {};
7+
inherit (pkgs) lib;
8+
inherit (import flake.inputs.gitignore { inherit lib; })
9+
gitignoreSource
10+
;
11+
12+
nixFilter = name: type: !(lib.hasSuffix ".nix" name);
13+
srcFilter =
14+
src:
15+
lib.cleanSourceWith {
16+
filter = nixFilter;
17+
src = gitignoreSource src;
18+
};
19+
20+
immer = (import flake.inputs.immer { inherit pkgs; }).packages.${pkgs.system}.default;
21+
zug = (import flake.inputs.zug { inherit pkgs; }).packages.${pkgs.system}.default;
22+
523
in
6-
stdenv.mkDerivation rec {
7-
name = "lager-git";
8-
version = "git";
9-
src = builtins.filterSource (path: type:
10-
baseNameOf path != ".git" &&
11-
baseNameOf path != "build" &&
12-
baseNameOf path != "_build" &&
13-
baseNameOf path != "reports" &&
14-
baseNameOf path != "tools")
15-
./.;
16-
buildInputs = [
17-
ncurses
18-
SDL2
19-
SDL2_ttf
20-
];
21-
nativeBuildInputs = [
22-
cmake
23-
gcc7
24-
sass
25-
pkgs.pkg-config or pkgs.pkgconfig
26-
];
27-
cmakeFlags = [
28-
"-Dlager_BUILD_TESTS=OFF"
29-
"-Dlager_BUILD_EXAMPLES=OFF"
30-
];
31-
propagatedBuildInputs = [
32-
boost
33-
deps.cereal
34-
deps.immer
35-
deps.zug
36-
];
37-
meta = {
38-
homepage = "https://github.com/arximboldi/lager";
39-
description = "library for functional interactive c++ programs";
40-
license = lib.licenses.mit;
41-
};
24+
pkgs.callPackage ./nix/lager.nix {
25+
sources = srcFilter ./.;
26+
inherit immer zug;
4227
}

example/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ find_package(Qt5Gui)
110110
find_package(Qt5Widgets)
111111
find_package(Qt5QuickControls2)
112112

113-
find_package(Boost 1.56)
113+
find_package(Boost 1.56 CONFIG)
114114

115115
if (Qt5Core_FOUND AND Qt5Concurrent_FOUND AND Qt5Gui_FOUND AND Qt5Widgets_FOUND AND Qt5Qml_FOUND AND Qt5QuickControls2_FOUND AND Boost_FOUND)
116116
add_executable(todo-qml EXCLUDE_FROM_ALL

example/counter/ncurses/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void draw(const counter::model& c)
3232
static const auto instructions = " arrow up -- decrease counter\n"
3333
" arrow down -- increase counter\n"
3434
" space bar -- reset counter";
35-
auto message = prelude + std::to_string(c.value);
35+
auto message = prelude + std::to_string(c.value);
3636
auto max_x = 0, max_y = 0;
3737
getmaxyx(stdscr, max_y, max_x);
3838
const auto border_y = 2, border_x = 4;
@@ -58,7 +58,7 @@ void draw(const counter::model& c)
5858

5959
int main(int argc, const char** argv)
6060
{
61-
auto serv = boost::asio::io_service{};
61+
auto serv = boost::asio::io_context{};
6262
auto term = ncurses::terminal{serv};
6363
::init_pair(1, COLOR_WHITE, COLOR_GREEN);
6464
::init_pair(2, COLOR_WHITE, COLOR_RED);

example/counter/ncurses/terminal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ using namespace std::string_literals;
2121

2222
namespace ncurses {
2323

24-
terminal::terminal(boost::asio::io_service& serv)
24+
terminal::terminal(boost::asio::io_context& serv)
2525
: win_{[] {
2626
std::locale::global(std::locale(""));
2727
::setlocale(LC_ALL, "");

example/counter/ncurses/terminal.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#pragma once
1414

15-
#include <boost/asio/io_service.hpp>
15+
#include <boost/asio/io_context.hpp>
1616
#include <boost/asio/posix/stream_descriptor.hpp>
1717
#include <boost/asio/signal_set.hpp>
1818

@@ -59,7 +59,7 @@ struct terminal
5959
{
6060
using event_handler = std::function<void(event)>;
6161

62-
terminal(boost::asio::io_service& serv);
62+
terminal(boost::asio::io_context& serv);
6363

6464
coord size();
6565

0 commit comments

Comments
 (0)