mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
Get the Nix build working. (#335)
V3_GIT_ORIGIN_REV_ID: e70e2a42b2445b4bcf4e9ee7db771b475c32d2f9
This commit is contained in:
parent
dea588255b
commit
078b0d3487
@ -1,3 +1,7 @@
|
||||
use std::fmt::Display;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use axum::{
|
||||
body::HttpBody,
|
||||
extract::State,
|
||||
@ -8,23 +12,22 @@ use axum::{
|
||||
Extension, Json, Router,
|
||||
};
|
||||
use clap::Parser;
|
||||
|
||||
use ::engine::authentication::{AuthConfig, AuthConfig::V1 as V1AuthConfig, AuthModeConfig};
|
||||
use engine::{schema::GDS, VERSION};
|
||||
use hasura_authn_core::Session;
|
||||
use hasura_authn_jwt::auth as jwt_auth;
|
||||
use hasura_authn_jwt::jwt;
|
||||
use hasura_authn_webhook::webhook;
|
||||
use lang_graphql as gql;
|
||||
use std::path::PathBuf;
|
||||
use std::{fmt::Display, sync::Arc};
|
||||
use tower_http::trace::TraceLayer;
|
||||
use tracing_util::{
|
||||
add_event_on_active_span, set_status_on_current_span, AttributeVisibility, ErrorVisibility,
|
||||
SpanVisibility, TraceableError, TraceableHttpResponse,
|
||||
};
|
||||
|
||||
use engine::authentication::{AuthConfig, AuthConfig::V1 as V1AuthConfig, AuthModeConfig};
|
||||
use engine::{schema::GDS, VERSION};
|
||||
use hasura_authn_core::Session;
|
||||
use hasura_authn_jwt::auth as jwt_auth;
|
||||
use hasura_authn_jwt::jwt;
|
||||
use hasura_authn_webhook::webhook;
|
||||
use lang_graphql as gql;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(version = VERSION)]
|
||||
struct ServerOptions {
|
||||
#[arg(long, value_name = "METADATA_FILE", env = "METADATA_PATH")]
|
||||
metadata_path: PathBuf,
|
||||
|
@ -1,12 +1,27 @@
|
||||
fn main() {
|
||||
// Cargo sets the PROFILE environment variable
|
||||
let profile = std::env::var("PROFILE").unwrap();
|
||||
if profile == "release" {
|
||||
// For release builds (cargo build --release ...), set the version to the git commit short
|
||||
let commit_short = build_data::get_git_commit_short().unwrap();
|
||||
println!("cargo:rustc-env=CARGO_V3_ENGINE_VERSION={}", commit_short);
|
||||
fn main() -> Result<(), String> {
|
||||
// Ensure that we rebuild if the version is specified.
|
||||
println!("cargo:rerun-if-env-changed=RELEASE_VERSION");
|
||||
|
||||
// On release builds, use the Git commit as a backup if the version is not set.
|
||||
// On debug builds, use "dev".
|
||||
// If we fail to get the Git information, fail.
|
||||
let build_profile = std::env::var("PROFILE").map_err(|err| err.to_string())?;
|
||||
let release_version = if build_profile == "release" {
|
||||
match option_env!("RELEASE_VERSION") {
|
||||
Some(version) => version.to_string(),
|
||||
None => {
|
||||
let git_commit_ref = build_data::get_git_commit_short()?;
|
||||
let git_dirty = build_data::get_git_dirty().unwrap_or(false);
|
||||
if git_dirty {
|
||||
format!("{git_commit_ref}-dirty")
|
||||
} else {
|
||||
git_commit_ref
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// For non-release builds, set the version to 'dev'
|
||||
println!("cargo:rustc-env=CARGO_V3_ENGINE_VERSION=dev");
|
||||
}
|
||||
"dev".to_string()
|
||||
};
|
||||
println!("cargo:rustc-env=CARGO_V3_ENGINE_VERSION={release_version}");
|
||||
Ok(())
|
||||
}
|
||||
|
17
v3/flake.nix
17
v3/flake.nix
@ -33,9 +33,24 @@
|
||||
in
|
||||
{
|
||||
formatter = pkgs.nixpkgs-fmt;
|
||||
|
||||
packages = {
|
||||
# a binary for whichever is the local computer
|
||||
default = rust.callPackage ./nix/app.nix { };
|
||||
default = rust.callPackage ./nix/app.nix {
|
||||
version = if self ? "dirtyRev" then self.dirtyShortRev else self.shortRev;
|
||||
};
|
||||
};
|
||||
|
||||
apps = {
|
||||
default = self.apps.${localSystem}.engine;
|
||||
engine = flake-utils.lib.mkApp {
|
||||
drv = self.packages.${localSystem}.default;
|
||||
name = "engine";
|
||||
};
|
||||
agent = flake-utils.lib.mkApp {
|
||||
drv = self.packages.${localSystem}.default;
|
||||
name = "engine";
|
||||
};
|
||||
};
|
||||
|
||||
devShells = {
|
||||
|
@ -1,6 +1,7 @@
|
||||
# This is a function that returns a derivation for the compiled Rust project.
|
||||
{ craneLib
|
||||
, lib
|
||||
, version
|
||||
, stdenv
|
||||
, openssl
|
||||
, libiconv
|
||||
@ -14,11 +15,13 @@ let
|
||||
|
||||
src =
|
||||
let
|
||||
isJsonFile = path: _type: builtins.match ".*json" path != null;
|
||||
isGraphqlFile = path: _type: builtins.match ".*graphql" path != null;
|
||||
isHtmlFile = path: _type: builtins.match ".*html" path != null;
|
||||
isJsonFile = path: _type: builtins.match ".*json" path != null;
|
||||
isSourceFile = path: type:
|
||||
isJsonFile path type
|
||||
|| isGraphqlFile path type
|
||||
isGraphqlFile path type
|
||||
|| isHtmlFile path type
|
||||
|| isJsonFile path type
|
||||
|| craneLib.filterCargoSources path type;
|
||||
in
|
||||
lib.cleanSourceWith { src = craneLib.path ./..; filter = isSourceFile; };
|
||||
@ -45,4 +48,5 @@ craneLib.buildPackage
|
||||
(buildArgs // {
|
||||
inherit cargoArtifacts;
|
||||
doCheck = false;
|
||||
RELEASE_VERSION = version;
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user