diff --git a/lib/node-application.nix b/lib/node-application.nix index 60a90da..b3b28fc 100644 --- a/lib/node-application.nix +++ b/lib/node-application.nix @@ -44,6 +44,7 @@ ExecStart = "${application}/${mainBinaryPath}"; User = name; PermissionsStartOnly = true; + Restart = "on-failure"; }; } // serviceConfig); }; diff --git a/lib/presets/qemu-guest.nix b/lib/presets/qemu-guest.nix new file mode 100644 index 0000000..26c4dd9 --- /dev/null +++ b/lib/presets/qemu-guest.nix @@ -0,0 +1,15 @@ +{ + imports = [ + + ]; + + boot = { + initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "sd_mod" "sr_mod" ]; + + loader.grub = { + enable = true; + version = 2; + device = "/dev/sda"; + }; + }; +} diff --git a/networks/default.nix b/networks/default.nix index 8047b70..2f29f69 100644 --- a/networks/default.nix +++ b/networks/default.nix @@ -7,7 +7,7 @@ generateCaddyConfiguration = (import ../lib/generate/caddy-configuration.nix) args; in let proxiedApplications = [{ - hostname = "pastebin-stream-dev.cryto.net"; + hostname = config.systems.osmium.applications.pastebin-stream.hostname; tls = true; proxyTarget = "http://localhost:3000"; }]; @@ -16,40 +16,53 @@ imports = [ (pastebinStream { errorPath = "/var/lib/pastebin-stream/errors"; - rev = "3b7f6ea4ad663b82e7cfd95ae3c65f1a32f0cb0a"; - sha256 = "0w29rwgkjpd9cl42z0n2fy5is730db3mfsqvjmxa7x65nz34d3wj"; + rev = "06ef0fa19aa05a755efcafd9be077d3dacd79ee8"; + sha256 = "06ilz7g31lrwyn1lcx095a5nn305xfmg5whdqb4ghgc8whn765s8"; }) ]; - services.caddy = { - enable = true; - agree = true; - email = "admin@cryto.net"; - config = '' + config = { + services.caddy = { + enable = true; + agree = true; + email = "admin@cryto.net"; + config = '' ${generateCaddyConfiguration proxiedApplications} - ''; - }; - - services.node-pastebin-stream = { - enable = true; + ''; + }; - errorReporting = { + services.node-pastebin-stream = { enable = true; - metadata = { - from = "ops@cryto.net"; - to = "admin@cryto.net"; + errorReporting = { + enable = true; + + metadata = { + from = "ops@cryto.net"; + to = "admin@cryto.net"; + }; }; }; - }; - networking.firewall.allowedTCPPorts = [ - 80 - 443 - ]; + networking.firewall.allowedTCPPorts = [ + 80 + 443 + ]; - environment.systemPackages = with pkgs; [ - htop - ]; + environment.systemPackages = with pkgs; [ + htop + ]; + }; + + options.systems.osmium = with lib; { + applications.pastebin-stream = { + hostname = mkOption { + description = '' + The hostname to expose the pastebin-stream application on. + ''; + type = types.str; + }; + }; + }; }; } diff --git a/systems/osmium-testing.nix b/systems/osmium-testing.nix index b91e79c..0e186eb 100644 --- a/systems/osmium-testing.nix +++ b/systems/osmium-testing.nix @@ -11,6 +11,11 @@ in { deployment.targetEnv = "digitalOcean"; deployment.digitalOcean.region = "ams2"; deployment.digitalOcean.size = "512mb"; - #deployment.digitalOcean.authToken = removeNewlines (builtins.readFile ../credentials/digitalocean-auth-token); + + systems.osmium = { + applications.pastebin-stream = { + hostname = "pastebin-stream-dev.cryto.net"; + }; + }; } // presetRootSsh // presetTools; } diff --git a/systems/osmium.nix b/systems/osmium.nix new file mode 100644 index 0000000..86b1dfc --- /dev/null +++ b/systems/osmium.nix @@ -0,0 +1,32 @@ +let + removeNewlines = (import ../lib/util/remove-newlines.nix); + presetRootSsh = (import ../lib/presets/root-ssh.nix); +in { + osmium = {config, pkgs, ...}@args: let + presetTools = (import ../lib/presets/tools.nix) args; + presetQemuGuest = (import ../lib/presets/qemu-guest.nix); + in + { + deployment.targetHost = "80.255.0.137"; + + systems.osmium = { + applications.pastebin-stream = { + hostname = "pastebin-stream.cryto.net"; + }; + }; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/cf472470-0b3d-414b-93f8-b5e4298fad05"; + fsType = "ext4"; + }; + + networking = { + hostName = "osmium"; + defaultGateway6 = "2a01:4a0:4a::1"; + interfaces.enp0s3 = { + ipv6Address = "2a01:4a0:4a:5d::35c7"; + ipv6PrefixLength = 48; + }; + }; + } // presetRootSsh // presetTools // presetQemuGuest; +}