Skip to content

Commit

Permalink
initial stab at setting up nix for local testing with postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
ulucs committed Apr 25, 2024
1 parent d97a2b6 commit 5922d78
Show file tree
Hide file tree
Showing 3 changed files with 241 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ target
Cargo.lock
docs/book
docs/doctest_cache
.vscode
data
181 changes: 181 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
description = "A demo of sqlite-web and multiple postgres services";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
systems.url = "github:nix-systems/default";
process-compose-flake.url = "github:Platonic-Systems/process-compose-flake";
services-flake.url = "github:juspay/services-flake";
flake-parts.url = "github:hercules-ci/flake-parts";
rust-overlay.url = "github:oxalica/rust-overlay";
};

outputs = inputs @ { rust-overlay, nixpkgs, ...} :
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;

imports = [
inputs.process-compose-flake.flakeModule
];

perSystem = { self', system, ... }: let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
dbName = "atmosphere";
in {
process-compose."default" = { config, ... }: {
imports = [
inputs.services-flake.processComposeModules.default
];

services.postgres."pg1" = {
enable = true;
initialDatabases = [
{ name = dbName; }
];
};

settings.processes.test = let
pgconf = config.services.postgres.pg1;
in {
environment.DATABASE_URL = pgconf.connectionURI { inherit dbName; };

command = pkgs.writeShellApplication {
name = "cargo.test.postgres";
runtimeInputs = with pkgs; [
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.SystemConfiguration
rust-bin.stable.latest.default
];
text = "cargo test -F postgres";
};
};
};
};
};
}

0 comments on commit 5922d78

Please sign in to comment.