From 3359c62cb300d0a29f9e7aeeb2253f2cf9ec80da Mon Sep 17 00:00:00 2001 From: Justin Rubek <25621857+justinrubek@users.noreply.github.com> Date: Thu, 5 Oct 2023 20:02:05 -0500 Subject: [PATCH] refactor(nix): restructure flake This unpacks the flake into a few different files. This more closely matches the way that I write my projects and separates some concerns out such as managing devShells alongside cargo builds. Many of the flake inputs have been updated to take advantage of newer features such as treefmt in pre-commit-hooks. Configuration for cocogitto and bomper are also included to handle releases. --- bomp.ron | 3 + cog.toml | 23 + flake-parts/cargo.nix | 155 +++---- flake-parts/ci.nix | 34 ++ flake-parts/formatting.nix | 32 ++ flake-parts/pre-commit.nix | 21 + flake-parts/rust-toolchain.nix | 38 ++ flake-parts/shells.nix | 40 ++ flake.lock | 749 +++++++++++++++++++++++++++++++-- flake.nix | 19 +- treefmt.toml | 8 + 11 files changed, 984 insertions(+), 138 deletions(-) create mode 100644 bomp.ron create mode 100644 cog.toml create mode 100644 flake-parts/ci.nix create mode 100644 flake-parts/formatting.nix create mode 100644 flake-parts/pre-commit.nix create mode 100644 flake-parts/rust-toolchain.nix create mode 100644 flake-parts/shells.nix create mode 100644 treefmt.toml diff --git a/bomp.ron b/bomp.ron new file mode 100644 index 0000000..960b7c9 --- /dev/null +++ b/bomp.ron @@ -0,0 +1,3 @@ +( + cargo: Some(Autodetect), +) diff --git a/cog.toml b/cog.toml new file mode 100644 index 0000000..62b0192 --- /dev/null +++ b/cog.toml @@ -0,0 +1,23 @@ +ignore_merge_commits = false +branch_whitelist = ["main"] +pre_bump_hooks = [ + "bomper {{latest}} {{version}}" +] +post_bump_hooks = [ + "git push", + "git push origin {{version}}" +] + +[commit_types] + +[changelog] +path = "CHANGELOG.md" +template = "remote" +remote = "github.com" +repository = "thoenix" +owner = "justinrubek" +authors = [ + { signature = "Justin Rubek", username = "justinrubek" } +] + +[bump_profiles] diff --git a/flake-parts/cargo.nix b/flake-parts/cargo.nix index a275ba7..8bfca90 100644 --- a/flake-parts/cargo.nix +++ b/flake-parts/cargo.nix @@ -2,56 +2,35 @@ inputs, self, ... -} @ part-inputs: { - imports = []; - +}: { perSystem = { pkgs, lib, system, inputs', + self', ... }: let - devTools = with pkgs; [ - # rust tooling - fenix-toolchain - bacon - rustfmt - cargo-nextest - # misc - pkgs.terraform - ]; - - extraNativeBuildInputs = [ - pkgs.pkg-config - pkgs.openssl - pkgs.openssl.dev - ] ++ lib.optionals pkgs.stdenv.isDarwin [ - pkgs.libiconv - pkgs.darwin.apple_sdk.frameworks.AppKit - pkgs.darwin.apple_sdk.frameworks.CoreFoundation - pkgs.darwin.apple_sdk.frameworks.CoreServices - pkgs.darwin.apple_sdk.frameworks.Foundation - pkgs.darwin.apple_sdk.frameworks.Security - ]; - - # allBuildInputs = base: base ++ extraBuildInputs; - allNativeBuildInputs = base: base ++ extraNativeBuildInputs; - - fenix-channel = inputs'.fenix.packages.latest; - fenix-toolchain = fenix-channel.withComponents [ - "rustc" - "cargo" - "clippy" - "rust-analysis" - "rust-src" - "rustfmt" - "llvm-tools-preview" - ]; - - craneLib = inputs.crane.lib.${system}.overrideToolchain fenix-toolchain; - - common-build-args = rec { + # packages required for building the rust packages + extraPackages = + [ + pkgs.pkg-config + pkgs.openssl + pkgs.openssl.dev + ] + ++ lib.optionals pkgs.stdenv.isDarwin [ + pkgs.libiconv + pkgs.darwin.apple_sdk.frameworks.AppKit + pkgs.darwin.apple_sdk.frameworks.CoreFoundation + pkgs.darwin.apple_sdk.frameworks.CoreServices + pkgs.darwin.apple_sdk.frameworks.Foundation + pkgs.darwin.apple_sdk.frameworks.Security + ]; + withExtraPackages = base: base ++ extraPackages; + + craneLib = inputs.crane.lib.${system}.overrideToolchain self'.packages.rust-toolchain; + + commonArgs = rec { src = inputs.nix-filter.lib { root = ../.; include = [ @@ -63,69 +42,53 @@ pname = "thoenix"; - nativeBuildInputs = allNativeBuildInputs []; + nativeBuildInputs = withExtraPackages []; LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath nativeBuildInputs; }; - deps-only = craneLib.buildDepsOnly ({} // common-build-args); - - clippy-check = craneLib.cargoClippy ({ - cargoArtifacts = deps-only; - cargoClippyExtraArgs = "--all-features -- --deny warnings"; - } - // common-build-args); - - rust-fmt-check = craneLib.cargoFmt ({ - inherit (common-build-args) src; - } - // common-build-args); - - tests-check = craneLib.cargoNextest ({ - cargoArtifacts = deps-only; - partitions = 1; - partitionType = "count"; - } - // common-build-args); - - pre-commit-hooks = inputs.pre-commit-hooks.lib.${system}.run { - inherit (common-build-args) src; - hooks = { - alejandra.enable = true; - rustfmt.enable = true; - }; - }; - cli-package = craneLib.buildPackage ({ - pname = "thoenix"; - cargoArtifacts = deps-only; - cargoExtraArgs = "--bin thoenix"; - } - // common-build-args); - in rec { - devShells.default = pkgs.mkShell rec { - packages = allNativeBuildInputs [fenix-toolchain] ++ devTools; - LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath packages; - inherit (self.checks.${system}.pre-commit-hooks) shellHook; - }; + cargoArtifacts = craneLib.buildDepsOnly commonArgs; packages = { - inherit fenix-toolchain; default = packages.cli; - cli = cli-package; + cli = craneLib.buildPackage ({ + pname = "thoenix"; + inherit cargoArtifacts; + cargoExtraArgs = "--bin thoenix"; + meta.mainProgram = "thoenix"; + } + // commonArgs); + + cargo-doc = craneLib.cargoDoc ({ + inherit cargoArtifacts; + } + // commonArgs); }; - apps = { - cli = { - type = "app"; - program = "${self.packages.${system}.cli}/bin/thoenix"; - }; - default = apps.cli; + checks = { + clippy = craneLib.cargoClippy (commonArgs + // { + inherit cargoArtifacts; + cargoClippyExtraArgs = "--all-features -- --deny warnings"; + }); + + rust-fmt = craneLib.cargoFmt (commonArgs + // { + inherit (commonArgs) src; + }); + + rust-tests = craneLib.cargoNextest (commonArgs + // { + inherit cargoArtifacts; + partitions = 1; + partitionType = "count"; + cargoExtraArgs = "--exclude annapurna-wasm --exclude annapurna-ui --workspace"; + }); }; + in rec { + inherit packages checks; - checks = { - inherit pre-commit-hooks; - clippy = clippy-check; - tests = tests-check; - rust-fmt = rust-fmt-check; + legacyPackages = { + cargoExtraPackages = extraPackages; }; }; } diff --git a/flake-parts/ci.nix b/flake-parts/ci.nix new file mode 100644 index 0000000..8f67ac4 --- /dev/null +++ b/flake-parts/ci.nix @@ -0,0 +1,34 @@ +{inputs, ...}: { + perSystem = { + config, + pkgs, + system, + inputs', + self', + ... + }: let + ciPackages = [ + self'.packages.cocogitto + self'.packages.bomper + ]; + + packages = { + cocogitto = pkgs.cocogitto; + bomper = inputs'.bomper.packages.cli; + }; + + devShells = { + ci = pkgs.mkShell rec { + packages = ciPackages; + + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath packages; + }; + }; + in rec { + inherit devShells packages; + + legacyPackages = { + inherit ciPackages; + }; + }; +} diff --git a/flake-parts/formatting.nix b/flake-parts/formatting.nix new file mode 100644 index 0000000..3380342 --- /dev/null +++ b/flake-parts/formatting.nix @@ -0,0 +1,32 @@ +{ + inputs, + self, + ... +}: { + perSystem = { + pkgs, + lib, + ... + }: let + formatters = [ + pkgs.alejandra + pkgs.rustfmt + ]; + + treefmt = pkgs.writeShellApplication { + name = "treefmt"; + runtimeInputs = [pkgs.treefmt] ++ formatters; + text = '' + exec treefmt "$@" + ''; + }; + in { + packages = { + inherit treefmt; + }; + + legacyPackages = { + inherit formatters; + }; + }; +} diff --git a/flake-parts/pre-commit.nix b/flake-parts/pre-commit.nix new file mode 100644 index 0000000..c05463c --- /dev/null +++ b/flake-parts/pre-commit.nix @@ -0,0 +1,21 @@ +{ + inputs, + self, + ... +}: { + perSystem = {self', ...}: let + in { + pre-commit = { + check.enable = true; + + settings = { + src = ../.; + hooks = { + treefmt.enable = true; + }; + + settings.treefmt.package = self'.packages.treefmt; + }; + }; + }; +} diff --git a/flake-parts/rust-toolchain.nix b/flake-parts/rust-toolchain.nix new file mode 100644 index 0000000..3395281 --- /dev/null +++ b/flake-parts/rust-toolchain.nix @@ -0,0 +1,38 @@ +{...}: { + perSystem = { + inputs', + lib, + pkgs, + ... + }: let + # "stable", "latest", "minimal", "complete" + channel = "latest"; + fenix-channel = inputs'.fenix.packages.${channel}; + + # rust targets + fenix-targets = with inputs'.fenix.packages.targets; + [ + x86_64-unknown-linux-gnu.${channel}.rust-std + aarch64-unknown-linux-gnu.${channel}.rust-std + ] + ++ lib.optionals pkgs.stdenv.isDarwin [ + x86_64-apple-darwin.${channel}.rust-std + aarch64-apple-darwin.${channel}.rust-std + ]; + + fenix-toolchain = inputs'.fenix.packages.combine ([ + fenix-channel.rustc + fenix-channel.cargo + fenix-channel.clippy + fenix-channel.rust-analysis + fenix-channel.rust-src + fenix-channel.rustfmt + fenix-channel.llvm-tools-preview + ] + ++ fenix-targets); + in { + packages = { + rust-toolchain = fenix-toolchain; + }; + }; +} diff --git a/flake-parts/shells.nix b/flake-parts/shells.nix new file mode 100644 index 0000000..19ebe0c --- /dev/null +++ b/flake-parts/shells.nix @@ -0,0 +1,40 @@ +{inputs, ...}: { + perSystem = { + config, + pkgs, + system, + inputs', + self', + lib, + ... + }: let + inherit (self'.packages) rust-toolchain; + inherit (self'.legacyPackages) cargoExtraPackages ciPackages; + + devTools = [ + # rust tooling + rust-toolchain + pkgs.cargo-audit + pkgs.cargo-udeps + pkgs.cargo-nextest + pkgs.bacon + # formatting + self'.packages.treefmt + # misc + pkgs.terraform + ]; + in { + devShells = { + default = pkgs.mkShell rec { + packages = devTools ++ cargoExtraPackages ++ ciPackages; + + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath packages; + RUST_SRC_PATH = "${self'.packages.rust-toolchain}/lib/rustlib/src/rust/src"; + + shellHook = '' + ${config.pre-commit.installationScript} + ''; + }; + }; + }; +} diff --git a/flake.lock b/flake.lock index d039ab5..19ae694 100644 --- a/flake.lock +++ b/flake.lock @@ -32,15 +32,117 @@ "type": "github" } }, + "bomper": { + "inputs": { + "bomper": "bomper_2", + "crane": "crane_2", + "fenix": "fenix_2", + "flake-parts": "flake-parts_2", + "nix-filter": "nix-filter_2", + "nixpkgs": [ + "nixpkgs" + ], + "pre-commit-hooks": "pre-commit-hooks_2" + }, + "locked": { + "lastModified": 1693771860, + "narHash": "sha256-0z+bBJ/bSDv2CTj5CJ77PG3Nj7GilscjbMrc4hXxMCY=", + "owner": "justinrubek", + "repo": "bomper", + "rev": "5eb97995c0993cb87fe8f4b2e08ac7ce827a04f9", + "type": "github" + }, + "original": { + "owner": "justinrubek", + "repo": "bomper", + "type": "github" + } + }, + "bomper_2": { + "inputs": { + "crane": "crane", + "fenix": "fenix", + "flake-parts": "flake-parts", + "flake-utils": "flake-utils_2", + "nix-filter": "nix-filter", + "nixpkgs": [ + "bomper", + "nixpkgs" + ], + "pre-commit-hooks": "pre-commit-hooks" + }, + "locked": { + "lastModified": 1684981875, + "narHash": "sha256-tPiVrvDSzC9eCDZzeGilUKHw5J+rS2m8fOUVc42Zk10=", + "owner": "justinrubek", + "repo": "bomper", + "rev": "2879aef8363632128d07e1d58085497fd8c557dd", + "type": "github" + }, + "original": { + "owner": "justinrubek", + "repo": "bomper", + "type": "github" + } + }, "crane": { "inputs": { "flake-compat": "flake-compat", "flake-utils": "flake-utils", "nixpkgs": [ + "bomper", + "bomper", "nixpkgs" ], "rust-overlay": "rust-overlay" }, + "locked": { + "lastModified": 1684468982, + "narHash": "sha256-EoC1N5sFdmjuAP3UOkyQujSOT6EdcXTnRw8hPjJkEgc=", + "owner": "ipetkov", + "repo": "crane", + "rev": "99de890b6ef4b4aab031582125b6056b792a4a30", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "crane_2": { + "inputs": { + "flake-compat": "flake-compat_3", + "flake-utils": "flake-utils_4", + "nixpkgs": [ + "bomper", + "nixpkgs" + ], + "rust-overlay": "rust-overlay_2" + }, + "locked": { + "lastModified": 1684468982, + "narHash": "sha256-EoC1N5sFdmjuAP3UOkyQujSOT6EdcXTnRw8hPjJkEgc=", + "owner": "ipetkov", + "repo": "crane", + "rev": "99de890b6ef4b4aab031582125b6056b792a4a30", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "crane_3": { + "inputs": { + "flake-compat": "flake-compat_5", + "flake-utils": "flake-utils_6", + "nixpkgs": [ + "nixpkgs" + ], + "rust-overlay": "rust-overlay_3" + }, "locked": { "lastModified": 1674348649, "narHash": "sha256-hBRlaUlsrmW1wAPevwQnkrT0XiLrmlAHWabWYmLeQlQ=", @@ -58,16 +160,61 @@ "fenix": { "inputs": { "nixpkgs": [ + "bomper", + "bomper", "nixpkgs" ], "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1674973297, - "narHash": "sha256-YPeiGZPeGn3xYNfKSWW04jBne1CUusURvNzZa0sppiY=", + "lastModified": 1684909271, + "narHash": "sha256-jaBSRiB/6bQocsdAd+LGNJydB1B9BuKKn8V6spi0Nxg=", + "owner": "nix-community", + "repo": "fenix", + "rev": "8f2abd362e6a93c0e0ddc3c8dc7734a6a1c9f894", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "fenix_2": { + "inputs": { + "nixpkgs": [ + "bomper", + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src_2" + }, + "locked": { + "lastModified": 1684909271, + "narHash": "sha256-jaBSRiB/6bQocsdAd+LGNJydB1B9BuKKn8V6spi0Nxg=", + "owner": "nix-community", + "repo": "fenix", + "rev": "8f2abd362e6a93c0e0ddc3c8dc7734a6a1c9f894", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "fenix_3": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src_3" + }, + "locked": { + "lastModified": 1696486940, + "narHash": "sha256-xQRns0wxLoXcLVYBELB+BF/UD/kZG0p4nfS3WL1VzRA=", "owner": "nix-community", "repo": "fenix", - "rev": "8ac023ad0108cae2bacfc7a1cc3f9219e6b4520a", + "rev": "c4593ee2fca543e9f0226aade57be9c75d6e1e78", "type": "github" }, "original": { @@ -77,6 +224,70 @@ } }, "flake-compat": { + "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-compat_2": { + "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-compat_3": { + "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-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-compat_5": { "flake": false, "locked": { "lastModified": 1668681692, @@ -92,7 +303,7 @@ "type": "github" } }, - "flake-compat_2": { + "flake-compat_6": { "flake": false, "locked": { "lastModified": 1673956053, @@ -113,11 +324,47 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1668450977, - "narHash": "sha256-cfLhMhnvXn6x1vPm+Jow3RiFAUSCw/l1utktCw5rVA4=", + "lastModified": 1678379998, + "narHash": "sha256-TZdfNqftHhDuIFwBcN9MUThx5sQXCTeZk9je5byPKRw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c13d60b89adea3dc20704c045ec4d50dd964d447", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_2" + }, + "locked": { + "lastModified": 1678379998, + "narHash": "sha256-TZdfNqftHhDuIFwBcN9MUThx5sQXCTeZk9je5byPKRw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c13d60b89adea3dc20704c045ec4d50dd964d447", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_3": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_3" + }, + "locked": { + "lastModified": 1696343447, + "narHash": "sha256-B2xAZKLkkeRFG5XcHHSXXcP7To9Xzr59KXeZiRf4vdQ=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "d591857e9d7dd9ddbfba0ea02b43b927c3c0f1fa", + "rev": "c9afaba3dfa4085dbd2ccb38dfade5141e33d9d4", "type": "github" }, "original": { @@ -127,6 +374,39 @@ } }, "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1656928814, + "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { "locked": { "lastModified": 1667395993, "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", @@ -141,7 +421,25 @@ "type": "github" } }, - "flake-utils_2": { + "flake-utils_4": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_5": { "locked": { "lastModified": 1667395993, "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", @@ -151,11 +449,12 @@ "type": "github" }, "original": { - "id": "flake-utils", - "type": "indirect" + "owner": "numtide", + "repo": "flake-utils", + "type": "github" } }, - "flake-utils_3": { + "flake-utils_6": { "locked": { "lastModified": 1667395993, "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", @@ -170,7 +469,25 @@ "type": "github" } }, - "flake-utils_4": { + "flake-utils_7": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_8": { "locked": { "lastModified": 1634851050, "narHash": "sha256-N83GlSGPJJdcqhUxSCS/WwW5pksYf3VP1M13cDRTSVA=", @@ -186,6 +503,51 @@ } }, "gitignore": { + "inputs": { + "nixpkgs": [ + "bomper", + "bomper", + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "gitignore_2": { + "inputs": { + "nixpkgs": [ + "bomper", + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "gitignore_3": { "inputs": { "nixpkgs": [ "pre-commit-hooks", @@ -207,6 +569,36 @@ } }, "nix-filter": { + "locked": { + "lastModified": 1678109515, + "narHash": "sha256-C2X+qC80K2C1TOYZT8nabgo05Dw2HST/pSn6s+n6BO8=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "aa9ff6ce4a7f19af6415fb3721eaa513ea6c763c", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nix-filter", + "type": "github" + } + }, + "nix-filter_2": { + "locked": { + "lastModified": 1678109515, + "narHash": "sha256-C2X+qC80K2C1TOYZT8nabgo05Dw2HST/pSn6s+n6BO8=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "aa9ff6ce4a7f19af6415fb3721eaa513ea6c763c", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nix-filter", + "type": "github" + } + }, + "nix-filter_3": { "locked": { "lastModified": 1666547822, "narHash": "sha256-razwnAybPHyoAyhkKCwXdxihIqJi1G6e1XP4FQOJTEs=", @@ -223,27 +615,64 @@ }, "nixpkgs": { "locked": { - "lastModified": 1669542132, - "narHash": "sha256-DRlg++NJAwPh8io3ExBJdNW7Djs3plVI5jgYQ+iXAZQ=", + "lastModified": 1681303793, + "narHash": "sha256-JEdQHsYuCfRL2PICHlOiH/2ue3DwoxUX7DJ6zZxZXFk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a115bb9bd56831941be3776c8a94005867f316a7", + "rev": "fe2ecaf706a5907b5e54d979fbde4924d84b65fc", "type": "github" }, "original": { - "id": "nixpkgs", + "owner": "NixOS", "ref": "nixos-unstable", - "type": "indirect" + "repo": "nixpkgs", + "type": "github" } }, "nixpkgs-lib": { "locked": { "dir": "lib", - "lastModified": 1665349835, - "narHash": "sha256-UK4urM3iN80UXQ7EaOappDzcisYIuEURFRoGQ/yPkug=", + "lastModified": 1678375444, + "narHash": "sha256-XIgHfGvjFvZQ8hrkfocanCDxMefc/77rXeHvYdzBMc8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "130fa0baaa2b93ec45523fdcde942f6844ee9f6e", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib_2": { + "locked": { + "dir": "lib", + "lastModified": 1678375444, + "narHash": "sha256-XIgHfGvjFvZQ8hrkfocanCDxMefc/77rXeHvYdzBMc8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "130fa0baaa2b93ec45523fdcde942f6844ee9f6e", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib_3": { + "locked": { + "dir": "lib", + "lastModified": 1696019113, + "narHash": "sha256-X3+DKYWJm93DRSdC5M6K5hLqzSya9BjibtBsuARoPco=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "34c5293a71ffdb2fe054eb5288adc1882c1eb0b1", + "rev": "f5892ddac112a1e9b3612c39af1b72987ee5783a", "type": "github" }, "original": { @@ -256,11 +685,27 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1673800717, - "narHash": "sha256-SFHraUqLSu5cC6IxTprex/nTsI81ZQAtDvlBvGDWfnA=", + "lastModified": 1678872516, + "narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable_2": { + "locked": { + "lastModified": 1678872516, + "narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2f9fd351ec37f5d479556cd48be4ca340da59b8f", + "rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8", "type": "github" }, "original": { @@ -270,7 +715,54 @@ "type": "github" } }, + "nixpkgs-stable_3": { + "locked": { + "lastModified": 1685801374, + "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c37ca420157f4abc31e26f436c1145f8951ff373", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs_2": { + "locked": { + "lastModified": 1681303793, + "narHash": "sha256-JEdQHsYuCfRL2PICHlOiH/2ue3DwoxUX7DJ6zZxZXFk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fe2ecaf706a5907b5e54d979fbde4924d84b65fc", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1696193975, + "narHash": "sha256-mnQjUcYgp9Guu3RNVAB2Srr1TqKcPpRXmJf4LJk6KRY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fdd898f8f79e8d2f99ed2ab6b3751811ef683242", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "nixpkgs_4": { "locked": { "lastModified": 1636823747, "narHash": "sha256-oWo1nElRAOZqEf90Yek2ixdHyjD+gqtS/pAgwaQ9UhQ=", @@ -290,17 +782,61 @@ "flake-compat": "flake-compat_2", "flake-utils": "flake-utils_3", "gitignore": "gitignore", + "nixpkgs": "nixpkgs", + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1682596858, + "narHash": "sha256-Hf9XVpqaGqe/4oDGr30W8HlsWvJXtMsEPHDqHZA6dDg=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "fb58866e20af98779017134319b5663b8215d912", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "pre-commit-hooks_2": { + "inputs": { + "flake-compat": "flake-compat_4", + "flake-utils": "flake-utils_5", + "gitignore": "gitignore_2", + "nixpkgs": "nixpkgs_2", + "nixpkgs-stable": "nixpkgs-stable_2" + }, + "locked": { + "lastModified": 1682596858, + "narHash": "sha256-Hf9XVpqaGqe/4oDGr30W8HlsWvJXtMsEPHDqHZA6dDg=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "fb58866e20af98779017134319b5663b8215d912", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "pre-commit-hooks_3": { + "inputs": { + "flake-compat": "flake-compat_6", + "flake-utils": "flake-utils_7", + "gitignore": "gitignore_3", "nixpkgs": [ "nixpkgs" ], - "nixpkgs-stable": "nixpkgs-stable" + "nixpkgs-stable": "nixpkgs-stable_3" }, "locked": { - "lastModified": 1674761200, - "narHash": "sha256-v0ypL0eDhFWmgd3f5nnbffaMA5BUoOnYUiEso7fk+q0=", + "lastModified": 1696516544, + "narHash": "sha256-8rKE8Je6twTNFRTGF63P9mE3lZIq917RAicdc4XJO80=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "8539119ba0b17b15e60de60da0348d8c73bbfdf2", + "rev": "66c352d33e0907239e4a69416334f64af2c685cc", "type": "github" }, "original": { @@ -311,24 +847,58 @@ }, "root": { "inputs": { - "crane": "crane", - "fenix": "fenix", - "flake-parts": "flake-parts", - "flake-utils": "flake-utils_2", - "nix-filter": "nix-filter", - "nixpkgs": "nixpkgs", - "pre-commit-hooks": "pre-commit-hooks", + "bomper": "bomper", + "crane": "crane_3", + "fenix": "fenix_3", + "flake-parts": "flake-parts_3", + "nix-filter": "nix-filter_3", + "nixpkgs": "nixpkgs_3", + "pre-commit-hooks": "pre-commit-hooks_3", "terranix": "terranix" } }, "rust-analyzer-src": { "flake": false, "locked": { - "lastModified": 1674850341, - "narHash": "sha256-W8abw+8SuxSMMBH4ydfawdC6zwPHQwhHerFEXkB4oU4=", + "lastModified": 1684785219, + "narHash": "sha256-1A1waHOB8Pf2BLPtVltsWMP4bhcvTCVUAKpfL9BmCeM=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "2120c913c28896ed8e6247906f8884939c268683", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "rust-analyzer-src_2": { + "flake": false, + "locked": { + "lastModified": 1684785219, + "narHash": "sha256-1A1waHOB8Pf2BLPtVltsWMP4bhcvTCVUAKpfL9BmCeM=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "2120c913c28896ed8e6247906f8884939c268683", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "rust-analyzer-src_3": { + "flake": false, + "locked": { + "lastModified": 1696440704, + "narHash": "sha256-2kzGh0PO9uh9KOftXNxdqDbROdtAYV6fvRONvsqfr+0=", "owner": "rust-lang", "repo": "rust-analyzer", - "rev": "f1b257f4eb4fef74b42fd7135d1cf3884e8b51c9", + "rev": "b57658d9a9fbc3ca34c1eb13ef41ef0e5e4b49d0", "type": "github" }, "original": { @@ -339,6 +909,62 @@ } }, "rust-overlay": { + "inputs": { + "flake-utils": [ + "bomper", + "bomper", + "crane", + "flake-utils" + ], + "nixpkgs": [ + "bomper", + "bomper", + "crane", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1683080331, + "narHash": "sha256-nGDvJ1DAxZIwdn6ww8IFwzoHb2rqBP4wv/65Wt5vflk=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "d59c3fa0cba8336e115b376c2d9e91053aa59e56", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-overlay_2": { + "inputs": { + "flake-utils": [ + "bomper", + "crane", + "flake-utils" + ], + "nixpkgs": [ + "bomper", + "crane", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1683080331, + "narHash": "sha256-nGDvJ1DAxZIwdn6ww8IFwzoHb2rqBP4wv/65Wt5vflk=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "d59c3fa0cba8336e115b376c2d9e91053aa59e56", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-overlay_3": { "inputs": { "flake-utils": [ "crane", @@ -363,12 +989,57 @@ "type": "github" } }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "terranix": { "inputs": { "bats-assert": "bats-assert", "bats-support": "bats-support", - "flake-utils": "flake-utils_4", - "nixpkgs": "nixpkgs_2", + "flake-utils": "flake-utils_8", + "nixpkgs": "nixpkgs_4", "terranix-examples": "terranix-examples" }, "locked": { diff --git a/flake.nix b/flake.nix index 56019fc..4737ded 100644 --- a/flake.nix +++ b/flake.nix @@ -17,19 +17,32 @@ url = "github:cachix/pre-commit-hooks.nix"; inputs.nixpkgs.follows = "nixpkgs"; }; + + bomper = { + url = "github:justinrubek/bomper"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { + outputs = inputs @ { self, - flake-utils, flake-parts, ... }: - flake-parts.lib.mkFlake {inherit self;} { + flake-parts.lib.mkFlake {inherit inputs;} { systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"]; imports = [ ./lib.nix + + ./flake-parts/rust-toolchain.nix ./flake-parts/cargo.nix + + ./flake-parts/shells.nix + ./flake-parts/ci.nix + + ./flake-parts/pre-commit.nix + ./flake-parts/formatting.nix + inputs.pre-commit-hooks.flakeModule ]; flake = { diff --git a/treefmt.toml b/treefmt.toml new file mode 100644 index 0000000..7697eb4 --- /dev/null +++ b/treefmt.toml @@ -0,0 +1,8 @@ +[formatter.rust] +command = "rustfmt" +options = ["--edition", "2021"] +includes = ["*.rs"] + +[formatter.nix] +command = "alejandra" +includes = ["*.nix"]