|
| 1 | +{ |
| 2 | + inputs = { |
| 3 | + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; |
| 4 | + website.url = "github:truroshan/django-nextjs-nix"; |
| 5 | + |
| 6 | + }; |
| 7 | + |
| 8 | + outputs = { nixpkgs,website, ... }: rec { |
| 9 | + |
| 10 | + colmena = { |
| 11 | + meta = { |
| 12 | + nixpkgs = import nixpkgs { |
| 13 | + system = "x86_64-linux"; |
| 14 | + }; |
| 15 | + }; |
| 16 | + |
| 17 | + do-droplet = { |
| 18 | + deployment = { |
| 19 | + targetHost = "192.168.0.1"; # server ip-address or domain name |
| 20 | + targetPort = 22; |
| 21 | + buildOnTarget = true; |
| 22 | + targetUser = "root"; |
| 23 | + tags = [ "web" ]; |
| 24 | + }; |
| 25 | + |
| 26 | + networking.firewall.allowedTCPPorts = [ 80 443 22 ]; |
| 27 | + |
| 28 | + services.openssh.enable = true; |
| 29 | + |
| 30 | + virtualisation.oci-containers.containers = { |
| 31 | + |
| 32 | + "nextapp" = { |
| 33 | + image = "nextapp:stable"; |
| 34 | + imageFile = website.packages.x86_64-linux.nextAppImage; |
| 35 | + ports = [ "3000:3000" ]; |
| 36 | + }; |
| 37 | + |
| 38 | + "djangoapp" = { |
| 39 | + image = "djangoapp:stable"; |
| 40 | + imageFile = website.packages.x86_64-linux.djangoAppImage; |
| 41 | + ports = [ "8080:8080" ]; |
| 42 | + }; |
| 43 | + }; |
| 44 | + |
| 45 | + # Connect Domain and enable Nginx |
| 46 | + services.nginx.enable = false; |
| 47 | + |
| 48 | + security.acme.acceptTerms = true; |
| 49 | + security.acme.email = "[email protected]"; |
| 50 | + |
| 51 | + |
| 52 | + services.nginx.virtualHosts = { |
| 53 | + |
| 54 | + "example.com" = { |
| 55 | + default = true; |
| 56 | + forceSSL = true; |
| 57 | + enableACME = true; |
| 58 | + locations."/".return = "200 \"Hello from Nixie!\""; |
| 59 | + }; |
| 60 | + |
| 61 | + "next.example.com" = { |
| 62 | + forceSSL = true; |
| 63 | + enableACME = true; |
| 64 | + locations."/" = { |
| 65 | + proxyPass = "http://localhost:3000"; |
| 66 | + }; |
| 67 | + }; |
| 68 | + |
| 69 | + "django.example.com" = { |
| 70 | + forceSSL = true; |
| 71 | + enableACME = true; |
| 72 | + locations."/" = { |
| 73 | + proxyPass = "http://localhost:8080"; |
| 74 | + }; |
| 75 | + }; |
| 76 | + |
| 77 | + }; |
| 78 | + |
| 79 | + |
| 80 | + system.stateVersion = "21.11"; |
| 81 | + boot.isContainer = true; |
| 82 | + time.timeZone = "Asia/Kolkata"; |
| 83 | + }; |
| 84 | + |
| 85 | + }; |
| 86 | + }; |
| 87 | +} |
0 commit comments