From 641c5a34d457531d96e3138cd0fe9fd5b59ca2db Mon Sep 17 00:00:00 2001 From: a-kenji Date: Fri, 17 Jun 2022 12:16:33 +0200 Subject: [PATCH] add(ci): check for msrv (#1522) --- .github/workflows/nix.yml | 23 ++++++++++++++++++++++- nix/default.nix | 32 +++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index f2e7dd6e..882e6c70 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest name: "nix build" environment: cachix - timeout-minutes: 25 + timeout-minutes: 35 steps: - uses: actions/checkout@v3 with: @@ -27,3 +27,24 @@ jobs: authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - run: | nix build || nix build --substituters 'https://cache.nixos.org' --extra-substituters '' + build-msrv: + runs-on: ubuntu-latest + name: "build msrv" + environment: cachix + timeout-minutes: 35 + steps: + - uses: actions/checkout@v3 + with: + # Nix Flakes doesn't work on shallow clones + fetch-depth: 0 + - uses: cachix/install-nix-action@v17 + - uses: cachix/cachix-action@v10 + with: + name: zellij + # If you chose API tokens for write access OR if you have a private cache + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - run: | + nix build .#zellij-msrv || nix build .#zellij-msrv --substituters 'https://cache.nixos.org' --extra-substituters '' + - if: ${{ failure() }} + run: | + echo "::error :: If this is the only ci step failing, it is likely that the MSRV needs to be bumped. diff --git a/nix/default.nix b/nix/default.nix index a863621b..8de8fd87 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -32,6 +32,16 @@ flake-utils.lib.eachSystem [ ]; }; + crate2nixMsrvPkgs = import nixpkgs { + inherit system; + overlays = [ + (self: _: { + rustc = msrvToolchain; + cargo = msrvToolchain; + }) + ]; + }; + name = "zellij"; pname = name; root = self; @@ -40,9 +50,16 @@ flake-utils.lib.eachSystem [ src = pkgs.nix-gitignore.gitignoreSource ignoreSource root; - cargoToml = builtins.fromTOML (builtins.readFile (src + ./Cargo.toml)); + cargoToml = builtins.fromTOML (builtins.readFile (src + "/Cargo.toml")); + toolchainToml = builtins.fromTOML (builtins.readFile (src + "/rust-toolchain.toml")); rustToolchainToml = pkgs.rust-bin.fromRustupToolchainFile (src + "/rust-toolchain.toml"); + msrvToolchain = pkgs.rust-bin.fromRustupToolchain { + channel = cargoToml.package.rust-version; + components = toolchainToml.toolchain.components; + targets = toolchainToml.toolchain.targets; + }; + cargoLock = { lockFile = builtins.path { path = src + "/Cargo.lock"; @@ -160,6 +177,19 @@ in rec { nativeBuildInputs = nativeBuildInputs ++ defaultPlugins; }; + packages.zellij-msrv = crate2nixMsrvPkgs.callPackage ./crate2nix.nix { + inherit + name + src + crate2nix + desktopItems + postInstall + patchPhase + meta + ; + nativeBuildInputs = nativeBuildInputs ++ defaultPlugins; + }; + # native nixpkgs support - keep supported packages.zellij-native = (pkgs.makeRustPlatform {inherit cargo rustc;}).buildRustPackage { inherit