Skip to content

Commit 900388b

Browse files
committed
Add Nix flake
Using it for CI is much more elegant than the current Ubuntu PPA dumpster fire plus we can easily run it locally.
1 parent 5f835e0 commit 900388b

File tree

4 files changed

+83
-15
lines changed

4 files changed

+83
-15
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,10 @@ name: Continuous Integration
22
on: [push, pull_request]
33
jobs:
44
build:
5-
strategy:
6-
matrix:
7-
cxx: [g++, clang++]
85
runs-on: ubuntu-latest
9-
env:
10-
CXX: ${{ matrix.cxx }}
116
steps:
12-
- uses: actions/checkout@v3
13-
- name: Install dependencies
14-
run: sudo apt install -y libseccomp-dev && sudo add-apt-repository ppa:ubuntu-toolchain-r/test && sudo apt-get update && sudo apt-get -y install gcc-14 && sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 30
15-
- name: Configure the project
16-
run: cmake -B build -DCMAKE_BUILD_TYPE=Debug
17-
- name: Build the project
18-
run: cmake --build build
19-
- name: Run tests
20-
run: tests/run-tests.sh
7+
- uses: actions/checkout@v4
8+
- uses: cachix/install-nix-action@v27
9+
with:
10+
nix_path: nixpkgs=channel:nixos-unstable
11+
- run: nix flake check --print-build-logs

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.21)
2-
project(copycat)
2+
project(copycat VERSION 0.1)
33

44
set(LIB_TARGET "${PROJECT_NAME}")
55
set(BIN_TARGET "${PROJECT_NAME}-bin")

flake.lock

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
description = "A library for intercepting system calls";
3+
inputs = {
4+
quartz.url = "github:vimpostor/quartz";
5+
};
6+
7+
outputs = { self, quartz }: quartz.lib.eachSystem (system:
8+
let
9+
pkgs = quartz.inputs.nixpkgs.legacyPackages.${system};
10+
stdenvs = [ { name = "gcc"; pkg = pkgs.gcc14Stdenv; } { name = "clang"; pkg = pkgs.llvmPackages_18.stdenv; } ];
11+
defaultStdenv = (builtins.head stdenvs).name;
12+
makeStdenvPkg = env: env.mkDerivation {
13+
pname = "copycat";
14+
version = quartz.lib.cmakeProjectVersion ./CMakeLists.txt;
15+
16+
src = ./.;
17+
18+
nativeBuildInputs = with pkgs; [
19+
cmake
20+
libseccomp
21+
];
22+
};
23+
in {
24+
packages = {
25+
default = self.outputs.packages.${system}.${defaultStdenv};
26+
} // builtins.listToAttrs (map (x: { name = x.name; value = makeStdenvPkg x.pkg; }) stdenvs);
27+
checks = {
28+
format = pkgs.runCommand "format" { src = ./.; nativeBuildInputs = [ pkgs.clang-tools pkgs.git ]; } "mkdir $out && cd $src && find . -type f -path './*\\.[hc]pp' -exec clang-format -style=file --dry-run --Werror {} \\;";
29+
} // builtins.listToAttrs (map (x: { name = "tests-" + x.name; value = (makeStdenvPkg x.pkg); }) stdenvs);
30+
}
31+
);
32+
}

0 commit comments

Comments
 (0)