diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index da473d2..7fad75b 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -23,7 +23,7 @@ jobs: uses: DeterminateSystems/magic-nix-cache-action@main - name: Check - run: nix build --fallback --print-build-logs '.#check-clippy' + run: nix build --fallback --print-build-logs '.#checks.x86_64-linux.clippy' - name: Upload analysis results uses: github/codeql-action/upload-sarif@v3 @@ -45,7 +45,7 @@ jobs: uses: DeterminateSystems/magic-nix-cache-action@main - name: Check - run: nix build --fallback --print-build-logs '.#check-rustfmt' + run: nix build --fallback --print-build-logs '.#checks.x86_64-linux.rustfmt' nixfmt: runs-on: ubuntu-latest @@ -61,4 +61,4 @@ jobs: uses: DeterminateSystems/magic-nix-cache-action@main - name: Check - run: nix build --fallback --print-build-logs '.#check-nixfmt' + run: nix build --fallback --print-build-logs '.#checks.x86_64-linux.nixfmt' diff --git a/.github/workflows/update-flake-lock.yml b/.github/workflows/update-flake-lock.yml index 88b72c4..dcbe8b0 100644 --- a/.github/workflows/update-flake-lock.yml +++ b/.github/workflows/update-flake-lock.yml @@ -24,5 +24,4 @@ jobs: with: pr-title: "build(deps): update flake.lock" commit-msg: "build(deps): update flake.lock" - pr-reviewers: ryanccn pr-labels: dependencies, nix diff --git a/flake.nix b/flake.nix index c07598d..7919b63 100644 --- a/flake.nix +++ b/flake.nix @@ -38,59 +38,68 @@ mkFlakeCheck = { name, - nativeBuildInputs ? [ ], command, + extraConfig ? { }, }: - pkgs.stdenv.mkDerivation { - name = "check-${name}"; - inherit nativeBuildInputs; - inherit (self.packages.${system}.nrr) src cargoDeps; - - buildPhase = '' - ${command} - touch "$out" - ''; - - doCheck = false; - dontInstall = true; - dontFixup = true; - }; + pkgs.stdenv.mkDerivation ( + { + name = "check-${name}"; + inherit (self.packages.${system}.nrr) src; + + buildPhase = '' + ${command} + touch "$out" + ''; + + doCheck = false; + dontInstall = true; + dontFixup = true; + } + // extraConfig + ); in { nixfmt = mkFlakeCheck { name = "nixfmt"; - nativeBuildInputs = with pkgs; [ nixfmt-rfc-style ]; command = "nixfmt --check ."; + + extraConfig = { + nativeBuildInputs = with pkgs; [ nixfmt-rfc-style ]; + }; }; rustfmt = mkFlakeCheck { name = "rustfmt"; - - nativeBuildInputs = with pkgs; [ - cargo - rustfmt - ]; - command = "cargo fmt --check"; + + extraConfig = { + nativeBuildInputs = with pkgs; [ + cargo + rustfmt + ]; + }; }; clippy = mkFlakeCheck { name = "clippy"; - - nativeBuildInputs = with pkgs; [ - rustPlatform.cargoSetupHook - cargo - rustc - clippy - clippy-sarif - sarif-fmt - ]; - command = '' cargo clippy --all-features --all-targets --tests \ --offline --message-format=json \ | clippy-sarif | tee $out | sarif-fmt ''; + + extraConfig = { + inherit (self.packages.${system}.nrr) cargoDeps; + + nativeBuildInputs = with pkgs; [ + rustPlatform.cargoSetupHook + cargo + rustc + clippy + clippy-sarif + sarif-fmt + ]; + }; }; } ); @@ -119,7 +128,6 @@ inputsFrom = [ self.packages.${system}.nrr ]; - __structuredAttrs = true; env = { RUST_BACKTRACE = 1; RUST_SRC_PATH = toString pkgs.rustPlatform.rustLibSrc; @@ -132,17 +140,12 @@ system: let pkgs = nixpkgsFor.${system}; - - # re-use our overlay to call packages packages = self.overlays.default null pkgs; in { inherit (packages) nrr; default = packages.nrr; } - // (lib.attrsets.mapAttrs' ( - name: value: lib.nameValuePair "check-${name}" value - ) self.checks.${system}) ); legacyPackages = forAllSystems ( diff --git a/nix/package.nix b/nix/package.nix index abe7359..ccb4344 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -10,12 +10,15 @@ enableOptimizeSize ? false, nrxAlias ? true, }: - +let + year = builtins.substring 0 4 self.lastModifiedDate; + month = builtins.substring 4 2 self.lastModifiedDate; + day = builtins.substring 6 2 self.lastModifiedDate; +in rustPlatform.buildRustPackage rec { pname = passthru.cargoToml.package.name; - inherit (passthru.cargoToml.package) version; + version = passthru.cargoToml.package.version + "-unstable-${year}-${month}-${day}"; - __structuredAttrs = true; strictDeps = true; src = nix-filter.lib.filter {