Skip to content

Commit

Permalink
add gate
Browse files Browse the repository at this point in the history
  • Loading branch information
srid committed Nov 19, 2024
1 parent 0090ff8 commit eff3333
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 17 deletions.
15 changes: 15 additions & 0 deletions configurations/nixos/gate/configuration.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{ ... }: {
imports = [
./hardware-configuration.nix
./networking.nix # generated at runtime by nixos-infect

];

boot.tmp.cleanOnBoot = true;
zramSwap.enable = true;
networking.hostName = "gate";
networking.domain = "";
services.openssh.enable = true;
users.users.root.openssh.authorizedKeys.keys = [ ''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHQRxPoqlThDrkR58pKnJgmeWPY9/wleReRbZ2MOZRyd'' ];
system.stateVersion = "23.11";
}
39 changes: 39 additions & 0 deletions configurations/nixos/gate/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{ flake, pkgs, ... }:

let
inherit (flake) inputs;
inherit (inputs) self;
in
{
# nixos-unified.sshTarget = "[email protected]";
nixos-unified.sshTarget = "gate";

imports = [
./configuration.nix
(self + /modules/nixos/shared/primary-as-admin.nix)
];

nixpkgs.hostPlatform = "x86_64-linux";
services.tailscale.enable = true;
services.openssh.settings.PasswordAuthentication = false;
services.nginx = {
enable = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
virtualHosts."actualism.app" = {
# FIXME: Don't hardcode, instead of read from pureintent's containers.nix
locations."/".proxyPass = "http://pureintent:3000";
enableACME = true;
addSSL = true;
};
};
security.acme = {
acceptTerms = true;
defaults.email = "[email protected]";
};
networking.firewall.allowedTCPPorts = [ 80 443 22 ];

# Workaround the annoying `Failed to start Network Manager Wait Online` error on switch.
# https://github.com/NixOS/nixpkgs/issues/180175
systemd.services.NetworkManager-wait-online.enable = false;
}
9 changes: 9 additions & 0 deletions configurations/nixos/gate/hardware-configuration.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{ modulesPath, ... }:
{
imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
boot.loader.grub.device = "/dev/sda";
boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "xen_blkfront" "vmw_pvscsi" ];
boot.initrd.kernelModules = [ "nvme" ];
fileSystems."/" = { device = "/dev/sda1"; fsType = "ext4"; };

}
34 changes: 34 additions & 0 deletions configurations/nixos/gate/networking.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{ lib, ... }: {
# This file was populated at runtime with the networking
# details gathered from the active system.
networking = {
nameservers = [
"8.8.8.8"
];
defaultGateway = "172.31.1.1";
defaultGateway6 = {
address = "fe80::1";
interface = "eth0";
};
dhcpcd.enable = false;
usePredictableInterfaceNames = lib.mkForce false;
interfaces = {
eth0 = {
ipv4.addresses = [
{ address = "5.161.184.111"; prefixLength = 32; }
];
ipv6.addresses = [
{ address = "2a01:4ff:f0:9d5a::1"; prefixLength = 64; }
{ address = "fe80::9400:3ff:fedc:b821"; prefixLength = 64; }
];
ipv4.routes = [{ address = "172.31.1.1"; prefixLength = 32; }];
ipv6.routes = [{ address = "fe80::1"; prefixLength = 128; }];
};

};
};
services.udev.extraRules = ''
ATTR{address}=="96:00:03:dc:b8:21", NAME="eth0"
'';
}
10 changes: 0 additions & 10 deletions configurations/nixos/pureintent/containers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
let
inherit (flake) inputs;
actualism-app = inputs.actualism-app.packages.${pkgs.system}.default;
app-port = 3000;
app-domain = "actualism.app";
in
{
containers.actualism-app = {
Expand All @@ -21,12 +19,4 @@ in
};
};
};

# TODO: cloudflare tunnels
services.nginx = {
enable = true;
virtualHosts.${app-domain} = {
locations."/".proxyPass = "http://localhost:${builtins.toString app-port}";
};
};
}
6 changes: 3 additions & 3 deletions flake.lock

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

13 changes: 9 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ default:

# Activate local configuration
[group('main')]
activate:
local:
nix run

# Deploy host 'pureintent'
[group('main')]
deploy:
# Deploy to Beelink
[group('deploy')]
pureintent:
nix run . pureintent

# Deploy to nginx gate
[group('deploy')]
gate:
nix run . gate

# Format the nix source tree
fmt:
pre-commit run --all-files

0 comments on commit eff3333

Please sign in to comment.