nix: Add the commit to the version #25
No files matched your search
@@ -10,6 +10,9 @@
|
||||
systems = [ "x86_64-linux" "aarch64-linux" ];
|
||||
forSystems = f: lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
|
||||
|
||||
# The commit the package's version shows, if the flake is from Git
|
||||
rev = self.shortRev or self.dirtyShortRev or null;
|
||||
|
||||
# Each module defaults its `package` to this flake's build for the system it's used on
|
||||
withPackage = path: option: { lib, pkgs, ... }: {
|
||||
imports = [ path ];
|
||||
@@ -19,7 +22,7 @@
|
||||
in
|
||||
{
|
||||
packages = forSystems (pkgs: rec {
|
||||
slop-broker = pkgs.callPackage ./nix/package.nix { };
|
||||
slop-broker = pkgs.callPackage ./nix/package.nix { inherit rev; };
|
||||
default = slop-broker;
|
||||
# The demo's VMs (see `docs/demo.md`)
|
||||
demo = import ./nix/demo/agent.nix { inherit pkgs slop-broker; };
|
||||
@@ -27,7 +30,7 @@
|
||||
});
|
||||
|
||||
overlays.default = final: _prev: {
|
||||
slop-broker = final.callPackage ./nix/package.nix { };
|
||||
slop-broker = final.callPackage ./nix/package.nix { inherit rev; };
|
||||
};
|
||||
|
||||
nixosModules = {
|
||||
|
||||
+9
-2
@@ -1,10 +1,13 @@
|
||||
{ lib, rustPlatform, pkg-config, openssl, sqlite }:
|
||||
# `rev` is the commit the build is from, like `2d59b59` or `2d59b59-dirty`, which the version
|
||||
# shows. It's part of the build, so every commit rebuilds the package.
|
||||
{ lib, rustPlatform, pkg-config, openssl, sqlite, rev ? null }:
|
||||
let
|
||||
inherit (lib.fileset) toSource unions;
|
||||
inherit ((builtins.fromTOML (builtins.readFile ../Cargo.toml)).package) version;
|
||||
in
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "slop-broker";
|
||||
inherit ((builtins.fromTOML (builtins.readFile ../Cargo.toml)).package) version;
|
||||
inherit version;
|
||||
|
||||
src = toSource {
|
||||
root = ../.;
|
||||
@@ -16,6 +19,10 @@ rustPlatform.buildRustPackage {
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [ openssl sqlite ];
|
||||
|
||||
env = lib.optionalAttrs (rev != null) {
|
||||
SLOP_BROKER_VERSION = "${version}+${rev}";
|
||||
};
|
||||
|
||||
postInstall = ''
|
||||
ln -s slop-broker $out/bin/slop-approve
|
||||
install -Dm644 slop-tools.md $out/share/slop-broker/slop-tools.md
|
||||
|
||||
@@ -12,7 +12,7 @@ use slop_broker::server::{self, Broker};
|
||||
use slop_broker::{approve, web};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(about = "Approval broker for coding agents")]
|
||||
#[command(version = slop_broker::VERSION, about = "Approval broker for coding agents")]
|
||||
enum Command {
|
||||
/// Run the broker.
|
||||
Serve {
|
||||
|
||||
@@ -27,6 +27,8 @@ const GUIDE: &str = include_str!("../../slop-tools.md");
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(
|
||||
name = "slop",
|
||||
version = slop_broker::VERSION,
|
||||
about = "Ask the slop broker to run privileged operations",
|
||||
after_help = "Requests wait for an approver for as long as the broker allows (it says how long);\n\
|
||||
don't retry them in a loop.\n\
|
||||
|
||||
@@ -15,3 +15,10 @@ pub mod server;
|
||||
pub mod targets;
|
||||
pub mod types;
|
||||
pub mod web;
|
||||
|
||||
/// The version, like `0.3.0+2d59b59`: Nix builds add the commit they're built from (with `-dirty`
|
||||
/// for uncommitted changes) in `SLOP_BROKER_VERSION`.
|
||||
pub const VERSION: &str = match option_env!("SLOP_BROKER_VERSION") {
|
||||
Some(version) => version,
|
||||
None => env!("CARGO_PKG_VERSION"),
|
||||
};
|
||||
+3
-2
@@ -176,8 +176,9 @@ pub async fn handle<S: AsyncRead + AsyncWrite + Send + 'static>(broker: Arc<Brok
|
||||
async fn process(broker: &Broker, requester: &str, request: Request, io: &mut Io) -> Option<ServerMessage> {
|
||||
if request.version != PROTOCOL_VERSION {
|
||||
return Some(ServerMessage::Error(format!(
|
||||
"protocol version {} is not supported (the broker uses {PROTOCOL_VERSION}); update slop",
|
||||
request.version
|
||||
"protocol version {} is not supported (slop-broker {} uses {PROTOCOL_VERSION}); update slop",
|
||||
request.version,
|
||||
crate::VERSION
|
||||
)));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ use crate::ops::printable;
|
||||
use crate::queue::{Decision, PendingInfo};
|
||||
|
||||
/// The broker's version, which signed-in pages show.
|
||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
pub use crate::VERSION;
|
||||
|
||||
/// HTML escaping, after replacing what [`printable`] replaces.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
||||
Reference in new issue
Block a user