diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e4a0a4..cc9894c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,8 +17,8 @@ jobs: run: nix develop --command cargo fmt --all -- --check - name: Run clippy run: nix develop --command cargo clippy -- -D warnings - - name: Run tests - run: nix develop --command cargo test + - name: Run alejandra + run: nix develop --command alejandra --check flake.nix test: runs-on: ubuntu-latest diff --git a/.zed/settings.json b/.zed/settings.json index 396a7e1..2bf41b4 100644 --- a/.zed/settings.json +++ b/.zed/settings.json @@ -13,5 +13,18 @@ } } } + }, + "languages": { + "Nix": { + "formatter": { + "external": { + "command": "alejandra", + "arguments": [ + "-q" + ] + } + }, + "format_on_save": "on" + } } } diff --git a/flake.nix b/flake.nix index bd4b4e5..6373489 100644 --- a/flake.nix +++ b/flake.nix @@ -11,77 +11,81 @@ }; }; - outputs = { nixpkgs, flake-utils, fenix, crane, ... }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - # Using stable toolchain as base - toolchain = with fenix.packages.${system}; - combine [ - minimal.rustc - minimal.cargo - targets.x86_64-pc-windows-gnu.latest.rust-std + outputs = { + nixpkgs, + flake-utils, + fenix, + crane, + ... + }: + flake-utils.lib.eachDefaultSystem (system: let + pkgs = nixpkgs.legacyPackages.${system}; + # Using stable toolchain as base + toolchain = with fenix.packages.${system}; + combine [ + minimal.rustc + minimal.cargo + targets.x86_64-pc-windows-gnu.latest.rust-std ]; - craneLib = (crane.mkLib pkgs).overrideToolchain toolchain; + craneLib = (crane.mkLib pkgs).overrideToolchain toolchain; - # Common build inputs for both native and cross compilation - commonArgs = { + # Common build inputs for both native and cross compilation + commonArgs = { + src = craneLib.cleanCargoSource ./.; + cargoArtifacts = craneLib.buildDepsOnly { src = craneLib.cleanCargoSource ./.; - cargoArtifacts = craneLib.buildDepsOnly { - src = craneLib.cleanCargoSource ./.; - }; - doCheck = false; # skip tests during nix build }; + doCheck = false; # skip tests during nix build + }; - # Native build - timr = craneLib.buildPackage commonArgs; + # Native build + timr = craneLib.buildPackage commonArgs; - # Windows cross-compilation build - # @see https://crane.dev/examples/cross-windows.html - crossBuild = craneLib.buildPackage { - src = craneLib.cleanCargoSource ./.; + # Windows cross-compilation build + # @see https://crane.dev/examples/cross-windows.html + crossBuild = craneLib.buildPackage { + src = craneLib.cleanCargoSource ./.; - strictDeps = true; - doCheck = false; + strictDeps = true; + doCheck = false; - CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu"; + CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu"; - # fixes issues related to libring - TARGET_CC = "${pkgs.pkgsCross.mingwW64.stdenv.cc}/bin/${pkgs.pkgsCross.mingwW64.stdenv.cc.targetPrefix}cc"; + # fixes issues related to libring + TARGET_CC = "${pkgs.pkgsCross.mingwW64.stdenv.cc}/bin/${pkgs.pkgsCross.mingwW64.stdenv.cc.targetPrefix}cc"; - #fixes issues related to openssl - OPENSSL_DIR = "${pkgs.openssl.dev}"; - OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib"; - OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include/"; + #fixes issues related to openssl + OPENSSL_DIR = "${pkgs.openssl.dev}"; + OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib"; + OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include/"; - depsBuildBuild = with pkgs; [ - pkgsCross.mingwW64.stdenv.cc - pkgsCross.mingwW64.windows.pthreads + depsBuildBuild = with pkgs; [ + pkgsCross.mingwW64.stdenv.cc + pkgsCross.mingwW64.windows.pthreads + ]; + }; + in { + packages = { + inherit timr; + default = timr; + windows = crossBuild; + }; + + # Development shell with all necessary tools + devShell = with nixpkgs.legacyPackages.${system}; + mkShell { + buildInputs = with fenix.packages.${system}.stable; [ + rust-analyzer + clippy + rustfmt + toolchain + pkgs.just + pkgs.nixd + pkgs.alejandra ]; - }; - in - { - packages = { - inherit timr; - default = timr; - windows = crossBuild; - }; - - # Development shell with all necessary tools - devShell = with nixpkgs.legacyPackages.${system}; mkShell { - buildInputs = with fenix.packages.${system}.stable; [ - rust-analyzer - clippy - rustfmt - toolchain - pkgs.just - ]; - - - inherit (commonArgs) src; RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library"; }; - }); + }); }