diff options
author | Sergey Gulin | 2024-03-27 12:22:02 +0300 |
---|---|---|
committer | Sergey Gulin | 2024-03-29 20:25:47 +0300 |
commit | a92835264100583903dc408abe43d461ff7d4dca (patch) | |
tree | f22e488e7d057772809a9936ad124915ff968b6f /flake.nix | |
parent | 0a0187794ac7f7a1e62cda3dabf8dc041f868790 (diff) |
[OPS-1384] Introduce NixOS VM tests
Problem: Currently, the only way to test deploy-rs deployments is to
actually do a deployment to an existing NixOS instance (either in VM,
or a real machine) manually. This is a bit inconvenient and one can
forget to test changes when developing/reviewing deploy-rs changes.
Solution: Add NixOS VM tests.
Diffstat (limited to 'flake.nix')
-rw-r--r-- | flake.nix | 31 |
1 files changed, 24 insertions, 7 deletions
@@ -15,10 +15,9 @@ }; }; - outputs = { self, nixpkgs, utils, ... }: + outputs = { self, nixpkgs, utils, ... }@inputs: { - overlay = final: prev: - let + overlays.default = final: prev: let system = final.stdenv.hostPlatform.system; darwinOptions = final.lib.optionalAttrs final.stdenv.isDarwin { buildInputs = with final.darwin.apple_sdk.frameworks; [ @@ -34,7 +33,13 @@ pname = "deploy-rs"; version = "0.1.0"; - src = ./.; + src = final.lib.sourceByRegex ./. [ + "Cargo\.lock" + "Cargo\.toml" + "src" + "src/bin" + ".*\.rs$" + ]; cargoLock.lockFile = ./Cargo.lock; }) // { meta.description = "A Simple multi-profile Nix-flake deploy tool"; }; @@ -145,7 +150,15 @@ } // utils.lib.eachSystem (utils.lib.defaultSystems ++ ["aarch64-darwin"]) (system: let - pkgs = import nixpkgs { inherit system; overlays = [ self.overlay ]; }; + pkgs = import nixpkgs { + inherit system; + overlays = [ self.overlays.default ]; + }; + + # make a matrix to use in GitHub pipeline + mkMatrix = name: attrs: { + include = map (v: { ${name} = v; }) (pkgs.lib.attrNames attrs); + }; in { defaultPackage = self.packages."${system}".deploy-rs; @@ -176,8 +189,12 @@ checks = { deploy-rs = self.packages.${system}.default.overrideAttrs (super: { doCheck = true; }); - }; + } // (pkgs.lib.optionalAttrs (pkgs.lib.elem system ["x86_64-linux"]) (import ./nix/tests { + inherit inputs pkgs; + })); + + inherit (pkgs.deploy-rs) lib; - lib = pkgs.deploy-rs.lib; + check-matrix = mkMatrix "check" self.checks.${system}; }); } |