diff --git a/.gitignore b/.gitignore index 3f4b997..089308c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ .direnv/ .idea/ /target -.rust-toolchain -.pre-commit-config.yaml diff --git a/flake.lock b/flake.lock index 73bfdd0..36ef2ff 100644 --- a/flake.lock +++ b/flake.lock @@ -1,31 +1,15 @@ { "nodes": { - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, "flake-utils": { "inputs": { "systems": "systems" }, "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", "type": "github" }, "original": { @@ -34,34 +18,13 @@ "type": "github" } }, - "gitignore": { - "inputs": { - "nixpkgs": [ - "pre-commit-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" - } - }, "nixpkgs": { "locked": { - "lastModified": 1753694789, - "narHash": "sha256-cKgvtz6fKuK1Xr5LQW/zOUiAC0oSQoA9nOISB0pJZqM=", + "lastModified": 1729413321, + "narHash": "sha256-I4tuhRpZFa6Fu6dcH9Dlo5LlH17peT79vx1y1SpeKt0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "dc9637876d0dcc8c9e5e22986b857632effeb727", + "rev": "1997e4aa514312c1af7e2bda7fad1644e778ff26", "type": "github" }, "original": { @@ -71,33 +34,10 @@ "type": "github" } }, - "pre-commit-hooks": { - "inputs": { - "flake-compat": "flake-compat", - "gitignore": "gitignore", - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1750779888, - "narHash": "sha256-wibppH3g/E2lxU43ZQHC5yA/7kIKLGxVEnsnVK1BtRg=", - "owner": "cachix", - "repo": "git-hooks.nix", - "rev": "16ec914f6fb6f599ce988427d9d94efddf25fe6d", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "git-hooks.nix", - "type": "github" - } - }, "root": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "pre-commit-hooks": "pre-commit-hooks" + "nixpkgs": "nixpkgs" } }, "systems": { diff --git a/flake.nix b/flake.nix index d3dd6f0..3d7a291 100644 --- a/flake.nix +++ b/flake.nix @@ -2,38 +2,33 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; - pre-commit-hooks = { - url = "github:cachix/git-hooks.nix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; }; outputs = - { self - , nixpkgs + { nixpkgs , flake-utils , ... - }@inputs: + }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; - # Place all toolchain components in a single directory for IntelliJ - rust-toolchain = pkgs.symlinkJoin { - name = "rust-toolchain"; - paths = with pkgs; [ - rustc - cargo - rustPlatform.rustcSrc - ] ++ lib.optionals stdenv.isDarwin [ - libiconv - ]; - }; in { - checks = import ./nix/git-hooks.nix { inherit inputs pkgs; }; - devShells = import ./nix/shell.nix { inherit pkgs rust-toolchain self; }; - formatter = pkgs.nixpkgs-fmt; + devShells.default = pkgs.mkShell { + name = "immich-tools"; + buildInputs = with pkgs; [ + cargo + cargo-machete + cargo-release + cargo-sort + openssl + pkg-config + ] ++ lib.optionals stdenv.isDarwin [ + libiconv + darwin.apple_sdk.frameworks.SystemConfiguration + ]; + }; }); } diff --git a/nix/git-hooks.nix b/nix/git-hooks.nix deleted file mode 100644 index 355da46..0000000 --- a/nix/git-hooks.nix +++ /dev/null @@ -1,65 +0,0 @@ -{ inputs, pkgs, ... }: -let - conventional-commit = pkgs.callPackage ./pkgs/conventional-pre-commit.nix { }; -in -{ - pre-commit-check = inputs.pre-commit-hooks.lib.${pkgs.system}.run { - src = ./..; - hooks = { - # TOML - check-toml.enable = true; - - # YAML - check-yaml.enable = true; - - # Nix - deadnix.enable = true; - flake-checker.enable = true; - nixpkgs-fmt.enable = true; - statix.enable = true; - - # Rust - clippy = { - enable = true; - settings = { - denyWarnings = true; - }; - extraPackages = with pkgs; [ - openssl - pkg-config - ]; - }; - rustfmt.enable = true; - cargo-check = { - enable = true; - extraPackages = with pkgs; [ - pkg-config - openssl - ]; - }; - - # Git - no-commit-to-branch = { - enable = true; - settings = { - branch = [ "main" ]; - }; - }; - conventional-commit = { - enable = true; - name = "conventional-commit"; - description = "A pre-commit hook that checks commit messages for Conventional Commits formatting"; - package = conventional-commit; - entry = "${conventional-commit}/bin/conventional-pre-commit"; - args = [ "--strict" "feat" "fix" "chore" "revert" "style" "docs" "build" "refactor" "test" "ci" "perf" ]; - stages = [ "commit-msg" ]; - }; - }; - - settings = { - rust.check.cargoDeps = pkgs.rustPlatform.importCargoLock { - lockFile = ../Cargo.lock; - }; - }; - }; -} diff --git a/nix/pkgs/conventional-pre-commit.nix b/nix/pkgs/conventional-pre-commit.nix deleted file mode 100644 index dbeb136..0000000 --- a/nix/pkgs/conventional-pre-commit.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ python3Packages, fetchPypi, ... }: - -python3Packages.buildPythonApplication rec { - pname = "conventional_pre_commit"; - version = "4.2.0"; - - src = fetchPypi { - inherit pname version; - hash = "sha256-a1ooZzOMWKHRTTAN5otWwXt8hAO7EiFV84Y5pCPSH/E="; - }; - - doCheck = false; - pyproject = true; - - build-system = with python3Packages; [ - setuptools - setuptools-scm - wheel - ]; -} diff --git a/nix/shell.nix b/nix/shell.nix deleted file mode 100644 index a620fe0..0000000 --- a/nix/shell.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ pkgs, rust-toolchain, self, ... }: - -{ - default = pkgs.mkShell { - name = "immich-tools"; - buildInputs = with pkgs; [ - cargo - cargo-edit - cargo-insta - cargo-machete - cargo-release - cargo-sort - git-cliff - openssl - pkg-config - rustc - rust-toolchain - ] ++ lib.optionals stdenv.isDarwin [ - libiconv - ] ++ self.checks.${pkgs.system}.pre-commit-check.enabledPackages; - RUST_BACKTRACE = 1; - - # Copy rust-toolchain to project directory for easy use in IntelliJ - shellHook = '' - if [ -L ./.rust-toolchain ] && [ "$(readlink ./.rust-toolchain)" = "${rust-toolchain}" ]; then - echo "Rust toolchain symlink is already correct." - else - rm -f ./.rust-toolchain - ln -s ${rust-toolchain} ./.rust-toolchain - echo "Rust toolchain symlink updated." - fi - - ${self.checks.${pkgs.system}.pre-commit-check.shellHook} - ''; - }; -}