aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorSergey Gulin2024-03-27 12:22:02 +0300
committerSergey Gulin2024-03-29 20:25:47 +0300
commita92835264100583903dc408abe43d461ff7d4dca (patch)
treef22e488e7d057772809a9936ad124915ff968b6f /flake.nix
parent0a0187794ac7f7a1e62cda3dabf8dc041f868790 (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.nix31
1 files changed, 24 insertions, 7 deletions
diff --git a/flake.nix b/flake.nix
index 66b2e76..fa975a9 100644
--- a/flake.nix
+++ b/flake.nix
@@ -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};
});
}