Convert to manual pre-commit
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
host
|
||||
result
|
||||
.pre-commit-config.yaml
|
||||
.direnv
|
||||
# On home-manager only installs, this is built into the same dir
|
||||
# where I am storing my repo
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v6.0.0
|
||||
hooks:
|
||||
- id: check-added-large-files
|
||||
- id: check-case-conflict
|
||||
- id: check-illegal-windows-names
|
||||
- id: check-json
|
||||
- id: check-merge-conflict
|
||||
args:
|
||||
- "--assume-in-merge"
|
||||
- id: check-shebang-scripts-are-executable
|
||||
- id: check-symlinks
|
||||
- id: check-yaml
|
||||
- id: end-of-file-fixer
|
||||
- id: fix-byte-order-marker
|
||||
- id: mixed-line-ending
|
||||
- id: trailing-whitespace
|
||||
- repo: https://github.com/adrienverge/yamllint.git
|
||||
rev: v1.37.1
|
||||
hooks:
|
||||
- id: yamllint
|
||||
args:
|
||||
- "-d"
|
||||
- |-
|
||||
extends: default
|
||||
ignore:
|
||||
- manifests/cnpg-system/barman-cloud.yaml
|
||||
rules:
|
||||
comments: false
|
||||
comments-indentation: false
|
||||
document-start: false
|
||||
- repo: https://github.com/NixOS/nixfmt
|
||||
rev: v1.1.0
|
||||
hooks:
|
||||
- id: nixfmt-nix
|
||||
- repo: https://github.com/astro/deadnix
|
||||
rev: v1.3.1
|
||||
hooks:
|
||||
- id: deadnix
|
||||
+3
-34
@@ -1,5 +1,4 @@
|
||||
{
|
||||
hooks,
|
||||
lib,
|
||||
system,
|
||||
top,
|
||||
@@ -9,39 +8,9 @@
|
||||
let
|
||||
meta = import ./hosts/metadata.nix;
|
||||
in
|
||||
{
|
||||
pre-commit-check = hooks.lib.${system}.run {
|
||||
src = ./.;
|
||||
hooks = {
|
||||
deadnix.enable = true;
|
||||
# Needs https://github.com/DeterminateSystems/flake-checker/pull/130
|
||||
#flake-checker.enable = true;
|
||||
nixfmt-rfc-style.enable = true;
|
||||
check-merge-conflicts.enable = true;
|
||||
check-yaml.enable = true;
|
||||
yamllint = {
|
||||
enable = true;
|
||||
args = [
|
||||
"--config-data"
|
||||
(lib.generators.toYAML { } {
|
||||
extends = "default";
|
||||
ignore = [
|
||||
"manifests/cnpg-system/barman-cloud.yaml"
|
||||
".pre-commit-config.yaml"
|
||||
];
|
||||
rules = {
|
||||
comments = false;
|
||||
comments-indentation = false;
|
||||
document-start = false;
|
||||
};
|
||||
})
|
||||
];
|
||||
verbose = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
// (builtins.mapAttrs (_n: v: v.config.system.build.toplevel) (
|
||||
# Pulls all hosts down to be a check
|
||||
(builtins.mapAttrs (_n: v: v.config.system.build.toplevel) (
|
||||
lib.filterAttrs (n: _v: builtins.any (a: a == system) meta.${n}.arch) top.self.nixosConfigurations
|
||||
))
|
||||
# Adds all packages as a check
|
||||
// (top.self.packages.${system})
|
||||
|
||||
Generated
+6
-80
@@ -160,22 +160,6 @@
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1761588595,
|
||||
"narHash": "sha256-XKUZz9zewJNUj46b4AJdiRZJAvSZ0Dqj2BNfXvFlJC4=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "f387cd2afec9419c8ee37694406ca490c3f34ee5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat_2": {
|
||||
"locked": {
|
||||
"lastModified": 1747046372,
|
||||
"narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=",
|
||||
@@ -190,7 +174,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat_3": {
|
||||
"flake-compat_2": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1761588595,
|
||||
@@ -358,27 +342,6 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gitignore": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"hooks",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1709087332,
|
||||
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"haumea": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
@@ -468,26 +431,6 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"hooks": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"gitignore": "gitignore",
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1763988335,
|
||||
"narHash": "sha256-QlcnByMc8KBjpU37rbq5iP7Cp97HvjRP0ucfdh+M4Qc=",
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"rev": "50b9238891e388c9fdc6a5c49e49c42533a1b5ce",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"ixx": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
@@ -713,22 +656,6 @@
|
||||
}
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1759417375,
|
||||
"narHash": "sha256-O7eHcgkQXJNygY6AypkF9tFhsoDQjpNEojw3eFs73Ow=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "dc704e6102e76aad573f63b74c742cd96f8f1e6c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_4": {
|
||||
"locked": {
|
||||
"lastModified": 1764517877,
|
||||
"narHash": "sha256-pp3uT4hHijIC8JUK5MEqeAWmParJrgBVzHLNfJDZxg4=",
|
||||
@@ -744,7 +671,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_5": {
|
||||
"nixpkgs_4": {
|
||||
"locked": {
|
||||
"lastModified": 1759770925,
|
||||
"narHash": "sha256-CZwkCtzTNclqlhuwDsVtGoRumTpqCUK0xSnFIMgd8ls=",
|
||||
@@ -803,7 +730,7 @@
|
||||
"nurpkgs": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts_4",
|
||||
"nixpkgs": "nixpkgs_4"
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1764709261,
|
||||
@@ -869,7 +796,7 @@
|
||||
},
|
||||
"proxmox": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat_2",
|
||||
"flake-compat": "flake-compat",
|
||||
"nixpkgs-libvncserver": "nixpkgs-libvncserver",
|
||||
"nixpkgs-stable": "nixpkgs-stable",
|
||||
"nixpkgs-unstable": "nixpkgs-unstable_2",
|
||||
@@ -898,7 +825,6 @@
|
||||
"darwin": "darwin_2",
|
||||
"flake-parts": "flake-parts_2",
|
||||
"hmunstable": "hmunstable",
|
||||
"hooks": "hooks",
|
||||
"nix-hardware": "nix-hardware",
|
||||
"nixos-generators": "nixos-generators",
|
||||
"nixunstable": "nixunstable",
|
||||
@@ -1092,7 +1018,7 @@
|
||||
},
|
||||
"vsext": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs_5"
|
||||
"nixpkgs": "nixpkgs_4"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1764640937,
|
||||
@@ -1110,7 +1036,7 @@
|
||||
},
|
||||
"wsl": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat_3",
|
||||
"flake-compat": "flake-compat_2",
|
||||
"nixpkgs": [
|
||||
"nixunstable"
|
||||
]
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
inputs.nixpkgs.follows = "nixunstable";
|
||||
};
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
hooks.url = "github:cachix/git-hooks.nix";
|
||||
hmunstable = {
|
||||
url = "github:nix-community/home-manager/master";
|
||||
inputs.nixpkgs.follows = "nixunstable";
|
||||
|
||||
@@ -217,4 +217,3 @@ let g:ctrlp_user_command = {
|
||||
\}
|
||||
" let g:ctrpl_match_func = { 'match': 'pymatcher#PyMatch' }
|
||||
" map <F6> <Esc>:CtrlP<Cr>
|
||||
|
||||
|
||||
+18
-18
@@ -3,9 +3,9 @@ index a16b52a..37faf08 100644
|
||||
--- c/attic/src/nix_store/bindings/mod.rs
|
||||
+++ i/attic/src/nix_store/bindings/mod.rs
|
||||
@@ -10,6 +10,8 @@ use tokio::io::{AsyncWrite, AsyncWriteExt};
|
||||
|
||||
|
||||
use crate::{AtticError, AtticResult};
|
||||
|
||||
|
||||
+use super::stream_config::NarStreamConfig;
|
||||
+
|
||||
// The C++ implementation takes care of concurrency
|
||||
@@ -19,7 +19,7 @@ index a16b52a..37faf08 100644
|
||||
+ error::SendError, channel, Receiver, Sender,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+
|
||||
+
|
||||
/// Async write request.
|
||||
@@ -32,7 +32,7 @@ index a16b52a..37faf08 100644
|
||||
- sender: mpsc::UnboundedSender<AsyncWriteMessage>,
|
||||
+ sender: mpsc::Sender<AsyncWriteMessage>,
|
||||
}
|
||||
|
||||
|
||||
impl AsyncWriteSender {
|
||||
fn send(&mut self, data: &[u8]) -> Result<(), mpsc::SendError<AsyncWriteMessage>> {
|
||||
let message = AsyncWriteMessage::Data(Vec::from(data));
|
||||
@@ -41,13 +41,13 @@ index a16b52a..37faf08 100644
|
||||
+ // This provides backpressure when the channel is full
|
||||
+ self.sender.blocking_send(message).map_err(|e| mpsc::SendError(e.0))
|
||||
}
|
||||
|
||||
|
||||
fn eof(&mut self) -> Result<(), mpsc::SendError<AsyncWriteMessage>> {
|
||||
let message = AsyncWriteMessage::Eof;
|
||||
- self.sender.send(message)
|
||||
+ self.sender.blocking_send(message).map_err(|e| mpsc::SendError(e.0))
|
||||
}
|
||||
|
||||
|
||||
pub(crate) fn rust_error(
|
||||
@@ -76,19 +82,25 @@ impl AsyncWriteSender {
|
||||
error: impl std::error::Error,
|
||||
@@ -58,14 +58,14 @@ index a16b52a..37faf08 100644
|
||||
+ self.sender.try_send(message)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// A wrapper of the `AsyncWrite` trait for the synchronous Nix C++ land.
|
||||
pub struct AsyncWriteAdapter {
|
||||
- receiver: mpsc::UnboundedReceiver<AsyncWriteMessage>,
|
||||
+ receiver: mpsc::Receiver<AsyncWriteMessage>,
|
||||
eof: bool,
|
||||
}
|
||||
|
||||
|
||||
impl AsyncWriteAdapter {
|
||||
pub fn new() -> (Self, Box<AsyncWriteSender>) {
|
||||
- let (sender, receiver) = mpsc::unbounded_channel();
|
||||
@@ -75,7 +75,7 @@ index a16b52a..37faf08 100644
|
||||
+ pub fn new_with_config(config: NarStreamConfig) -> (Self, Box<AsyncWriteSender>) {
|
||||
+ // Use bounded channel to provide backpressure and prevent OOM
|
||||
+ let (sender, receiver) = mpsc::channel(config.channel_capacity);
|
||||
|
||||
|
||||
let r = Self {
|
||||
receiver,
|
||||
diff --git c/attic/src/nix_store/mod.rs i/attic/src/nix_store/mod.rs
|
||||
@@ -85,7 +85,7 @@ index 4e08a67..04ef0f6 100644
|
||||
@@ -46,6 +46,9 @@ mod bindings;
|
||||
#[cfg(feature = "nix_store")]
|
||||
mod nix_store;
|
||||
|
||||
|
||||
+#[cfg(feature = "nix_store")]
|
||||
+mod stream_config;
|
||||
+
|
||||
@@ -95,34 +95,34 @@ index 4e08a67..04ef0f6 100644
|
||||
@@ -61,6 +64,9 @@ use crate::hash::Hash;
|
||||
#[cfg(feature = "nix_store")]
|
||||
pub use nix_store::NixStore;
|
||||
|
||||
|
||||
+#[cfg(feature = "nix_store")]
|
||||
+pub use stream_config::NarStreamConfig;
|
||||
+
|
||||
#[cfg(test)]
|
||||
pub mod tests;
|
||||
|
||||
|
||||
diff --git c/attic/src/nix_store/nix_store.rs i/attic/src/nix_store/nix_store.rs
|
||||
index 3b754f9..91eb489 100644
|
||||
--- c/attic/src/nix_store/nix_store.rs
|
||||
+++ i/attic/src/nix_store/nix_store.rs
|
||||
@@ -8,6 +8,7 @@ use std::sync::Arc;
|
||||
use tokio::task::spawn_blocking;
|
||||
|
||||
|
||||
use super::bindings::{open_nix_store, AsyncWriteAdapter, FfiNixStore};
|
||||
+use super::stream_config::NarStreamConfig;
|
||||
use super::{to_base_name, StorePath, ValidPathInfo};
|
||||
use crate::error::AtticResult;
|
||||
use crate::hash::Hash;
|
||||
@@ -19,11 +20,18 @@ pub struct NixStore {
|
||||
|
||||
|
||||
/// Path to the Nix store itself.
|
||||
store_dir: PathBuf,
|
||||
+
|
||||
+ /// Configuration for NAR streaming.
|
||||
+ stream_config: NarStreamConfig,
|
||||
}
|
||||
|
||||
|
||||
#[cfg(feature = "nix_store")]
|
||||
impl NixStore {
|
||||
pub fn connect() -> AtticResult<Self> {
|
||||
@@ -140,11 +140,11 @@ index 3b754f9..91eb489 100644
|
||||
+ stream_config,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -84,12 +93,26 @@ impl NixStore {
|
||||
self.store_dir.join(&store_path.base_name)
|
||||
}
|
||||
|
||||
|
||||
- /// Creates a NAR archive from a path.
|
||||
+ /// Creates a NAR archive from a path with default configuration.
|
||||
///
|
||||
@@ -168,7 +168,7 @@ index 3b754f9..91eb489 100644
|
||||
- let (adapter, mut sender) = AsyncWriteAdapter::new();
|
||||
+ let (adapter, mut sender) = AsyncWriteAdapter::new_with_config(stream_config);
|
||||
let base_name = Vec::from(store_path.as_base_name_bytes());
|
||||
|
||||
|
||||
spawn_blocking(move || {
|
||||
diff --git c/attic/src/nix_store/stream_config.rs i/attic/src/nix_store/stream_config.rs
|
||||
new file mode 100644
|
||||
|
||||
+1
-1
@@ -69,4 +69,4 @@
|
||||
"hash": "sha256-spT7EFXLnI0FWT9Vlvp7QEP0urntmQ2C+fQB5bVLoLE="
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-4
@@ -1,5 +1,4 @@
|
||||
{
|
||||
self',
|
||||
pkgs,
|
||||
nixvimunstable,
|
||||
...
|
||||
@@ -18,19 +17,19 @@ let
|
||||
in
|
||||
{
|
||||
default = pkgs.mkShell {
|
||||
inherit (self'.checks.pre-commit-check) shellHook;
|
||||
buildInputs = with pkgs; [
|
||||
bashInteractive
|
||||
stdenv.cc
|
||||
curl
|
||||
git
|
||||
gnutar
|
||||
gzip
|
||||
inject
|
||||
inject-darwin
|
||||
nushell
|
||||
vim
|
||||
self'.checks.pre-commit-check.enabledPackages
|
||||
tmux
|
||||
xonsh
|
||||
zellij
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user