From c4ef680f30cef6fa3bb42c98d5c3b2b551b439f9 Mon Sep 17 00:00:00 2001 From: Marc Scholten Date: Sat, 27 Jan 2024 17:13:30 +0100 Subject: [PATCH] Allow optimized builds with deploy-to-nixos --- NixSupport/nixosModules/options.nix | 12 +++++++++++- NixSupport/nixosModules/services/app.nix | 4 ++-- NixSupport/nixosModules/services/worker.nix | 5 ++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/NixSupport/nixosModules/options.nix b/NixSupport/nixosModules/options.nix index b9bcc7fca..94a6097c4 100644 --- a/NixSupport/nixosModules/options.nix +++ b/NixSupport/nixosModules/options.nix @@ -1,5 +1,5 @@ # Running IHP app + a local Postgres connected to it -{ config, pkgs, modulesPath, lib, ... }: +{ self, config, pkgs, modulesPath, lib, ... }: with lib; { options.services.ihp = { @@ -74,6 +74,16 @@ with lib; type = types.attrs; default = {}; }; + + package = mkOption { + type = types.package; + default = if config.services.ihp.optimized then self.packages.x86_64-linux.optimized-prod-server else self.packages.x86_64-linux.default; + }; + + optimized = mkOption { + type = types.bool; + default = false; + }; }; } diff --git a/NixSupport/nixosModules/services/app.nix b/NixSupport/nixosModules/services/app.nix index dc16e1ae5..923ae827a 100644 --- a/NixSupport/nixosModules/services/app.nix +++ b/NixSupport/nixosModules/services/app.nix @@ -12,8 +12,8 @@ in serviceConfig = { Type = "simple"; Restart = "always"; - WorkingDirectory = "${ihpApp}/lib"; - ExecStart = "${ihpApp}/bin/RunProdServer"; + WorkingDirectory = "${cfg.package}/lib"; + ExecStart = "${cfg.package}/bin/RunProdServer"; }; environment = let diff --git a/NixSupport/nixosModules/services/worker.nix b/NixSupport/nixosModules/services/worker.nix index 87003b15a..5d96804ea 100644 --- a/NixSupport/nixosModules/services/worker.nix +++ b/NixSupport/nixosModules/services/worker.nix @@ -1,7 +1,6 @@ { config, pkgs, self, lib, ... }: let cfg = config.services.ihp; - ihpApp = self.packages.x86_64-linux.default; in { systemd.services.worker = { @@ -11,8 +10,8 @@ in serviceConfig = { Type = "simple"; Restart = "always"; - WorkingDirectory = "${ihpApp}/lib"; - ExecStart = "${ihpApp}/bin/RunJobs"; + WorkingDirectory = "${cfg.package}/lib"; + ExecStart = "${cfg.package}/bin/RunJobs"; }; environment = let