From fd8869e3da13684576e9b3593d3c7cc459f7142e Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Fri, 8 Dec 2023 08:52:59 -0700 Subject: [PATCH] Install postgres onto phobos. --- README.md | 3 +- hive/flake.lock | 45 ------------ hive/flake.nix | 24 ------ hive/phobos/flake.nix | 21 ------ infra/flake.lock | 117 ++++++++++++++++++++++++++++++ infra/flake.nix | 29 ++++++++ {hive => infra}/phobos/flake.lock | 0 infra/phobos/flake.nix | 52 +++++++++++++ 8 files changed, 200 insertions(+), 91 deletions(-) delete mode 100644 hive/flake.lock delete mode 100644 hive/flake.nix delete mode 100644 hive/phobos/flake.nix create mode 100644 infra/flake.lock create mode 100644 infra/flake.nix rename {hive => infra}/phobos/flake.lock (100%) create mode 100644 infra/phobos/flake.nix diff --git a/README.md b/README.md index 0d14fa0..beed349 100644 --- a/README.md +++ b/README.md @@ -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, diff --git a/hive/flake.lock b/hive/flake.lock deleted file mode 100644 index 1b65440..0000000 --- a/hive/flake.lock +++ /dev/null @@ -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 -} diff --git a/hive/flake.nix b/hive/flake.nix deleted file mode 100644 index 6eb7fd2..0000000 --- a/hive/flake.nix +++ /dev/null @@ -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; - }; - }; -} diff --git a/hive/phobos/flake.nix b/hive/phobos/flake.nix deleted file mode 100644 index 7318e9a..0000000 --- a/hive/phobos/flake.nix +++ /dev/null @@ -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"; - }; - }; -} diff --git a/infra/flake.lock b/infra/flake.lock new file mode 100644 index 0000000..b2daaba --- /dev/null +++ b/infra/flake.lock @@ -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 +} diff --git a/infra/flake.nix b/infra/flake.nix new file mode 100644 index 0000000..8ba8e64 --- /dev/null +++ b/infra/flake.nix @@ -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; + }; + }; +} diff --git a/hive/phobos/flake.lock b/infra/phobos/flake.lock similarity index 100% rename from hive/phobos/flake.lock rename to infra/phobos/flake.lock diff --git a/infra/phobos/flake.nix b/infra/phobos/flake.nix new file mode 100644 index 0000000..94f55df --- /dev/null +++ b/infra/phobos/flake.nix @@ -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"; + }; + }; +}