diff options
author | sadbeast <sadbeast@sadbeast.com> | 2024-07-16 18:16:29 -0700 |
---|---|---|
committer | sadbeast <sadbeast@sadbeast.com> | 2024-10-05 16:40:55 -0700 |
commit | 6bd24af2ffbea91db1b10a5d5258980ce2068c7f (patch) | |
tree | 66634833f2d45260be5fcaf9111400eda12f03cc /flake.nix | |
download | teamdraft-main.tar.gz teamdraft-main.tar.bz2 |
Diffstat (limited to 'flake.nix')
-rw-r--r-- | flake.nix | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f59fbae --- /dev/null +++ b/flake.nix @@ -0,0 +1,96 @@ +{ + description = "teamdraft.net"; + + inputs = { + devshell.url = "github:numtide/devshell"; + flake-parts.url = "github:hercules-ci/flake-parts"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + process-compose-flake.url = "github:Platonic-Systems/process-compose-flake"; + services-flake.url = "github:juspay/services-flake"; + treefmt-nix.url = "github:numtide/treefmt-nix"; + }; + + outputs = inputs @ { + flake-parts, + ... + }: + flake-parts.lib.mkFlake {inherit inputs;} { + imports = [ + inputs.devshell.flakeModule + inputs.process-compose-flake.flakeModule + inputs.treefmt-nix.flakeModule + ]; + systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"]; + perSystem = { + config, + self', + inputs', + pkgs, + system, + ... + }: + with builtins; rec { + process-compose."services" = { + imports = [ + inputs.services-flake.processComposeModules.default + ]; + services.postgres."db" = { + enable = true; + package = pkgs.postgresql_16; + extensions = extensions: [ + extensions.pgtap + extensions.pgsodium + ]; + + initialScript.before = readFile ./src/db/init.sql; + initialScript.after = readFile ./src/db/seed.sql; + + socketDir = "/tmp/db"; + superuser = "teamdraft"; + }; + settings = { + log_location = "./logs/services.log"; + }; + }; + + devshells.default = { + commands = [ + { + name = "db"; + help = "run postgresql"; + command = "nix run .#services"; + } + { + name = "reset"; + help = "recreate db and run postgresql"; + command = "rm -rf data && nix run .#services"; + } + { + name = "ci"; + help = "run all tests"; + command = "pg_prove"; + } + ]; + packages = with pkgs; [ + gdb + kcov + perl538Packages.TAPParserSourceHandlerpgTAP + pgcli + pgformatter + postgresql_16 + postgresql16Packages.pgtap + sops + zig + zls + ]; + }; + + treefmt.config = { + projectRootFile = "flake.nix"; + + flakeCheck = true; + flakeFormatter = true; + }; + }; + }; +} |