mirror of
https://github.com/tweag/nickel.git
synced 2024-09-11 11:47:03 +03:00
add %eval_nix% primop (#1465)
* add importing nix files behind a nix-experimental feature flag * add %eval_nix% builtin to evaluate a nix string * basic error reporting from nix * error messages * use pkg-config to find nix dependency * nice error message when feature disabled * better errors * resolve XXX * put appropriate dependencies in nativeBuildInputs * explain -sys crate option * no %% around builtins in error messages * clippy needs nativeBuildInputs * clippy * fix cargo doc * use nix master * c++17 -> c++20 * cargo fmt * review comments * fixup after merge * fix after rebase * revert to (hopefully) known good nix commit * try using nix's own nixpkgs * this worked on build02 * debug for mac CI * debug doesn't work * cargo fmt * debug * don't fail everything if we can't debug * debug take N * nix-version * remove debug * disable checks for nix on x86_64-darwin
This commit is contained in:
parent
8eae2c70fd
commit
91d63ed611
62
Cargo.lock
generated
62
Cargo.lock
generated
@ -687,6 +687,50 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cxx"
|
||||
version = "1.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbe98ba1789d56fb3db3bee5e032774d4f421b685de7ba703643584ba24effbe"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"cxxbridge-flags",
|
||||
"cxxbridge-macro",
|
||||
"link-cplusplus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cxx-build"
|
||||
version = "1.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4ce20f6b8433da4841b1dadfb9468709868022d829d5ca1f2ffbda928455ea3"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"codespan-reporting",
|
||||
"once_cell",
|
||||
"proc-macro2 1.0.67",
|
||||
"quote 1.0.33",
|
||||
"scratch",
|
||||
"syn 2.0.33",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cxxbridge-flags"
|
||||
version = "1.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20888d9e1d2298e2ff473cee30efe7d5036e437857ab68bbfea84c74dba91da2"
|
||||
|
||||
[[package]]
|
||||
name = "cxxbridge-macro"
|
||||
version = "1.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2fa16a70dd58129e4dfffdff535fb1bce66673f7bbeec4a5a1765a504e1ccd84"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.67",
|
||||
"quote 1.0.33",
|
||||
"syn 2.0.33",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "debugid"
|
||||
version = "0.8.0"
|
||||
@ -1373,6 +1417,15 @@ dependencies = [
|
||||
"safemem",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "link-cplusplus"
|
||||
version = "1.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d240c6f7e1ba3a28b0249f774e6a9dd0175054b52dfbb61b16eb8505c3785c9"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linked-hash-map"
|
||||
version = "0.5.6"
|
||||
@ -1687,6 +1740,8 @@ dependencies = [
|
||||
"codespan-reporting",
|
||||
"comrak",
|
||||
"criterion",
|
||||
"cxx",
|
||||
"cxx-build",
|
||||
"indexmap 1.9.3",
|
||||
"indoc 2.0.3",
|
||||
"js-sys",
|
||||
@ -1699,6 +1754,7 @@ dependencies = [
|
||||
"metrics",
|
||||
"nickel-lang-utils",
|
||||
"once_cell",
|
||||
"pkg-config",
|
||||
"pprof",
|
||||
"pretty",
|
||||
"pretty_assertions",
|
||||
@ -2510,6 +2566,12 @@ version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "scratch"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152"
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.18"
|
||||
|
@ -45,6 +45,8 @@ codespan-reporting = "0.11"
|
||||
comrak = "0.17.0"
|
||||
criterion = "0.4"
|
||||
csv = "1"
|
||||
cxx = "1.0"
|
||||
cxx-build = "1.0"
|
||||
derive_more = "0.99"
|
||||
directories = "4.0.1"
|
||||
env_logger = "0.10"
|
||||
@ -65,6 +67,7 @@ malachite-q = "0.3.2"
|
||||
md-5 = "0.10.5"
|
||||
once_cell = "1.17.1"
|
||||
pprof = "0.11.1"
|
||||
pkg-config = "0.3.27"
|
||||
pretty = "0.11.3"
|
||||
pretty_assertions = "1.3.0"
|
||||
pyo3 = "0.17.3"
|
||||
|
@ -9,6 +9,11 @@ keywords.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
readme.workspace = true
|
||||
# Maybe we should have the nix bindings in a separate -sys crate. maybe we
|
||||
# should even have separate crates for "nix-store", "nix-cmd", "nix-expr", "nix-
|
||||
# main", since they're separate libraries, but that seems a bit over the top.
|
||||
# SEE: https://kornel.ski/rust-sys-crate
|
||||
links = "nix"
|
||||
|
||||
[lib]
|
||||
bench = false
|
||||
@ -21,9 +26,12 @@ repl-wasm = ["dep:wasm-bindgen", "dep:js-sys", "dep:serde_repr"]
|
||||
doc = ["dep:comrak"]
|
||||
format = ["dep:topiary", "dep:topiary-queries", "dep:tree-sitter-nickel"]
|
||||
metrics = ["dep:metrics"]
|
||||
nix-experimental = [ "dep:cxx", "dep:cxx-build", "dep:pkg-config" ]
|
||||
|
||||
[build-dependencies]
|
||||
lalrpop.workspace = true
|
||||
cxx-build = { workspace = true, optional = true }
|
||||
pkg-config = { workspace = true, optional = true }
|
||||
|
||||
[dependencies]
|
||||
lalrpop-util.workspace = true
|
||||
@ -32,6 +40,7 @@ simple-counter.workspace = true
|
||||
clap = { workspace = true, features = ["derive"] }
|
||||
codespan.workspace = true
|
||||
codespan-reporting.workspace = true
|
||||
cxx = { workspace = true, optional = true }
|
||||
logos.workspace = true
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
serde_json.workspace = true
|
||||
|
@ -3,4 +3,29 @@ fn main() {
|
||||
.use_cargo_dir_conventions()
|
||||
.process_file("src/parser/grammar.lalrpop")
|
||||
.unwrap();
|
||||
|
||||
#[cfg(feature = "nix-experimental")]
|
||||
{
|
||||
use cxx_build::CFG;
|
||||
use std::path::PathBuf;
|
||||
|
||||
for lib in &["nix-store", "nix-cmd", "nix-expr", "nix-main"] {
|
||||
let lib = pkg_config::Config::new()
|
||||
.atleast_version("2.16.0")
|
||||
.probe(lib)
|
||||
.unwrap();
|
||||
let lib_include_paths = lib.include_paths.iter().map(PathBuf::as_path);
|
||||
CFG.exported_header_dirs.extend(lib_include_paths);
|
||||
}
|
||||
|
||||
cxx_build::bridge("src/nix_ffi/mod.rs")
|
||||
.file("src/nix_ffi/cpp/nix.cc")
|
||||
.flag_if_supported("-std=c++20")
|
||||
.flag_if_supported("-U_FORTIFY_SOURCE") // Otherwise builds with `-O0` raise a lot of warnings
|
||||
.compile("nickel-lang");
|
||||
|
||||
println!("cargo:rerun-if-changed=src/nix_ffi/mod.rs");
|
||||
println!("cargo:rerun-if-changed=src/nix_ffi/cpp/nix.cc");
|
||||
println!("cargo:rerun-if-changed=src/nix_ffi/cpp/nix.hh");
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
use crate::error::{Error, ImportError, ParseError, ParseErrors, TypecheckError};
|
||||
use crate::eval::cache::Cache as EvalCache;
|
||||
use crate::eval::Closure;
|
||||
#[cfg(feature = "nix-experimental")]
|
||||
use crate::nix_ffi;
|
||||
use crate::parser::{lexer::Lexer, ErrorTolerantParser};
|
||||
use crate::position::TermPos;
|
||||
use crate::stdlib::{self as nickel_stdlib, StdlibModule};
|
||||
@ -28,12 +30,15 @@ use std::time::SystemTime;
|
||||
use void::Void;
|
||||
|
||||
/// Supported input formats.
|
||||
#[derive(Clone, Copy, Eq, Debug, PartialEq)]
|
||||
#[derive(Default, Clone, Copy, Eq, Debug, PartialEq)]
|
||||
pub enum InputFormat {
|
||||
#[default]
|
||||
Nickel,
|
||||
Json,
|
||||
Yaml,
|
||||
Toml,
|
||||
#[cfg(feature = "nix-experimental")]
|
||||
Nix,
|
||||
}
|
||||
|
||||
impl InputFormat {
|
||||
@ -44,6 +49,8 @@ impl InputFormat {
|
||||
Some("json") => Some(InputFormat::Json),
|
||||
Some("yaml") | Some("yml") => Some(InputFormat::Yaml),
|
||||
Some("toml") => Some(InputFormat::Toml),
|
||||
#[cfg(feature = "nix-experimental")]
|
||||
Some("nix") => Some(InputFormat::Nix),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@ -520,7 +527,7 @@ impl Cache {
|
||||
|
||||
/// Parse a source without querying nor populating the cache.
|
||||
pub fn parse_nocache(&self, file_id: FileId) -> Result<(RichTerm, ParseErrors), ParseError> {
|
||||
self.parse_nocache_multi(file_id, InputFormat::Nickel)
|
||||
self.parse_nocache_multi(file_id, InputFormat::default())
|
||||
}
|
||||
|
||||
/// Parse a source without querying nor populating the cache. Support multiple formats.
|
||||
@ -588,6 +595,14 @@ impl Cache {
|
||||
InputFormat::Toml => toml::from_str(self.files.source(file_id))
|
||||
.map(|t| (attach_pos(t), ParseErrors::default()))
|
||||
.map_err(|err| (ParseError::from_toml(err, file_id))),
|
||||
#[cfg(feature = "nix-experimental")]
|
||||
InputFormat::Nix => {
|
||||
let json = nix_ffi::eval_to_json(self.files.source(file_id))
|
||||
.map_err(|e| ParseError::from_nix(e.what(), file_id))?;
|
||||
serde_json::from_str(&json)
|
||||
.map(|t| (attach_pos(t), ParseErrors::default()))
|
||||
.map_err(|err| ParseError::from_serde_json(err, file_id, &self.files))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1297,7 +1312,7 @@ impl ImportResolver for Cache {
|
||||
) -> Result<(ResolvedTerm, FileId), ImportError> {
|
||||
let parent_path = parent.and_then(|p| self.get_path(p)).map(PathBuf::from);
|
||||
let path_buf = with_parent(path, parent_path);
|
||||
let format = InputFormat::from_path(&path_buf).unwrap_or(InputFormat::Nickel);
|
||||
let format = InputFormat::from_path(&path_buf).unwrap_or_default();
|
||||
let id_op = self.get_or_add_file(&path_buf).map_err(|err| {
|
||||
ImportError::IOError(
|
||||
path_buf.to_string_lossy().into_owned(),
|
||||
|
@ -499,6 +499,8 @@ pub enum ParseError {
|
||||
/// The previous instance of the duplicated identifier.
|
||||
prev_ident: LocIdent,
|
||||
},
|
||||
/// There was an attempt to use a feature that hasn't been enabled
|
||||
DisabledFeature { feature: String, span: RawSpan },
|
||||
}
|
||||
|
||||
/// An error occurring during the resolution of an import.
|
||||
@ -699,6 +701,9 @@ impl ParseError {
|
||||
InternalParseError::DuplicateIdentInRecordPattern { ident, prev_ident } => {
|
||||
ParseError::DuplicateIdentInRecordPattern { ident, prev_ident }
|
||||
}
|
||||
InternalParseError::DisabledFeature { feature, span } => {
|
||||
ParseError::DisabledFeature { feature, span }
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -764,6 +769,12 @@ impl ParseError {
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(feature = "nix-experimental")]
|
||||
pub fn from_nix(error: &str, _file_id: FileId) -> Self {
|
||||
// Span is shown in the nix error message
|
||||
ParseError::ExternalFormatError(String::from("nix"), error.to_string(), None)
|
||||
}
|
||||
}
|
||||
|
||||
pub const INTERNAL_ERROR_MSG: &str =
|
||||
@ -1785,6 +1796,16 @@ impl IntoDiagnostics<FileId> for ParseError {
|
||||
secondary(&prev_ident.pos.unwrap()).with_message("previous binding here"),
|
||||
primary(&ident.pos.unwrap()).with_message("duplicated binding here"),
|
||||
]),
|
||||
ParseError::DisabledFeature { feature, span } => Diagnostic::error()
|
||||
.with_message("interpreter compiled without required features")
|
||||
.with_labels(vec![primary(&span).with_message(format!(
|
||||
"this syntax is only supported with the `{}` feature enabled",
|
||||
feature
|
||||
))])
|
||||
.with_notes(vec![format!(
|
||||
"Recompile nickel with `--features {}`",
|
||||
feature
|
||||
)]),
|
||||
};
|
||||
|
||||
vec![diagnostic]
|
||||
|
@ -12,6 +12,9 @@ use super::{
|
||||
subst, Cache, Closure, Environment, ImportResolver, VirtualMachine,
|
||||
};
|
||||
|
||||
#[cfg(feature = "nix-experimental")]
|
||||
use crate::nix_ffi;
|
||||
|
||||
use crate::{
|
||||
error::{EvalError, IllegalPolymorphicTailAction},
|
||||
identifier::LocIdent,
|
||||
@ -1155,6 +1158,30 @@ impl<R: ImportResolver, C: Cache> VirtualMachine<R, C> {
|
||||
Err(mk_type_error!("label_push_diag", "Label"))
|
||||
}}
|
||||
}
|
||||
#[cfg(feature = "nix-experimental")]
|
||||
UnaryOp::EvalNix() => {
|
||||
if let Term::Str(s) = &*t {
|
||||
let json = nix_ffi::eval_to_json(&String::from(s)).map_err(|e| {
|
||||
EvalError::Other(
|
||||
format!("nix code failed to evaluate:\n {}", e.what()),
|
||||
pos,
|
||||
)
|
||||
})?;
|
||||
Ok(Closure::atomic_closure(
|
||||
serde_json::from_str(&json).map_err(|e| {
|
||||
EvalError::Other(format!("Nix produced invalid json: {}", e), pos)
|
||||
})?,
|
||||
))
|
||||
} else {
|
||||
// Not using mk_type_error! because of a non-uniform message
|
||||
Err(EvalError::TypeError(
|
||||
String::from("String"),
|
||||
String::from("eval_nix takes a string of nix code as an argument"),
|
||||
arg_pos,
|
||||
RichTerm { term: t, pos },
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,8 @@ pub mod error;
|
||||
pub mod eval;
|
||||
pub mod identifier;
|
||||
pub mod label;
|
||||
#[cfg(feature = "nix-experimental")]
|
||||
pub mod nix_ffi;
|
||||
pub mod parser;
|
||||
pub mod position;
|
||||
pub mod pretty;
|
||||
|
47
core/src/nix_ffi/cpp/nix.cc
Normal file
47
core/src/nix_ffi/cpp/nix.cc
Normal file
@ -0,0 +1,47 @@
|
||||
#include "nix.hh"
|
||||
|
||||
using namespace nix;
|
||||
|
||||
#include <nix/config.h>
|
||||
#include <nix/store-api.hh>
|
||||
#include <nix/eval.hh>
|
||||
#include <nix/shared.hh>
|
||||
#include <nix/canon-path.hh>
|
||||
#include <nix/nixexpr.hh>
|
||||
#include <nix/value-to-json.hh>
|
||||
#include <nix/command.hh>
|
||||
#include <nix/value.hh>
|
||||
|
||||
#include "nickel-lang-core/src/nix_ffi/mod.rs.h"
|
||||
|
||||
// nix is designed with command-line use in mind, and there's some setup stuff
|
||||
// that's tied to the EvalCommand class.
|
||||
struct DummyEvalCommand : virtual EvalCommand {
|
||||
|
||||
void run(ref<Store> store) override
|
||||
{
|
||||
// so it doesn't complain about unused variables
|
||||
(void)store;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// FIXME: error messages have an extra `error:` on them
|
||||
rust::String eval_to_json(rust::Str nixCode)
|
||||
{
|
||||
auto dummy = DummyEvalCommand({});
|
||||
initNix();
|
||||
initGC();
|
||||
auto & state = *dummy.getEvalState();
|
||||
|
||||
auto vRes = state.allocValue();
|
||||
state.eval(state.parseExprFromString(std::string(nixCode), state.rootPath(CanonPath::root)), *vRes);
|
||||
|
||||
std::stringstream out;
|
||||
NixStringContext context;
|
||||
// TODO: don't force the value. figure out a way to return thunks.
|
||||
// (second argument)
|
||||
printValueAsJSON(state, true, *vRes, noPos, out, context, false);
|
||||
|
||||
return out.str();
|
||||
}
|
10
core/src/nix_ffi/cpp/nix.hh
Normal file
10
core/src/nix_ffi/cpp/nix.hh
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <nix/primops.hh>
|
||||
#include "rust/cxx.h"
|
||||
|
||||
#include "nickel-lang-core/src/nix_ffi/mod.rs.h"
|
||||
|
||||
using namespace nix;
|
||||
|
||||
rust::String eval_to_json(const rust::Str nix_code);
|
10
core/src/nix_ffi/mod.rs
Normal file
10
core/src/nix_ffi/mod.rs
Normal file
@ -0,0 +1,10 @@
|
||||
#![cfg(feature = "nix-experimental")]
|
||||
#[cxx::bridge]
|
||||
mod internal {
|
||||
unsafe extern "C++" {
|
||||
include!("nickel-lang-core/src/nix_ffi/cpp/nix.hh");
|
||||
fn eval_to_json(nix_code: &str) -> Result<String>;
|
||||
}
|
||||
}
|
||||
|
||||
pub use internal::*;
|
@ -113,7 +113,10 @@ pub enum ParseError {
|
||||
/// e.g. in the signature `forall r. { ; r } -> r`,
|
||||
/// - a variable is used as both a record and enum row variable, e.g. in the
|
||||
/// signature `forall r. [| ; r |] -> { ; r }`.
|
||||
TypeVariableKindMismatch { ty_var: LocIdent, span: RawSpan },
|
||||
TypeVariableKindMismatch {
|
||||
ty_var: LocIdent,
|
||||
span: RawSpan,
|
||||
},
|
||||
/// A record literal, which isn't a record type, has a field with a type annotation but without
|
||||
/// a definition. While we could technically handle this situation, this is most probably an
|
||||
/// error from the user, because this type annotation is useless and, maybe non-intuitively,
|
||||
@ -134,4 +137,8 @@ pub enum ParseError {
|
||||
/// The position of the type annotation.
|
||||
annot_span: RawSpan,
|
||||
},
|
||||
DisabledFeature {
|
||||
feature: String,
|
||||
span: RawSpan,
|
||||
},
|
||||
}
|
||||
|
@ -667,7 +667,22 @@ UOp: UnaryOp = {
|
||||
"record_empty_with_tail" => UnaryOp::RecordEmptyWithTail(),
|
||||
"trace" => UnaryOp::Trace(),
|
||||
"label_push_diag" => UnaryOp::LabelPushDiag(),
|
||||
};
|
||||
<l: @L> "eval_nix" <r: @R> =>? {
|
||||
#[cfg(feature = "nix-experimental")]
|
||||
{
|
||||
Ok(UnaryOp::EvalNix())
|
||||
}
|
||||
#[cfg(not(feature = "nix-experimental"))]
|
||||
{
|
||||
Err(lalrpop_util::ParseError::User {
|
||||
error: ParseError::DisabledFeature {
|
||||
feature: String::from("nix-experimental"),
|
||||
span: mk_span(src_id, l, r),
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MatchCase: MatchCase = {
|
||||
<id: EnumTag> "=>" <t: Term> => MatchCase::Normal(id, t),
|
||||
@ -1087,6 +1102,7 @@ extern {
|
||||
"label_append_note" => Token::Normal(NormalToken::LabelAppendNote),
|
||||
"label_push_diag" => Token::Normal(NormalToken::LabelPushDiag),
|
||||
"array_slice" => Token::Normal(NormalToken::ArraySlice),
|
||||
"eval_nix" => Token::Normal(NormalToken::EvalNix),
|
||||
|
||||
"{" => Token::Normal(NormalToken::LBrace),
|
||||
"}" => Token::Normal(NormalToken::RBrace),
|
||||
|
@ -320,6 +320,8 @@ pub enum NormalToken<'input> {
|
||||
LabelPushDiag,
|
||||
#[token("%array_slice%")]
|
||||
ArraySlice,
|
||||
#[token("%eval_nix%")]
|
||||
EvalNix,
|
||||
|
||||
#[token("{")]
|
||||
LBrace,
|
||||
|
@ -1233,6 +1233,10 @@ pub enum UnaryOp {
|
||||
/// This primop shouldn't be used directly by user a priori, but is used internally during e.g.
|
||||
/// contract application.
|
||||
LabelPushDiag(),
|
||||
|
||||
/// Evaluate a string of nix code into a resulting nickel value. Currently completely (strictly) evaluates the nix code, and must result in a value serializable into JSON.
|
||||
#[cfg(feature = "nix-experimental")]
|
||||
EvalNix(),
|
||||
}
|
||||
|
||||
impl fmt::Display for UnaryOp {
|
||||
@ -1281,6 +1285,8 @@ impl fmt::Display for UnaryOp {
|
||||
RecordEmptyWithTail() => write!(f, "record_empty_with_tail"),
|
||||
Trace() => write!(f, "trace"),
|
||||
LabelPushDiag() => write!(f, "label_push_diag"),
|
||||
#[cfg(feature = "nix-experimental")]
|
||||
EvalNix() => write!(f, "eval_nix"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -207,6 +207,9 @@ pub fn get_uop_type(
|
||||
// Morally: Lbl -> Lbl
|
||||
// Actual: Dyn -> Dyn
|
||||
UnaryOp::LabelPushDiag() => (mk_uniftype::dynamic(), mk_uniftype::dynamic()),
|
||||
// Str -> Dyn
|
||||
#[cfg(feature = "nix-experimental")]
|
||||
UnaryOp::EvalNix() => (mk_uniftype::str(), mk_uniftype::dynamic()),
|
||||
})
|
||||
}
|
||||
|
||||
|
100
flake.lock
100
flake.lock
@ -41,7 +41,7 @@
|
||||
},
|
||||
"crane_2": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat_3",
|
||||
"flake-compat": "flake-compat_4",
|
||||
"flake-utils": "flake-utils_3",
|
||||
"nixpkgs": [
|
||||
"topiary",
|
||||
@ -111,6 +111,22 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat_4": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1673956053,
|
||||
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
@ -222,6 +238,22 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"lowdown-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1633514407,
|
||||
"narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=",
|
||||
"owner": "kristapsdz",
|
||||
"repo": "lowdown",
|
||||
"rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "kristapsdz",
|
||||
"repo": "lowdown",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-filter": {
|
||||
"locked": {
|
||||
"lastModified": 1687178632,
|
||||
@ -237,6 +269,27 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-input": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat_2",
|
||||
"lowdown-src": "lowdown-src",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nixpkgs-regression": "nixpkgs-regression"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1694598107,
|
||||
"narHash": "sha256-JEJSU2O+getWkc+Ql6Dsp72ZGihyZ2Ba7fMdv+ma4TQ=",
|
||||
"owner": "nixos",
|
||||
"repo": "nix",
|
||||
"rev": "b99fdcf8dbb38ec0be0e82f65d1d138ec9e89dda",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"repo": "nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1695830400,
|
||||
@ -247,9 +300,26 @@
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-unstable",
|
||||
"type": "indirect"
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-22.11-small",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-regression": {
|
||||
"locked": {
|
||||
"lastModified": 1643052045,
|
||||
"narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-stable": {
|
||||
@ -269,6 +339,21 @@
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1693565476,
|
||||
"narHash": "sha256-ya00zHt7YbPo3ve/wNZ/6nts61xt7wK/APa6aZAfey0=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "aa8aa7e2ea35ce655297e8322dc82bf77a31d04b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-unstable",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1681358109,
|
||||
"narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=",
|
||||
@ -286,7 +371,7 @@
|
||||
},
|
||||
"pre-commit-hooks": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat_2",
|
||||
"flake-compat": "flake-compat_3",
|
||||
"flake-utils": [
|
||||
"flake-utils"
|
||||
],
|
||||
@ -314,7 +399,8 @@
|
||||
"inputs": {
|
||||
"crane": "crane",
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nix-input": "nix-input",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"pre-commit-hooks": "pre-commit-hooks",
|
||||
"rust-overlay": "rust-overlay_2",
|
||||
"topiary": "topiary"
|
||||
@ -398,7 +484,7 @@
|
||||
"rust-overlay_4": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_5",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1689042658,
|
||||
|
19
flake.nix
19
flake.nix
@ -20,6 +20,7 @@
|
||||
url = "github:tweag/topiary";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
nix-input.url = "github:nixos/nix";
|
||||
};
|
||||
|
||||
nixConfig = {
|
||||
@ -35,6 +36,7 @@
|
||||
, rust-overlay
|
||||
, crane
|
||||
, topiary
|
||||
, nix-input
|
||||
}:
|
||||
let
|
||||
SYSTEMS = [
|
||||
@ -184,6 +186,7 @@
|
||||
snapFilter = mkFilter ".*snap$";
|
||||
scmFilter = mkFilter ".*scm$";
|
||||
mdFilter = mkFilter ".*md$"; # include markdown files for checking snippets in the documentation
|
||||
cxxFilter = mkFilter ".*(cc|hh)$";
|
||||
importsFilter = mkFilter ".*/core/tests/integration/imports/imported/.*$"; # include all files that are imported in tests
|
||||
|
||||
infraFilter = mkFilter ".*/infra/.*$";
|
||||
@ -201,6 +204,7 @@
|
||||
snapFilter
|
||||
scmFilter
|
||||
mdFilter
|
||||
cxxFilter
|
||||
filterCargoSources
|
||||
importsFilter
|
||||
] && !(builtins.any (filter: filter path type) [
|
||||
@ -297,7 +301,16 @@
|
||||
'';
|
||||
# pyo3 needs a Python interpreter in the build environment
|
||||
# https://pyo3.rs/v0.17.3/building_and_distribution#configuring-the-python-version
|
||||
buildInputs = [ pkgs.python3 ];
|
||||
nativeBuildInputs = with pkgs; [ pkg-config python3 ];
|
||||
buildInputs = with pkgs; [
|
||||
(nix-input.packages.${system}.default.overrideAttrs
|
||||
# SEE: https://github.com/NixOS/nix/issues/9107
|
||||
(_: lib.optionalAttrs (system == "x86_64-darwin") {
|
||||
doCheck = false;
|
||||
})
|
||||
)
|
||||
boost # implicit dependency of nix
|
||||
];
|
||||
|
||||
# seems to be needed for consumer cargoArtifacts to be able to use
|
||||
# zstd mode properly
|
||||
@ -413,7 +426,7 @@
|
||||
# Check that documentation builds without warnings or errors
|
||||
checkRustDoc = craneLib.cargoDoc {
|
||||
inherit pname src version cargoArtifacts env;
|
||||
inherit (cargoArtifactsDeps) buildInputs;
|
||||
inherit (cargoArtifactsDeps) nativeBuildInputs buildInputs;
|
||||
|
||||
RUSTDOCFLAGS = "-D warnings";
|
||||
|
||||
@ -434,7 +447,7 @@
|
||||
|
||||
clippy = craneLib.cargoClippy {
|
||||
inherit pname src cargoArtifacts env;
|
||||
inherit (cargoArtifactsDeps) buildInputs;
|
||||
inherit (cargoArtifactsDeps) nativeBuildInputs buildInputs;
|
||||
|
||||
cargoExtraArgs = cargoBuildExtraArgs;
|
||||
cargoClippyExtraArgs = "--all-features --all-targets --workspace -- --deny warnings --allow clippy::new-without-default --allow clippy::match_like_matches_macro";
|
||||
|
Loading…
Reference in New Issue
Block a user