chore: Apply nixfmt

(cherry picked from commit d11c2029c5a33ec522f46dd3e00fec8db2c3729b)
This commit is contained in:
Robert Hensing 2025-08-26 14:52:12 +02:00
parent eba8c06c9d
commit 83dece62b2
3 changed files with 184 additions and 138 deletions

View file

@ -1,9 +1,17 @@
{ lib, inputs, withSystem, ... }: {
{
lib,
inputs,
withSystem,
...
}:
{
imports = [
inputs.pre-commit-hooks-nix.flakeModule
inputs.hercules-ci-effects.flakeModule
];
perSystem = { config, pkgs, ... }: {
perSystem =
{ config, pkgs, ... }:
{
pre-commit.settings.hooks.nixfmt-rfc-style.enable = true;
# Temporarily disable rustfmt due to configuration issues
@ -41,10 +49,14 @@
NIX_DEBUG_INFO_DIRS =
let
# TODO: add to Nixpkgs lib
getDebug = pkg:
if pkg?debug then pkg.debug
else if pkg?lib then pkg.lib
else pkg;
getDebug =
pkg:
if pkg ? debug then
pkg.debug
else if pkg ? lib then
pkg.lib
else
pkg;
in
"${getDebug config.packages.nix}/lib/debug";
buildInputs = [
@ -73,7 +85,9 @@
NIX_PATH = "nixpkgs=${inputs.nixpkgs}";
};
};
herculesCI = hci@{ config, ... }: {
herculesCI =
hci@{ config, ... }:
{
ciSystems = [ "x86_64-linux" ];
};
flake = { };

View file

@ -10,17 +10,34 @@
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = inputs@{ self, flake-parts, ... }:
flake-parts.lib.mkFlake
{ inherit inputs; }
({ lib, ... }: {
outputs =
inputs@{ self, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } (
{
lib,
...
}:
{
imports = [
inputs.nix-cargo-integration.flakeModule
inputs.flake-parts.flakeModules.partitions
./rust/nci.nix
];
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
perSystem = { config, self', inputs', pkgs, ... }: {
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
perSystem =
{
config,
self',
inputs',
pkgs,
...
}:
{
packages.nix = inputs'.nix.packages.nix;
};
@ -31,5 +48,6 @@
partitions.dev.module = {
imports = [ ./dev/flake-module.nix ];
};
});
}
);
}

View file

@ -1,5 +1,12 @@
{
perSystem = { lib, config, pkgs, ... }: {
perSystem =
{
lib,
config,
pkgs,
...
}:
{
# https://flake.parts/options/nix-cargo-integration
nci.projects.nix-bindings = {
path = ./.;
@ -8,16 +15,21 @@
buildInputs = [
# stdbool.h
pkgs.stdenv.cc
] ++
(if config.packages.nix?libs
then
let l = config.packages.nix.libs; in [
]
++ (
if config.packages.nix ? libs then
let
l = config.packages.nix.libs;
in
[
l.nix-expr-c
l.nix-store-c
l.nix-util-c
l.nix-flake-c
]
else [ config.packages.nix ]);
else
[ config.packages.nix ]
);
nativeBuildInputs = [
pkgs.pkg-config
];
@ -45,21 +57,23 @@
echo "Configuring relocated store at $NIX_REMOTE..."
# Init ahead of time, because concurrent initialization is flaky
${# Not using nativeBuildInputs because this should (hopefully) be
${
# Not using nativeBuildInputs because this should (hopefully) be
# the only place where we need a nix binary. Let's stay in control.
pkgs.buildPackages.nix}/bin/nix-store --init
pkgs.buildPackages.nix
}/bin/nix-store --init
echo "Store initialized."
'';
};
# NOTE: duplicated in flake.nix devShell
env = {
LIBCLANG_PATH =
lib.makeLibraryPath [ pkgs.buildPackages.llvmPackages.clang-unwrapped ];
LIBCLANG_PATH = lib.makeLibraryPath [ pkgs.buildPackages.llvmPackages.clang-unwrapped ];
BINDGEN_EXTRA_CLANG_ARGS =
# Work around missing [[deprecated]] in clang
"-x c++ -std=c++2a";
} // lib.optionalAttrs pkgs.stdenv.cc.isGNU {
}
// lib.optionalAttrs pkgs.stdenv.cc.isGNU {
# Avoid cc wrapper, because we only need to add the compiler/"system" dirs
NIX_CC_UNWRAPPED = "${pkgs.stdenv.cc.cc}/bin/gcc";
};