Install postgres onto phobos.

main
Joshua Potter 2023-12-08 08:52:59 -07:00
parent 9c083e3a41
commit fd8869e3da
8 changed files with 200 additions and 91 deletions

View File

@ -25,7 +25,8 @@ from your DigitalOcean account at creation time.
Deployment is managed using [colmena](https://github.com/zhaofengli/colmena).
To deploy, run the following:
```bash
$ cd hive
$ cd infra
$ nix flake update # If any machine changes were made.
$ colmena apply
```
Note that colmena requires non-interactivity. If you haven't done so already,

View File

@ -1,45 +0,0 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1701952659,
"narHash": "sha256-TJv2srXt6fYPUjxgLAL0cy4nuf1OZD4KuA1TrCiQqg0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b4372c4924d9182034066c823df76d6eaf1f4ec4",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
},
"phobos": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1,
"narHash": "sha256-D7vDC0Qph0MikxxgIlCNduD1o7QfQQO5SRtGLAVwywg=",
"path": "./phobos",
"type": "path"
},
"original": {
"path": "./phobos",
"type": "path"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"phobos": "phobos"
}
}
},
"root": "root",
"version": 7
}

View File

@ -1,24 +0,0 @@
{
description = "Configuration of all remote NixOS machines.";
inputs = {
phobos = {
url = "path:./phobos";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
};
outputs = { nixpkgs, phobos, ... }: {
colmena = {
meta = {
nixpkgs = import nixpkgs {
system = "x86_64-linux";
};
};
# Remote machines
phobos = phobos.nixosModules.default;
};
};
}

View File

@ -1,21 +0,0 @@
{
description = "Phobos machine";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
};
outputs = { nixpkgs, ... }: {
nixosModules.default = { modulesPath, lib, ... }: {
imports = lib.optional (builtins.pathExists ./do-userdata.nix) ./do-userdata.nix ++ [
(modulesPath + "/virtualisation/digital-ocean-config.nix")
];
deployment.targetHost = "146.190.127.180";
networking.hostName = "phobos";
system.stateVersion = "23.11";
};
};
}

117
infra/flake.lock Normal file
View File

@ -0,0 +1,117 @@
{
"nodes": {
"boardwise": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": [
"phobos",
"nixpkgs"
]
},
"locked": {
"lastModified": 1701963345,
"narHash": "sha256-ObPo2TtW4JqhpjR/bzuGDPvcQp21ykImi5DYD7gKg4Q=",
"owner": "boardwise-gg",
"repo": "website",
"rev": "0eca8e5f5f9cf1b4c12c1d50e851dad94b33c0a9",
"type": "github"
},
"original": {
"owner": "boardwise-gg",
"ref": "v0.1.0",
"repo": "website",
"type": "github"
}
},
"flake-compat": {
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"revCount": 57,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1701952659,
"narHash": "sha256-TJv2srXt6fYPUjxgLAL0cy4nuf1OZD4KuA1TrCiQqg0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b4372c4924d9182034066c823df76d6eaf1f4ec4",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
},
"phobos": {
"inputs": {
"boardwise": "boardwise",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1,
"narHash": "sha256-BcLR2La75qG8EVXabtZ0KXq+OYXtBVY8opTxS2qHdrg=",
"path": "./phobos",
"type": "path"
},
"original": {
"path": "./phobos",
"type": "path"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"phobos": "phobos"
}
},
"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
}

29
infra/flake.nix Normal file
View File

@ -0,0 +1,29 @@
{
description = "Configuration of all remote NixOS machines.";
inputs = {
phobos = {
url = "path:./phobos";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
};
outputs = { nixpkgs, phobos, ... }:
let
system = "x86_64-linux";
in
{
colmena = {
meta = {
nixpkgs = import nixpkgs {
inherit system;
};
specialArgs = { inherit system; };
};
# Remote machines
phobos = phobos.nixosModules.default;
};
};
}

52
infra/phobos/flake.nix Normal file
View File

@ -0,0 +1,52 @@
{
description = "Phobos machine";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
boardwise = {
url = "github:boardwise-gg/website/v0.1.0";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { boardwise, ... }: {
nixosModules.default = { modulesPath, pkgs, lib, system, ... }: {
imports = lib.optional (builtins.pathExists ./do-userdata.nix) ./do-userdata.nix ++ [
(modulesPath + "/virtualisation/digital-ocean-config.nix")
];
deployment = {
targetHost = "146.190.127.180";
};
networking = {
hostName = "phobos";
firewall = {
enable = true;
allowedTCPPorts = [ 80 443 ];
};
};
services.postgresql = {
enable = true;
package = pkgs.postgresql_15;
ensureDatabases = [ "boardwise" ];
authentication = lib.mkOverride 10 ''
# TYPE DATABASE USER ADDRESS METHOD
local all all trust
'';
};
environment = {
systemPackages = [
boardwise.packages.${system}.app
];
variables = {
DATABASE_URL="ecto://postgres:postgres@localhost/boardwise";
};
};
system.stateVersion = "23.11";
};
};
}