From d2e051b09dd5ecc888a09da2b2fab33750a2e078 Mon Sep 17 00:00:00 2001 From: "Jill \"oatmealine\" Monoids" Date: Tue, 23 May 2023 09:10:31 +0300 Subject: [PATCH] fix? flake --- flake.nix | 106 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 56 insertions(+), 50 deletions(-) diff --git a/flake.nix b/flake.nix index 9932961..179e67d 100644 --- a/flake.nix +++ b/flake.nix @@ -9,7 +9,7 @@ }; outputs = { self, nixpkgs, flake-utils, crystal-flake }: - (with flake-utils.lib; eachSystem defaultSystems) (system: + flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; inherit (crystal-flake.packages.${system}) crystal shards; @@ -47,61 +47,67 @@ shards ]; }; + }) // { + nixosModules = { + crystal-gauntlet = { config, lib, pkgs, ... }: + with lib; + let + cfg = config.services.crystal-gauntlet; + in { + options.services.crystal-gauntlet = { + enable = mkEnableOption "Enables the crystal-gauntlet server"; - nixosModule = { config, lib, pkgs, ... }: - with lib; - let - cfg = config.services.crystal-gauntlet; - in { - options.services.crystal-gauntlet = { - enable = mkEnableOption "Enables the crystal-gauntlet server"; - - domain = mkOption { - type = types.nullOr types.str; - default = null; - description = "Which domain to host the server under; if disabled, NGINX is not used"; - }; - port = mkOption { - type = types.port; - default = 8050; - }; - package = mkOption { - type = types.package; - default = self.packages.${system}.default; - }; - }; - - config = mkIf cfg.enable { - systemd.services."crystal-gauntlet" = { - wantedBy = [ "multi-user.target" ]; - - serviceConfig = { - Restart = "on-failure"; - ExecStart = "${getExe cfg.package}"; - DynamicUser = "yes"; - RuntimeDirectory = "crystal-gauntlet"; - RuntimeDirectoryMode = "0755"; - StateDirectory = "crystal-gauntlet"; - StateDirectoryMode = "0700"; - CacheDirectory = "crystal-gauntlet"; - CacheDirectoryMode = "0750"; + domain = mkOption { + type = types.nullOr types.str; + default = null; + description = "Which domain to host the server under; if disabled, NGINX is not used"; + }; + port = mkOption { + type = types.port; + default = 8050; + }; + package = mkOption { + type = types.package; + default = self.defaultPackage.${pkgs.system}; }; }; - services.nginx = mkIf cfg.domain { - virtualHosts."${cfg.domain}" = { - enableACME = true; - forceSSL = false; - addSSL = true; - locations."/" = { - proxyPass = "http://127.0.0.1:${cfg.port}/"; + config = mkIf cfg.enable { + systemd.services."crystal-gauntlet" = { + wantedBy = [ "multi-user.target" ]; + + environment = { + LISTEN_ON = "http://127.0.0.1:${toString cfg.port}"; + }; + + serviceConfig = { + Restart = "on-failure"; + ExecStart = "${getExe cfg.package}"; + DynamicUser = "yes"; + RuntimeDirectory = "crystal-gauntlet"; + RuntimeDirectoryMode = "0755"; + StateDirectory = "crystal-gauntlet"; + StateDirectoryMode = "0700"; + CacheDirectory = "crystal-gauntlet"; + CacheDirectoryMode = "0750"; + }; + }; + + services.nginx = mkIf (cfg.domain != null) { + virtualHosts."${cfg.domain}" = { + enableACME = true; + forceSSL = false; + addSSL = true; + locations."/" = { + proxyPass = "http://127.0.0.1:${toString cfg.port}/"; + }; + extraConfig = '' + client_max_body_size 500M; + ''; }; - extraConfig = '' - client_max_body_size 500M; - ''; }; }; }; - }; - }); + }; + }; } \ No newline at end of file