diff options
| -rw-r--r-- | flake.lock | 128 | ||||
| -rw-r--r-- | flake.nix | 44 | ||||
| -rw-r--r-- | parts/deployment.nix | 2 | ||||
| -rw-r--r-- | parts/dev.nix | 30 |
4 files changed, 105 insertions, 99 deletions
@@ -16,13 +16,29 @@ "type": "github" } }, + "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" + } + }, "crane": { "inputs": { "flake-compat": [ - "flake-compat" + "compat" ], "flake-utils": [ - "flake-utils" + "utils" ], "nixpkgs": [ "nixpkgs" @@ -64,64 +80,10 @@ "type": "github" } }, - "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-parts": { - "inputs": { - "nixpkgs-lib": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1693611461, - "narHash": "sha256-aPODl8vAgGQ0ZYFIRisxYG5MOGSkIczvu2Cd8Gb9+1Y=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "7f53fdb7bdc5bb237da7fefef12d099e4fd611ca", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1692799911, - "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "gitignore": { "inputs": { "nixpkgs": [ - "pre-commit-hooks", + "pre-commit", "nixpkgs" ] }, @@ -155,13 +117,33 @@ "type": "github" } }, - "pre-commit-hooks": { + "parts": { + "inputs": { + "nixpkgs-lib": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1693611461, + "narHash": "sha256-aPODl8vAgGQ0ZYFIRisxYG5MOGSkIczvu2Cd8Gb9+1Y=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "7f53fdb7bdc5bb237da7fefef12d099e4fd611ca", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "pre-commit": { "inputs": { "flake-compat": [ - "flake-compat" + "compat" ], "flake-utils": [ - "flake-utils" + "utils" ], "gitignore": "gitignore", "nixpkgs": [ @@ -188,13 +170,13 @@ "root": { "inputs": { "advisory-db": "advisory-db", + "compat": "compat", "crane": "crane", "fenix": "fenix", - "flake-compat": "flake-compat", - "flake-parts": "flake-parts", - "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", - "pre-commit-hooks": "pre-commit-hooks" + "parts": "parts", + "pre-commit": "pre-commit", + "utils": "utils" } }, "rust-analyzer-src": { @@ -253,6 +235,24 @@ "repo": "default", "type": "github" } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1692799911, + "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } } }, "root": "root", @@ -13,19 +13,11 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - flake-compat = { - url = "github:edolstra/flake-compat"; - flake = false; - }; - - flake-parts = { + parts = { url = "github:hercules-ci/flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; }; - # this is just to avoid having multiple versions in flake.lock - flake-utils.url = "github:numtide/flake-utils"; - # used for cargo audit advisory-db = { url = "github:rustsec/advisory-db"; @@ -36,8 +28,8 @@ crane = { url = "github:ipetkov/crane"; inputs.nixpkgs.follows = "nixpkgs"; - inputs.flake-compat.follows = "flake-compat"; - inputs.flake-utils.follows = "flake-utils"; + inputs.flake-compat.follows = "compat"; + inputs.flake-utils.follows = "utils"; }; # toolchain management @@ -46,17 +38,33 @@ inputs.nixpkgs.follows = "nixpkgs"; }; - pre-commit-hooks = { + pre-commit = { url = "github:cachix/pre-commit-hooks.nix"; inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs-stable.follows = "nixpkgs"; - inputs.flake-compat.follows = "flake-compat"; - inputs.flake-utils.follows = "flake-utils"; + inputs.flake-compat.follows = "compat"; + inputs.flake-utils.follows = "utils"; }; + + # this is just to avoid having multiple versions in flake.lock + compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + + # ditto + utils.url = "github:numtide/flake-utils"; }; - outputs = inputs: - inputs.flake-parts.lib.mkFlake - {inherit inputs;} - {imports = [./parts];}; + outputs = { + parts, + pre-commit, + ... + } @ inputs: + parts.lib.mkFlake {inherit inputs;} { + imports = [ + pre-commit.flakeModule + ./parts + ]; + }; } diff --git a/parts/deployment.nix b/parts/deployment.nix index f0ab7d1..b9e43da 100644 --- a/parts/deployment.nix +++ b/parts/deployment.nix @@ -69,7 +69,7 @@ in { cfg = config.services.teawiebot; inherit (lib) mkEnableOption mkIf; in { - options.services.teawiebot.enable = mkEnableOption "enable teawiebot"; + options.services.teawiebot.enable = mkEnableOption "teawiebot"; config.systemd.services = mkIf cfg.enable { teawiebot = { diff --git a/parts/dev.nix b/parts/dev.nix index 246789a..fbd319b 100644 --- a/parts/dev.nix +++ b/parts/dev.nix @@ -4,12 +4,23 @@ ... }: { perSystem = { + config, craneLib, pkgs, system, toolchain, ... }: { + pre-commit = { + settings.hooks = { + actionlint.enable = true; + alejandra.enable = true; + deadnix.enable = true; + nil.enable = true; + statix.enable = true; + }; + }; + checks = let inherit (craneLib) cargoAudit cargoClippy cleanCargoSource cargoFmt; @@ -28,24 +39,11 @@ }); fmt = cargoFmt commonArgs; - - pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run { - src = self; - hooks = { - actionlint.enable = true; - alejandra.enable = true; - deadnix.enable = true; - nil.enable = true; - statix.enable = true; - }; - }; }; - devShells = let - inherit (pkgs) mkShell; - in { - default = mkShell { - inherit (self.checks.${system}.pre-commit-check) shellHook; + devShells = { + default = pkgs.mkShell { + shellHook = config.pre-commit.installationScript; packages = with pkgs; [ actionlint alejandra |
