mirror of
https://gitlab.com/keys.openpgp.org/hagrid.git
synced 2025-10-06 00:23:08 +02:00
nix+web: pass in commit hash when building from flake
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{ lib, rustPlatform, sqlite, openssl, gettext, pkg-config }:
|
||||
{ lib, rustPlatform, sqlite, openssl, gettext, pkg-config, commitShaShort ? "" }:
|
||||
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "hagrid";
|
||||
@@ -26,6 +26,8 @@ rustPlatform.buildRustPackage rec {
|
||||
openssl
|
||||
];
|
||||
|
||||
COMMIT_SHA_SHORT = commitShaShort;
|
||||
|
||||
meta = with lib; {
|
||||
description = "A verifying keyserver";
|
||||
homepage = "https://gitlab.com/keys.openpgp.org/hagrid";
|
||||
|
@@ -6,8 +6,9 @@
|
||||
outputs = { self, nixpkgs, utils }:
|
||||
utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = nixpkgs.legacyPackages."${system}";
|
||||
commitShaShort = if self ? rev then (pkgs.lib.substring 0 10 self.rev) else self.dirtyShortRev;
|
||||
in rec {
|
||||
packages.hagrid = pkgs.callPackage ./. { };
|
||||
packages.hagrid = pkgs.callPackage ./. { inherit commitShaShort; };
|
||||
packages.wkdDomainChecker = pkgs.callPackage ./wkd-domain-checker/. { };
|
||||
|
||||
packages.default = packages.hagrid;
|
||||
|
@@ -10,6 +10,8 @@ use std::path::PathBuf;
|
||||
|
||||
use crate::web::MyResponse;
|
||||
|
||||
use super::util::get_commit_sha;
|
||||
|
||||
pub struct MaintenanceMode {
|
||||
maintenance_file: PathBuf,
|
||||
}
|
||||
@@ -98,7 +100,7 @@ pub fn maintenance_error_web(message: String, i18n: I18n) -> MyResponse {
|
||||
let ctx = templates::MaintenanceMode {
|
||||
message,
|
||||
version: env!("VERGEN_SEMVER").to_string(),
|
||||
commit: env!("VERGEN_SHA_SHORT").to_string(),
|
||||
commit: get_commit_sha(),
|
||||
lang: i18n.lang.to_owned(),
|
||||
};
|
||||
MyResponse::Maintenance(Template::render("maintenance", ctx))
|
||||
|
@@ -13,7 +13,9 @@ use rocket_prometheus::PrometheusMetrics;
|
||||
use gettext_macros::{compile_i18n, include_i18n};
|
||||
|
||||
use serde::Serialize;
|
||||
use util::get_commit_sha;
|
||||
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::counters;
|
||||
@@ -34,6 +36,7 @@ mod debug_web;
|
||||
mod hkp;
|
||||
mod maintenance;
|
||||
mod manage;
|
||||
mod util;
|
||||
mod vks;
|
||||
mod vks_api;
|
||||
mod vks_web;
|
||||
@@ -155,7 +158,7 @@ impl MyResponse {
|
||||
let ctx = templates::FiveHundred {
|
||||
internal_error: e.to_string(),
|
||||
version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
commit: env!("VERGEN_SHA_SHORT").to_string(),
|
||||
commit: get_commit_sha(),
|
||||
lang: "en".to_string(),
|
||||
};
|
||||
MyResponse::ServerError(Template::render("500", ctx))
|
||||
@@ -206,7 +209,7 @@ impl MyResponse {
|
||||
}
|
||||
|
||||
mod templates {
|
||||
use super::{I18n, RequestOrigin};
|
||||
use super::{util::get_commit_sha, I18n, RequestOrigin};
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct FiveHundred {
|
||||
@@ -245,7 +248,7 @@ mod templates {
|
||||
Self {
|
||||
error: None,
|
||||
version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
commit: env!("VERGEN_SHA_SHORT").to_string(),
|
||||
commit: get_commit_sha(),
|
||||
base_uri: origin.get_base_uri().to_string(),
|
||||
page,
|
||||
lang: i18n.lang.to_string(),
|
||||
|
7
src/web/util.rs
Normal file
7
src/web/util.rs
Normal file
@@ -0,0 +1,7 @@
|
||||
use std::{env, option_env};
|
||||
|
||||
pub fn get_commit_sha() -> String {
|
||||
option_env!("COMMIT_SHA_SHORT")
|
||||
.unwrap_or_else(|| env!("VERGEN_SHA_SHORT"))
|
||||
.to_string()
|
||||
}
|
Reference in New Issue
Block a user