diff --git a/.github/workflows/macos.yaml b/.github/workflows/nix.yaml similarity index 53% rename from .github/workflows/macos.yaml rename to .github/workflows/nix.yaml index dcb15634..8d8cd7e7 100644 --- a/.github/workflows/macos.yaml +++ b/.github/workflows/nix.yaml @@ -1,6 +1,6 @@ # Adapted from https://github.com/rust-lang/rustup/blob/master/.github/workflows/windows-builds-on-master.yaml -name: macOS +name: nix on: pull_request: @@ -13,8 +13,8 @@ on: - hotfix/* tags: - v* -# schedule: -# - cron: "30 0 * * 0" # Every day at 00:30 UTC + # schedule: + # - cron: "30 0 * * 0" # Every day at 00:30 UTC workflow_dispatch: jobs: @@ -24,23 +24,16 @@ jobs: runs-on: self-hosted permissions: write-all env: - RUSTFLAGS: -Ctarget-feature=+crt-static -Dwarnings GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v5 with: fetch-depth: 0 - - run: rustup toolchain install stable --profile minimal - - run: rustup component add --toolchain stable clippy - - run: rustup toolchain install nightly --allow-downgrade -c rustfmt - - run: cargo +nightly fmt --check - - run: cargo deny check - - run: cargo clippy - - run: cargo test - - run: cargo build --locked --release + - run: nix flake check + - run: nix build - uses: actions/upload-artifact@v4 with: name: komorebi-aarch64-apple-darwin-${{ github.sha }} path: | - target/release/komorebi* - retention-days: 90 \ No newline at end of file + result/bin/komorebi* + retention-days: 90 diff --git a/Cargo.toml b/Cargo.toml index 1750d1a5..8202d407 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,10 @@ [workspace] resolver = "2" -members = [ - "komorebi", "komorebi-client", - "komorebic", "komorebi-bar" -] +members = ["komorebi", "komorebi-bar", "komorebi-client", "komorebic"] +[workspace.package] +version = "0.1.0" [workspace.dependencies] komorebi-themes = { git = "https://github.com/LGUG2Z/komorebi", rev = "1c23439f959bcfddf0f71918fc03a97dd4f30727" } @@ -34,3 +33,6 @@ tracing = "0.1" tracing-appender = "0.2" tracing-subscriber = { version = "0.3", features = ["env-filter"] } which = "8" + +[workspace.metadata.crane] +name = "komorebi-workspace" diff --git a/deny.toml b/deny.toml index d97cd110..7a56b2a8 100644 --- a/deny.toml +++ b/deny.toml @@ -1,7 +1,5 @@ [graph] -targets = [ - "aarch64-apple-darwin", -] +targets = ["aarch64-apple-darwin"] all-features = false no-default-features = false @@ -10,32 +8,32 @@ feature-depth = 1 [advisories] ignore = [ - { id = "RUSTSEC-2024-0436", reason = "paste is fine" }, - { id = "RUSTSEC-2024-0320", reason = "not using any yaml features from this library" }, - { id = "RUSTSEC-2025-0056", reason = "only used for colour palette generation" }, + { id = "RUSTSEC-2024-0436", reason = "paste is fine" }, + { id = "RUSTSEC-2024-0320", reason = "not using any yaml features from this library" }, + { id = "RUSTSEC-2025-0056", reason = "only used for colour palette generation" }, ] [licenses] allow = [ - "0BSD", - "Apache-2.0", - "Artistic-2.0", - "BSD-2-Clause", - "BSD-3-Clause", - "CC0-1.0", - "ISC", - "MIT", - "MPL-2.0", - "OFL-1.1", - "Ubuntu-font-1.0", - "Unicode-3.0", - "Zlib", + "0BSD", + "Apache-2.0", + "Artistic-2.0", + "BSD-2-Clause", + "BSD-3-Clause", + "CC0-1.0", + "ISC", + "MIT", + "MPL-2.0", + "OFL-1.1", + "Ubuntu-font-1.0", + "Unicode-3.0", + "Zlib", - "LicenseRef-Komorebi-2.0", - # these are also ok, but not yet used + "LicenseRef-Komorebi-2.0", + # these are also ok, but not yet used - # "BSL-1.0", - # "MIT-0", + # "BSL-1.0", + # "MIT-0", ] confidence-threshold = 0.8 @@ -81,10 +79,10 @@ unknown-registry = "deny" unknown-git = "deny" allow-registry = ["https://github.com/rust-lang/crates.io-index"] allow-git = [ - "https://github.com/LGUG2Z/quickxml_to_serde", - "https://github.com/LGUG2Z/base16-egui-themes", - "https://github.com/LGUG2Z/flavours", - "https://github.com/LGUG2Z/komorebi", - "https://github.com/LGUG2Z/base16_color_scheme", + "https://github.com/LGUG2Z/quickxml_to_serde", + "https://github.com/LGUG2Z/base16-egui-themes", + "https://github.com/LGUG2Z/flavours", + "https://github.com/LGUG2Z/komorebi", + "https://github.com/LGUG2Z/base16_color_scheme", -] \ No newline at end of file +] diff --git a/flake.lock b/flake.lock index c16827ee..bf4252ff 100644 --- a/flake.lock +++ b/flake.lock @@ -35,16 +35,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1760524057, - "narHash": "sha256-EVAqOteLBFmd7pKkb0+FIUyzTF61VKi7YmvP1tw4nEw=", - "owner": "nixos", + "lastModified": 1760934318, + "narHash": "sha256-/oUYsC0lUCBory65VK+UHqCCsCspbL1Vgfcf1KUYqVw=", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "544961dfcce86422ba200ed9a0b00dd4b1486ec5", + "rev": "87848bf0cc4f87717fc813a4575f07330c3e743c", "type": "github" }, "original": { - "owner": "nixos", - "ref": "nixos-unstable", + "owner": "NixOS", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index 2f98ee00..ef4f7694 100644 --- a/flake.nix +++ b/flake.nix @@ -1,109 +1,199 @@ { + description = "Build komorebi workspace"; + inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + crane.url = "github:ipetkov/crane"; flake-utils.url = "github:numtide/flake-utils"; rust-overlay.url = "github:oxalica/rust-overlay"; - crane.url = "github:ipetkov/crane"; }; - outputs = inputs: - with inputs; let - komorebiBuild = system: let - overlays = [ - (import rust-overlay) + outputs = { + nixpkgs, + crane, + flake-utils, + rust-overlay, + ... + }: let + komorebiBuild = system: let + overlays = [(import rust-overlay)]; + pkgs = import nixpkgs { + inherit system overlays; + }; + + inherit (pkgs) lib; + + toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + craneLib = (crane.mkLib pkgs).overrideToolchain toolchain; + version = "0.1.0"; + + src = lib.cleanSourceWith { + src = ./.; + filter = path: type: + (craneLib.filterCargoSources path type) + || (lib.hasInfix "/docs/" path) + || (builtins.match ".*/docs/.*" path != null); + }; + + cargoArtifacts = craneLib.buildDepsOnly commonArgs; + + commonArgs = { + inherit src version cargoArtifacts; + strictDeps = true; + + buildInputs = [ + pkgs.gcc + pkgs.libiconv ]; + }; - pkgs = (import nixpkgs) { - inherit system overlays; - }; - - inherit (pkgs) lib; - - toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; - craneLib = (crane.mkLib pkgs).overrideToolchain toolchain; - - src = lib.cleanSourceWith { - src = ./.; - filter = path: type: - (craneLib.filterCargoSources path type) - || (lib.hasInfix "/docs/" path) - || (builtins.match ".*/docs/.*" path != null); - }; - - version = "0.1.0"; - pname = "komorebi"; - - commonArgs = { - inherit src version pname; - nativeBuildInputs = with pkgs; []; + individualCrateArgs = + commonArgs + // { doCheck = false; - buildInputs = with pkgs; [ - gcc - libiconv - ]; }; - cargoArtifacts = craneLib.buildDepsOnly commonArgs; - in { + packages = { komorebi = craneLib.buildPackage ( - commonArgs + individualCrateArgs // { + inherit version; + pname = "komorebi"; cargoExtraArgs = "-p komorebi"; } ); komorebic = craneLib.buildPackage ( - commonArgs + individualCrateArgs // { + inherit version; + pname = "komorebic"; cargoExtraArgs = "-p komorebic"; } ); komorebi-bar = craneLib.buildPackage ( - commonArgs + individualCrateArgs // { + inherit version; + pname = "komorebi-bar"; cargoExtraArgs = "-p komorebi-bar"; } ); komorebi-full = craneLib.buildPackage ( - commonArgs + individualCrateArgs // { + inherit version; + pname = "komorebi-full"; cargoExtraArgs = "-p komorebi -p komorebic -p komorebi-bar"; } ); }; in - (flake-utils.lib.eachDefaultSystem ( - system: let - packages = komorebiBuild system; - in { - devShells = flake-utils.lib.flattenTree { - default = import ./shell.nix { - pkgs = (import nixpkgs) { - inherit system; - overlays = [(import rust-overlay)]; - }; - }; - }; - - packages = flake-utils.lib.flattenTree { - inherit (packages) komorebi komorebic komorebi-bar komorebi-full; - default = packages.komorebi-full; - }; - } - )) + packages // { - overlays.default = final: prev: let - packages = komorebiBuild final.system; - in { - inherit (packages) komorebi komorebic komorebi-bar komorebi-full; + inherit + pkgs + craneLib + commonArgs + cargoArtifacts + individualCrateArgs + src + ; + }; + in + flake-utils.lib.eachSystem ["aarch64-darwin"] ( + system: let + buildResult = komorebiBuild system; + inherit + (buildResult) + komorebi + komorebic + komorebi-bar + komorebi-full + pkgs + craneLib + commonArgs + src + ; + in { + checks = { + komorebi-workspace-clippy = craneLib.cargoClippy ( + commonArgs + // { + cargoClippyExtraArgs = "--all-targets -- --deny warnings"; + } + ); + + komorebi-workspace-fmt = craneLib.cargoFmt { + inherit src; + }; + + komorebi-workspace-toml-fmt = craneLib.taploFmt { + src = pkgs.lib.sources.sourceFilesBySuffices src [".toml"]; + }; + + komorebi-workspace-deny = craneLib.cargoDeny { + inherit src; + }; + + komorebi-workspace-nextest = craneLib.cargoNextest commonArgs; }; - overlays.komorebi = final: prev: let - packages = komorebiBuild final.system; - in { - inherit (packages) komorebi komorebic komorebi-bar komorebi-full; + packages = { + inherit + komorebi + komorebic + komorebi-bar + komorebi-full + ; + default = komorebi-full; }; + + apps = { + komorebi = flake-utils.lib.mkApp { + drv = komorebi; + }; + komorebic = flake-utils.lib.mkApp { + drv = komorebic; + }; + komorebi-bar = flake-utils.lib.mkApp { + drv = komorebi-bar; + }; + default = flake-utils.lib.mkApp { + drv = komorebi-full; + }; + }; + + devShells.default = import ./shell.nix { + inherit pkgs; + }; + } + ) + // { + overlays.default = final: _: let + buildResult = komorebiBuild final.system; + in { + inherit + (buildResult) + komorebi + komorebic + komorebi-bar + komorebi-full + ; }; + + overlays.komorebi = final: _: let + buildResult = komorebiBuild final.system; + in { + inherit + (buildResult) + komorebi + komorebic + komorebi-bar + komorebi-full + ; + }; + }; } diff --git a/komorebi-bar/Cargo.toml b/komorebi-bar/Cargo.toml index 7f572478..091672c0 100644 --- a/komorebi-bar/Cargo.toml +++ b/komorebi-bar/Cargo.toml @@ -42,4 +42,8 @@ tracing-subscriber = { workspace = true } [features] default = ["schemars"] -schemars = ["dep:schemars", "komorebi-client/default", "komorebi-themes/default"] +schemars = [ + "dep:schemars", + "komorebi-client/default", + "komorebi-themes/default", +] diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index 1b3843a8..5136281f 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -22,7 +22,10 @@ nanoid = "0.4" objc2 = "0.6" objc2-app-kit = "0.3" objc2-application-services = "0.3" -objc2-core-foundation = { version = "0.3", features = ["CFDictionary", "CFString"] } +objc2-core-foundation = { version = "0.3", features = [ + "CFDictionary", + "CFString", +] } objc2-core-graphics = { version = "0.3", features = ["CGWindow", "alloc"] } objc2-core-services = "0.3" objc2-core-video = "0.3" diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 31578d3b..292fe499 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "stable" \ No newline at end of file +channel = "stable" diff --git a/rustfmt.toml b/rustfmt.toml index 74c8af67..63df91e0 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1 +1 @@ -imports_granularity = "Item" \ No newline at end of file +imports_granularity = "Item"