Skip to content

Commit

Permalink
Allow optimized builds with deploy-to-nixos
Browse files Browse the repository at this point in the history
  • Loading branch information
mpscholten committed Jan 27, 2024
1 parent a454f07 commit c4ef680
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
12 changes: 11 additions & 1 deletion NixSupport/nixosModules/options.nix
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -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;
};
};
}

4 changes: 2 additions & 2 deletions NixSupport/nixosModules/services/app.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions NixSupport/nixosModules/services/worker.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{ config, pkgs, self, lib, ... }:
let
cfg = config.services.ihp;
ihpApp = self.packages.x86_64-linux.default;
in
{
systemd.services.worker = {
Expand All @@ -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
Expand Down

0 comments on commit c4ef680

Please sign in to comment.