Skip to content

Commit eb7e424

Browse files
authored
Merge pull request #750 from jrl-umi3218/flake
nix: init flake + CI
2 parents 0d98603 + f6354d3 commit eb7e424

File tree

6 files changed

+160
-3
lines changed

6 files changed

+160
-3
lines changed

.github/workflows/cmake.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ on: [push,pull_request]
55
jobs:
66
build-ubuntu:
77

8-
runs-on: [ubuntu-22.04]
8+
runs-on: ubuntu-24.04
99

1010
steps:
11-
- uses: actions/checkout@v3
11+
- uses: actions/checkout@v4
1212

1313
- name: Run project tests
1414
run: |
@@ -24,7 +24,6 @@ jobs:
2424
set -e
2525
set -x
2626
cd _unittests
27-
ln -s .. cmake
2827
CMAKE_BIN="cmake"
2928
$CMAKE_BIN --version
3029
$CMAKE_BIN -P test_pkg-config.cmake

.github/workflows/nix.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: "CI - Nix"
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
tests:
13+
name: "Nix build on ${{ matrix.os }}"
14+
runs-on: "${{ matrix.os }}-latest"
15+
strategy:
16+
matrix:
17+
os: [ubuntu, macos]
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: cachix/install-nix-action@v27
21+
- uses: cachix/cachix-action@v15
22+
with:
23+
name: gepetto
24+
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
25+
- run: nix build -L
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: update-flake-lock
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 19 3 * *'
7+
8+
jobs:
9+
lockfile:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
- name: Install Nix
15+
uses: DeterminateSystems/nix-installer-action@main
16+
- name: Update flake.lock
17+
uses: DeterminateSystems/update-flake-lock@main
18+
with:
19+
token: ${{ secrets.GH_TOKEN_FOR_UPDATES }}

_unittests/cmake

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
..

flake.lock

+58
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
description = "CMake utility toolbox";
3+
4+
inputs = {
5+
flake-parts.url = "github:hercules-ci/flake-parts";
6+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
7+
};
8+
9+
outputs =
10+
inputs:
11+
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
12+
systems = inputs.nixpkgs.lib.systems.flakeExposed;
13+
perSystem =
14+
{ pkgs, self', ... }:
15+
{
16+
packages = {
17+
default = self'.packages.jrl-cmakemodules;
18+
jrl-cmakemodules = pkgs.jrl-cmakemodules.overrideAttrs (super: {
19+
src = pkgs.lib.fileset.toSource {
20+
root = ./.;
21+
fileset = pkgs.lib.fileset.gitTracked ./.;
22+
};
23+
24+
# TODO: remove all this once it is in nixpkgs
25+
postPatch = ''
26+
patchShebangs _unittests/run_unit_tests.sh
27+
'';
28+
29+
outputs = [ "out" "doc" ];
30+
nativeBuildInputs = super.nativeBuildInputs ++ [
31+
pkgs.sphinxHook
32+
];
33+
sphinxRoot = "../.docs";
34+
35+
doCheck = true;
36+
checkInputs = [
37+
pkgs.python3
38+
];
39+
checkPhase = ''
40+
runHook preCheck
41+
42+
pushd ../_unittests
43+
./run_unit_tests.sh
44+
cmake -P test_pkg-config.cmake
45+
46+
rm -rf build install
47+
popd
48+
49+
runHook postCheck
50+
'';
51+
});
52+
};
53+
};
54+
};
55+
}

0 commit comments

Comments
 (0)