diff --git a/.gitignore b/.gitignore index 12a76b9..53aa5b0 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..f08fb00 --- /dev/null +++ b/.pre-commit-config.yaml @@ -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 diff --git a/checks.nix b/checks.nix index 29a2970..3e846a0 100644 --- a/checks.nix +++ b/checks.nix @@ -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}) diff --git a/flake.lock b/flake.lock index 3196448..050d843 100644 --- a/flake.lock +++ b/flake.lock @@ -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" ] diff --git a/flake.nix b/flake.nix index e3237b2..2c591ef 100644 --- a/flake.nix +++ b/flake.nix @@ -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"; diff --git a/home/baseline/vim/vimrc b/home/baseline/vim/vimrc index caf64c1..b4de629 100644 --- a/home/baseline/vim/vimrc +++ b/home/baseline/vim/vimrc @@ -217,4 +217,3 @@ let g:ctrlp_user_command = { \} " let g:ctrpl_match_func = { 'match': 'pymatcher#PyMatch' } " map :CtrlP - diff --git a/overlays/attic-client.patch b/overlays/attic-client.patch index b4dcee8..0a36493 100644 --- a/overlays/attic-client.patch +++ b/overlays/attic-client.patch @@ -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, + sender: mpsc::Sender, } - + impl AsyncWriteSender { fn send(&mut self, data: &[u8]) -> Result<(), mpsc::SendError> { 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> { 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, + receiver: mpsc::Receiver, eof: bool, } - + impl AsyncWriteAdapter { pub fn new() -> (Self, Box) { - let (sender, receiver) = mpsc::unbounded_channel(); @@ -75,7 +75,7 @@ index a16b52a..37faf08 100644 + pub fn new_with_config(config: NarStreamConfig) -> (Self, Box) { + // 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 { @@ -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 diff --git a/pkgs/zim/blobs.json b/pkgs/zim/blobs.json index 0e6c621..091e299 100644 --- a/pkgs/zim/blobs.json +++ b/pkgs/zim/blobs.json @@ -69,4 +69,4 @@ "hash": "sha256-spT7EFXLnI0FWT9Vlvp7QEP0urntmQ2C+fQB5bVLoLE=" } } -} \ No newline at end of file +} diff --git a/shells.nix b/shells.nix index e7ca76d..8169776 100644 --- a/shells.nix +++ b/shells.nix @@ -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 ]; }; }