From 9f66fe49207c983ee047bfe94bb803aa20d445b4 Mon Sep 17 00:00:00 2001 From: Sergey Bronnikov Date: Fri, 28 Aug 2026 18:38:15 +0300 Subject: [PATCH 1/2] Add Nix flake Add flake.nix that builds the elle-cli package and provides a dev shell (bash, clojure, leiningen) for `nix develop`. Usage: `nix build` / `nix run` / `nix develop`. --- flake.lock | 27 +++++++++++++ flake.nix | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c508296 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1787736819, + "narHash": "sha256-cV5xEJJK3BvhU8rEd4mC9UsmDi5qscv/kzGPhBRC5WA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9fbb54b33e91ee4ca368e35a78e0613c720600b3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..32079a6 --- /dev/null +++ b/flake.nix @@ -0,0 +1,116 @@ +{ + description = "Command-line frontend to transactional consistency checkers for black-box databases"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + outputs = { self, nixpkgs }: + let + systems = [ "x86_64-linux" "aarch64-linux" ]; + forAllSystems = nixpkgs.lib.genAttrs systems; + nixpkgsFor = system: import nixpkgs { inherit system; }; + + version = "0.1.11"; + + source = pkgs: pkgs.fetchFromGitHub { + owner = "ligurio"; + repo = "elle-cli"; + rev = version; + sha256 = "sha256-YqBk1ELWzkVckV97GNnuYMalfKLL0FhGOLQ/+ujPNs8="; + }; + + # Fetch all Maven/Clojars dependencies once. This is a fixed-output + # derivation, so the sandbox allows `lein deps` to reach the network. + mavenRepo = pkgs: pkgs.stdenv.mkDerivation { + pname = "elle-cli-maven-repo"; + inherit version; + src = source pkgs; + + nativeBuildInputs = with pkgs; [ leiningen jdk21 ]; + + outputHashMode = "recursive"; + outputHashAlgo = "sha256"; + outputHash = "sha256-CalXuQ1AcVJiMk6O2LxPjlxsAnk8fut9P8FkLZ30dXs="; + + dontConfigure = true; + dontFixup = true; + + buildPhase = '' + runHook preBuild + export HOME="$NIX_BUILD_TOP" + export LEIN_JVM_OPTS="-Duser.home=$NIX_BUILD_TOP/m2home" + make deps + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + mkdir -p "$out/repository" + cp -r "$NIX_BUILD_TOP/m2home/.m2/repository"/. "$out/repository/" + # Drop resolution metadata to keep the output deterministic. + find "$out" -name '*.lastUpdated' -delete + find "$out" -name '_remote.repositories' -delete + runHook postInstall + ''; + }; + + elle-cli = pkgs: pkgs.stdenv.mkDerivation rec { + pname = "elle-cli"; + inherit version; + src = source pkgs; + + nativeBuildInputs = with pkgs; [ + leiningen + jdk21 + makeWrapper + ]; + + buildPhase = '' + runHook preBuild + export HOME="$TMPDIR" + export LEIN_JVM_OPTS="-Duser.home=$TMPDIR/m2home" + mkdir -p "$TMPDIR/m2home/.m2" + cp -r "${mavenRepo pkgs}/repository" "$TMPDIR/m2home/.m2/repository" + make build LEIN="lein -o" + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + install -Dm644 target/${pname}-${version}-standalone.jar $out/share/java/${pname}-${version}-standalone.jar + + makeWrapper ${pkgs.jdk21}/bin/java $out/bin/${pname} \ + --add-flags "-Xmx32g -Djava.awt.headless=true" \ + --add-flags "-jar $out/share/java/${pname}-${version}-standalone.jar" \ + --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.graphviz ]} + + runHook postInstall + ''; + + meta = with pkgs.lib; { + description = "Command-line frontend to transactional consistency checkers for black-box databases"; + homepage = "https://github.com/ligurio/elle-cli"; + license = licenses.epl20; + mainProgram = "elle-cli"; + platforms = platforms.unix; + }; + }; + in { + packages = forAllSystems (system: { + elle-cli = elle-cli (nixpkgsFor system); + default = self.packages.${system}.elle-cli; + }); + + devShells = forAllSystems (system: + let pkgs = nixpkgsFor system; in { + default = pkgs.mkShell { + name = "elle-cli-dev"; + buildInputs = with pkgs; [ + bash + clojure + leiningen + ]; + }; + }); + }; +} From 55bd21961369dc59832568b936872fa02498a1a4 Mon Sep 17 00:00:00 2001 From: Sergey Bronnikov Date: Tue, 1 Sep 2026 15:42:33 +0300 Subject: [PATCH 2/2] Add check for flake.nix to GitHub Actions The patch introduce a job that validates flake.nix and verifies the package build: - Install Nix via DeterminateSystems/nix-installer-action. - Enable caching with magic-nix-cache-action. - Run `nix flake check` to validate flake evaluation. --- .github/workflows/publish.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9812a01..4fab824 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -45,3 +45,21 @@ jobs: tag: ${{ github.ref }} overwrite: true prerelease: true + + nix-flake: + runs-on: ubuntu-24.04 + + steps: + - uses: actions/checkout@v7.0.1 + + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@v4 + + - name: Setup magic Nix cache + uses: DeterminateSystems/magic-nix-cache-action@v2 + + - name: Check flake + run: nix flake check + + - name: Build default package + run: nix build .#default