dev flake: check example and tests

It makes sense to consolidate all of this to in one place, the "dev flake".
This commit is contained in:
Sridhar Ratnakumar 2023-07-10 12:54:38 -04:00 committed by Sridhar Ratnakumar
parent 4e181b2a0c
commit 05345eaab7
6 changed files with 41 additions and 155 deletions

5
.envrc
View File

@ -1 +1,4 @@
use flake ./dev
use flake ./dev \
--override-input services-flake . \
--override-input example ./example \
--override-input example/services-flake .

View File

@ -10,7 +10,8 @@ NixOS-like services for Nix flakes, as a [process-compose-flake](https://github.
TODO
(But see `./test/flake.nix`)
- Use direnv to enter the devShell
- Add tests to `./dev/flake.nix`
## Services available

View File

@ -1,9 +1,18 @@
# Development flake
#
# We setup a dev environment as well as run tests (flake checks) here, such that
# the top-level flake is simple enough for users.
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-root.url = "github:srid/flake-root";
mission-control.url = "github:Platonic-Systems/mission-control";
process-compose-flake.url = "github:Platonic-Systems/process-compose-flake";
services-flake.url = "path:..";
example.url = "path:../example";
};
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
@ -11,8 +20,28 @@
imports = [
inputs.flake-root.flakeModule
inputs.mission-control.flakeModule
inputs.process-compose-flake.flakeModule
];
perSystem = { pkgs, lib, config, ... }: {
perSystem = { inputs', pkgs, lib, config, ... }: {
# Test /example
checks = inputs'.example.checks;
# Test the individual services
process-compose = {
postgres = {
imports = [
inputs.services-flake.processComposeModules.default
../nix/postgres_test.nix
];
};
redis = {
imports = [
inputs.services-flake.processComposeModules.default
../nix/redis_test.nix
];
};
};
mission-control.scripts = {
ex = {
description = "Run example";

13
test.sh
View File

@ -2,11 +2,8 @@ set -euxo pipefail
cd "$(dirname "$0")"
# On NixOS, run the VM tests to test runtime behaviour
if command -v nixos-rebuild &> /dev/null; then
# example test
nix flake check -L ./example --override-input services-flake .
# service tests
nix flake check -L ./test --override-input services-flake .
fi
# TODO: use github:srid/nixci
nix flake check -L ./dev \
--override-input services-flake . \
--override-input example ./example \
--override-input example/services-flake .

View File

@ -1,112 +0,0 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1685662779,
"narHash": "sha256-cKDDciXGpMEjP1n6HlzKinN0H+oLmNpgeCTzYnsA2po=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "71fb97f0d875fd4de4994dfb849f2c75e17eb6c3",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1686089707,
"narHash": "sha256-LTNlJcru2qJ0XhlhG9Acp5KyjB774Pza3tRH0pKIb3o=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "af21c31b2a1ec5d361ed8050edd0303c31306397",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1685564631,
"narHash": "sha256-8ywr3AkblY4++3lIVxmrWZFzac7+f32ZEhH/A8pNscI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "4f53efe34b3a8877ac923b9350c874e3dcd5dc0a",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"process-compose-flake": {
"locked": {
"lastModified": 1687298948,
"narHash": "sha256-7Lu4/odCkkwrzR8Mo+3D+URv4oLap8WWLESzi/75eb0=",
"owner": "Platonic-Systems",
"repo": "process-compose-flake",
"rev": "5bdb90b85642901cf9a5dccfe8c907091c261604",
"type": "github"
},
"original": {
"owner": "Platonic-Systems",
"repo": "process-compose-flake",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs",
"process-compose-flake": "process-compose-flake",
"services-flake": "services-flake",
"systems": "systems"
}
},
"services-flake": {
"locked": {
"lastModified": 1687211778,
"narHash": "sha256-eBO71ucbGhNX7095CsFDm+sQ/HuTJSy03S3MevWVuZw=",
"owner": "juspay",
"repo": "services-flake",
"rev": "f171932d130c3ce5184b69144012a225b2e28868",
"type": "github"
},
"original": {
"owner": "juspay",
"repo": "services-flake",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View File

@ -1,32 +0,0 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
systems.url = "github:nix-systems/default";
process-compose-flake.url = "github:Platonic-Systems/process-compose-flake";
services-flake.url = "github:juspay/services-flake";
};
outputs = inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;
imports = [
inputs.process-compose-flake.flakeModule
];
perSystem = { self', pkgs, lib, ... }: {
process-compose = {
postgres = {
imports = [
inputs.services-flake.processComposeModules.default
../nix/postgres_test.nix
];
};
redis = {
imports = [
inputs.services-flake.processComposeModules.default
../nix/redis_test.nix
];
};
};
};
};
}