diff --git a/flake.lock b/flake.lock index 8a27428b..4cee8834 100644 --- a/flake.lock +++ b/flake.lock @@ -15,6 +15,22 @@ "type": "github" } }, + "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-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -33,6 +49,49 @@ "type": "github" } }, + "git-hooks-nix": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1765911976, + "narHash": "sha256-t3T/xm8zstHRLx+pIHxVpQTiySbKqcQbK+r+01XVKc0=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "b68b780b69702a090c8bb1b973bab13756cc7a27", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "git-hooks-nix", + "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": 1764947035, @@ -64,42 +123,11 @@ "type": "github" } }, - "nixpkgs_2": { - "locked": { - "lastModified": 1744536153, - "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_3": { - "locked": { - "lastModified": 1761236834, - "narHash": "sha256-+pthv6hrL5VLW2UqPdISGuLiUZ6SnAXdd2DdUE+fV2Q=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "d5faa84122bc0a1fd5d378492efce4e289f8eac1", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "root": { "inputs": { "crane": "crane", "flake-parts": "flake-parts", + "git-hooks-nix": "git-hooks-nix", "nixpkgs": "nixpkgs", "rust-overlay": "rust-overlay", "treefmt-nix": "treefmt-nix" @@ -107,7 +135,9 @@ }, "rust-overlay": { "inputs": { - "nixpkgs": "nixpkgs_2" + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { "lastModified": 1764988672, @@ -125,7 +155,9 @@ }, "treefmt-nix": { "inputs": { - "nixpkgs": "nixpkgs_3" + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { "lastModified": 1762938485, diff --git a/flake.nix b/flake.nix index fbc4bd12..880e21c8 100644 --- a/flake.nix +++ b/flake.nix @@ -1,12 +1,16 @@ { - description = "Build komorebi workspace"; + description = "komorebi for Mac"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; crane.url = "github:ipetkov/crane"; rust-overlay.url = "github:oxalica/rust-overlay"; + rust-overlay.inputs.nixpkgs.follows = "nixpkgs"; treefmt-nix.url = "github:numtide/treefmt-nix"; + treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; + git-hooks-nix.url = "github:cachix/git-hooks.nix"; + git-hooks-nix.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = @@ -107,13 +111,28 @@ imports = [ inputs.treefmt-nix.flakeModule + inputs.git-hooks-nix.flakeModule ]; perSystem = - { system, ... }: + { config, system, ... }: let pkgs = mkPkgs system; build = mkKomorebiPackages { inherit pkgs; }; + rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + nightlyRustfmt = pkgs.rust-bin.nightly.latest.rustfmt; + rustToolchainWithNightlyRustfmt = pkgs.symlinkJoin { + name = "rust-toolchain-with-nightly-rustfmt"; + paths = [ + nightlyRustfmt + rustToolchain + ]; + }; + nightlyToolchain = pkgs.rust-bin.nightly.latest.default; + cargo-udeps = pkgs.writeShellScriptBin "cargo-udeps" '' + export PATH="${nightlyToolchain}/bin:$PATH" + exec ${pkgs.cargo-udeps}/bin/cargo-udeps "$@" + ''; in { treefmt = { @@ -173,8 +192,38 @@ }; }; - devShells.default = import ./shell.nix { - inherit pkgs; + devShells.default = pkgs.mkShell { + name = "komorebi"; + + RUST_BACKTRACE = "full"; + + inputsFrom = [ build.fullBuild ]; + + packages = [ + rustToolchainWithNightlyRustfmt + cargo-udeps + + pkgs.cargo-deny + pkgs.cargo-nextest + pkgs.cargo-outdated + pkgs.jq + pkgs.just + pkgs.prettier + pkgs.wrangler + + pkgs.python311Packages.mkdocs-material + pkgs.python311Packages.mkdocs-macros + pkgs.python311Packages.setuptools + ]; + }; + + pre-commit = { + check.enable = true; + settings.hooks.treefmt = { + enable = true; + package = config.treefmt.build.wrapper; + pass_filenames = false; + }; }; }; diff --git a/justfile b/justfile index 1d200ab5..b4e1a2d3 100644 --- a/justfile +++ b/justfile @@ -4,7 +4,7 @@ fmt: test -z "$(rg 'eyre!' --type rust)" || (echo "eyre! macro not allowed"; false) test -z "$(rg 'dbg!' --type rust)" || (echo "dbg! macro not allowed"; false) test -z "$(rg 'println!' --type rust ./komorebi/src)" || (echo "println! macro not allowed"; false) - cargo +stable clippy + cargo clippy prettier --write README.md nix fmt @@ -15,16 +15,16 @@ clean: cargo clean install-with-jsonschema target: - cargo +stable install --path {{ target }} --locked --target-dir ~/.cargo/bin + cargo install --path {{ target }} --locked --target-dir ~/.cargo/bin install target: - cargo +stable install --path {{ target }} --locked --target-dir ~/.cargo/bin --no-default-features + cargo install --path {{ target }} --locked --target-dir ~/.cargo/bin --no-default-features build target: - cargo +stable build --package {{ target }} --locked --release + cargo build --package {{ target }} --locked --release run target: - cargo +stable run --bin {{ target }} --locked + cargo run --bin {{ target }} --locked error target $RUST_LOG="komorebi=error": just run {{ target }} @@ -42,7 +42,7 @@ trace target $RUST_LOG="komorebi=trace": just run {{ target }} deadlock $RUST_LOG="trace": - cargo +stable run --bin komorebi --locked --no-default-features --features deadlock_detection + cargo run --bin komorebi --locked --no-default-features --features deadlock_detection docgen: cargo run --package komorebic -- docgen @@ -65,6 +65,14 @@ schemagen: schemapub: wrangler pages deploy --project-name komorebi-for-mac --branch main ./komorebi-schema +depcheck: + cargo outdated --depth 2 + cargo udeps --quiet + +deps: + cargo update + just depgen + depgen: cargo deny check cargo deny list --format json | jq 'del(.unlicensed)' > dependencies.json diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 94032484..00000000 --- a/shell.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ - pkgs ? import (fetchTarball "https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz") { }, -}: -with pkgs; -mkShell { - name = "komorebi"; - - RUST_BACKTRACE = "full"; - - buildInputs = [ - cargo-deny - cargo-nextest - cargo-udeps - jq - just - prettier - wrangler - - python311Packages.mkdocs-material - python311Packages.mkdocs-macros - python311Packages.setuptools - python311Packages.json-schema-for-humans - ]; -}