Skip to content

Commit 4551a6d

Browse files
committed
Try to support Nix flakes from HEAD
1 parent ad8796b commit 4551a6d

3 files changed

Lines changed: 71 additions & 0 deletions

File tree

.github/workflows/test_prebuilt_binaries.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,20 @@ jobs:
254254

255255
- name: Build Flake and show celq version
256256
run: nix run github:IvanIsCoding/celq -- --version
257+
258+
test-nix-flake-latest:
259+
name: Test Nix flake (latest) validity and run
260+
runs-on: ubuntu-24.04
261+
steps:
262+
- name: Install Nix
263+
uses: cachix/install-nix-action@v26
264+
with:
265+
nix_path: nixpkgs=channel:nixos-unstable
266+
extra_nix_config: |
267+
experimental-features = nix-command flakes
268+
269+
- name: Build Flake with latest version and show celq version
270+
run: nix run github:IvanIsCoding/celq#latest -- --version
257271

258272
test-freebsd-install:
259273
name: Test FreeBSD 14.3 (x86_64)

flake.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
{
2323
# Compiles from source with Cargo and installs celq. That part I understood!
2424
default = pkgs.callPackage ./nix/celq.nix { };
25+
# Latest version from HEAD
26+
latest = pkgs.callPackage ./nix/celq_latest.nix { };
2527
});
2628
};
2729
}

nix/celq_latest.nix

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
lib,
3+
rustPlatform,
4+
fetchCrate,
5+
versionCheckHook,
6+
runCommand,
7+
}:
8+
9+
let
10+
cargoToml = builtins.fromTOML (builtins.readFile ../Cargo.toml);
11+
in
12+
13+
rustPlatform.buildRustPackage (finalAttrs: {
14+
pname = "celq";
15+
version = cargoToml.package.version;
16+
17+
# Fetch from HEAD
18+
src = lib.cleanSource ../.;
19+
20+
cargoLock = {
21+
lockFile = ../Cargo.lock;
22+
allowBuiltinFetchGit = true;
23+
};
24+
25+
nativeInstallCheckInputs = [
26+
versionCheckHook
27+
];
28+
29+
passthru = {
30+
tests.simple =
31+
runCommand "celq-test"
32+
{
33+
nativeBuildInputs = [ finalAttrs.finalPackage ];
34+
}
35+
''
36+
set -o pipefail
37+
38+
# Test the command `celq -n "1 > 0"`, which should return exit code 0
39+
if ! celq -n "1 > 0"; then
40+
echo "Test failed: celq can't execute simple expression"
41+
exit 1
42+
else
43+
echo "Test passed: celq executed simple expression successfully"
44+
fi
45+
'';
46+
};
47+
48+
meta = {
49+
description = "celq - A Common Expression Language (CEL) CLI Tool";
50+
homepage = "https://github.com/IvanIsCoding/celq";
51+
license = lib.licenses.mit;
52+
mainProgram = "celq";
53+
platforms = lib.platforms.unix;
54+
};
55+
})

0 commit comments

Comments
 (0)