Skip to content

Commit 8f4b137

Browse files
committed
ci: build docker container and do caching
1 parent f34dc1e commit 8f4b137

File tree

6 files changed

+71
-2
lines changed

6 files changed

+71
-2
lines changed

.github/workflows/nix.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: "nix builder"
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: cachix/install-nix-action@v25
12+
with:
13+
nix_path: nixpkgs=channel:nixos-unstable
14+
- uses: cachix/cachix-action@v14
15+
with:
16+
name: trickypr
17+
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
18+
- run: nix build
19+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/target
22
.direnv/
3+
result

flake.lock

Lines changed: 16 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: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
url = "github:oxalica/rust-overlay";
99
inputs.nixpkgs.follows = "nixpkgs";
1010
};
11+
crane = {
12+
url = "github:ipetkov/crane";
13+
};
1114
};
1215

1316
outputs =
@@ -16,24 +19,39 @@
1619
nixpkgs,
1720
rust-overlay,
1821
flake-utils,
22+
crane,
1923
...
2024
}:
2125
flake-utils.lib.eachDefaultSystem (
2226
system:
2327
let
2428
overlays = [ (import rust-overlay) ];
29+
package = import ./nix/package.nix;
30+
docker-image = import ./nix/docker-image.nix;
2531
pkgs = import nixpkgs {
2632
inherit system overlays;
2733
};
34+
craneLib = crane.mkLib pkgs;
2835
in
2936
{
37+
packages = rec {
38+
bin = package {
39+
inherit pkgs;
40+
craneLib = craneLib;
41+
};
42+
docker = docker-image {
43+
inherit pkgs;
44+
bin = bin;
45+
};
46+
default = docker;
47+
};
48+
3049
devShells.default =
3150
with pkgs;
3251
mkShell {
3352
buildInputs = [
34-
openssl
35-
pkg-config
3653
rust-bin.stable.latest.default
54+
dive
3755
];
3856

3957
shellHook = '''';

nix/docker-image.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{ pkgs, bin, ... }:
2+
pkgs.dockerTools.buildImage {
3+
name = "ghcr.io/anucssa/rubric-merge";
4+
tag = "latest";
5+
copyToRoot = [ bin ];
6+
config = {
7+
Cmd = [ "${bin}/bin/rubric-merge" ];
8+
};
9+
}

nix/package.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{ craneLib, ... }:
2+
craneLib.buildPackage rec {
3+
pname = "rubric-merge";
4+
name = pname;
5+
src = craneLib.cleanCargoSource ../.;
6+
}

0 commit comments

Comments
 (0)