Skip to content

Commit f24b749

Browse files
authored
Merge pull request #24 from nixops4/treefmt
Format, and keep formatted
2 parents d83eb57 + 4a1889f commit f24b749

File tree

8 files changed

+79
-107
lines changed

8 files changed

+79
-107
lines changed

dev/flake-module.nix

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
imports = [
77
inputs.pre-commit-hooks-nix.flakeModule
88
inputs.hercules-ci-effects.flakeModule
9+
inputs.treefmt-nix.flakeModule
910
];
1011
perSystem =
1112
{
@@ -17,7 +18,20 @@
1718
{
1819
nix-bindings-rust.nixPackage = inputs'.nix.packages.default;
1920

20-
pre-commit.settings.hooks.nixfmt-rfc-style.enable = true;
21+
treefmt = {
22+
# Used to find the project root
23+
projectRootFile = "flake.lock";
24+
25+
programs.rustfmt = {
26+
enable = true;
27+
edition = "2021";
28+
};
29+
programs.nixfmt.enable = true;
30+
programs.deadnix.enable = true;
31+
#programs.clang-format.enable = true;
32+
};
33+
34+
pre-commit.settings.hooks.treefmt.enable = true;
2135
# Temporarily disable rustfmt due to configuration issues
2236
# pre-commit.settings.hooks.rustfmt.enable = true;
2337
pre-commit.settings.settings.rust.cargoManifestPath = "./Cargo.toml";
@@ -90,7 +104,7 @@
90104
};
91105
};
92106
herculesCI =
93-
{ config, ... }:
107+
{ ... }:
94108
{
95109
ciSystems = [ "x86_64-linux" ];
96110
};

dev/flake.lock

Lines changed: 6 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/flake.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
pre-commit-hooks-nix.url = "github:cachix/pre-commit-hooks.nix";
55
pre-commit-hooks-nix.inputs.nixpkgs.follows = "";
66
hercules-ci-effects.url = "github:hercules-ci/hercules-ci-effects";
7+
treefmt-nix.url = "github:numtide/treefmt-nix";
8+
treefmt-nix.inputs.nixpkgs.follows = "";
79
};
810
outputs = { ... }: { };
911
}

flake.nix

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
};
1212

1313
outputs =
14-
inputs@{ self, flake-parts, ... }:
14+
inputs@{ flake-parts, ... }:
1515
flake-parts.lib.mkFlake { inherit inputs; } (
1616
toplevel@{
1717
lib,
18-
withSystem,
1918
...
2019
}:
2120
let
@@ -24,9 +23,7 @@
2423
*/
2524
flake-parts-modules.basic =
2625
{
27-
config,
2826
flake-parts-lib,
29-
withSystem,
3027
...
3128
}:
3229
{
@@ -114,7 +111,7 @@
114111
*/
115112
flake-parts-modules.tested =
116113
# Consumer toplevel
117-
{ options, config, ... }:
114+
{ config, ... }:
118115
{
119116
_file = ./flake.nix;
120117
imports = [ flake-parts-modules.basic ];
@@ -177,10 +174,7 @@
177174
];
178175
perSystem =
179176
{
180-
config,
181-
self',
182177
inputs',
183-
pkgs,
184178
...
185179
}:
186180
{

nci.nix

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
{
22
perSystem =
33
{
4-
lib,
54
config,
6-
pkgs,
75
...
86
}:
97
{

nix-bindings-expr/src/eval_state.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ use nix_bindings_bindgen_raw as raw;
138138
use nix_bindings_store::path::StorePath;
139139
use nix_bindings_store::store::{Store, StoreWeak};
140140
use nix_bindings_util::context::Context;
141-
use nix_bindings_util::string_return::{callback_get_result_string, callback_get_result_string_data};
141+
use nix_bindings_util::string_return::{
142+
callback_get_result_string, callback_get_result_string_data,
143+
};
142144
use nix_bindings_util::{check_call, check_call_opt_key, result_string_init};
143145
use std::ffi::{c_char, CString};
144146
use std::iter::FromIterator;
@@ -1217,7 +1219,8 @@ pub fn test_init() {
12171219
// which causes an error. So we set a custom build dir here.
12181220
// Only available on linux
12191221
if cfg!(target_os = "linux") {
1220-
nix_bindings_util::settings::set("sandbox-build-dir", "/custom-build-dir-for-test").unwrap();
1222+
nix_bindings_util::settings::set("sandbox-build-dir", "/custom-build-dir-for-test")
1223+
.unwrap();
12211224
}
12221225
std::env::set_var("_NIX_TEST_NO_SANDBOX", "1");
12231226

@@ -1784,9 +1787,7 @@ mod tests {
17841787
gc_registering_current_thread(|| {
17851788
let store = Store::open(None, HashMap::new()).unwrap();
17861789
let mut es = EvalState::new(store, []).unwrap();
1787-
let v = es
1788-
.eval_from_string("[ ]", "<test>")
1789-
.unwrap();
1790+
let v = es.eval_from_string("[ ]", "<test>").unwrap();
17901791
es.force(&v).unwrap();
17911792
let t = es.value_type_unforced(&v);
17921793
assert!(t == Some(ValueType::List));

nix-bindings-flake/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ impl FlakeSettings {
4545

4646
pub trait EvalStateBuilderExt {
4747
/// Configures the eval state to provide flakes features such as `builtins.getFlake`.
48-
fn flakes(self, settings: &FlakeSettings) -> Result<nix_bindings_expr::eval_state::EvalStateBuilder>;
48+
fn flakes(
49+
self,
50+
settings: &FlakeSettings,
51+
) -> Result<nix_bindings_expr::eval_state::EvalStateBuilder>;
4952
}
5053
impl EvalStateBuilderExt for nix_bindings_expr::eval_state::EvalStateBuilder {
5154
/// Configures the eval state to provide flakes features such as `builtins.getFlake`.

0 commit comments

Comments
 (0)