diff --git a/Guide/deployment.markdown b/Guide/deployment.markdown index 81d3a8b4c..45e50194a 100644 --- a/Guide/deployment.markdown +++ b/Guide/deployment.markdown @@ -214,7 +214,7 @@ flake.nixosConfigurations."ihp-app" = nixpkgs.lib.nixosSystem { services.ihp = { domain = "myihpapp.com"; - migrations = ./Application/Migration; + migrations = ./Application/Migration; # Optional: Remove this line or set to null if you don't use migrations schema = ./Application/Schema.sql; fixtures = ./Application/Fixtures.sql; sessionSecret = "xxx"; @@ -282,7 +282,7 @@ Make sure you put this into the `flake-parts.lib.mkFlake` block. The final `flak + + services.ihp = { + domain = "myihpapp.com"; -+ migrations = ./Application/Migration; ++ migrations = ./Application/Migration; # Optional: Remove this line or set to null if you don't use migrations + schema = ./Application/Schema.sql; + fixtures = ./Application/Fixtures.sql; + sessionSecret = "xxx"; diff --git a/NixSupport/nixosModules/options.nix b/NixSupport/nixosModules/options.nix index 653001458..66b3e912f 100644 --- a/NixSupport/nixosModules/options.nix +++ b/NixSupport/nixosModules/options.nix @@ -15,7 +15,11 @@ with lib; }; migrations = mkOption { - type = types.path; + type = types.nullOr types.path; + default = null; + description = '' + Path to the migrations directory. If null, migrations will be skipped. + ''; }; schema = mkOption { diff --git a/NixSupport/nixosModules/services/migrate.nix b/NixSupport/nixosModules/services/migrate.nix index 006085655..6be07adb0 100644 --- a/NixSupport/nixosModules/services/migrate.nix +++ b/NixSupport/nixosModules/services/migrate.nix @@ -1,8 +1,8 @@ -{ config, pkgs, ihp, ... }: +{ config, pkgs, lib, ihp, ... }: let cfg = config.services.ihp; in { - systemd.services.migrate = { + systemd.services.migrate = lib.mkIf (cfg.migrations != null) { serviceConfig = { Type = "oneshot"; ExecStart = ihp.apps."${pkgs.system}".migrate.program; diff --git a/flake-module.nix b/flake-module.nix index 80fd4e8dc..046ba5cd6 100644 --- a/flake-module.nix +++ b/flake-module.nix @@ -387,7 +387,11 @@ ihpFlake: --option sandbox false \ --option extra-substituters "https://digitallyinduced.cachix.org" \ --option extra-trusted-public-keys "digitallyinduced.cachix.org-1:y+wQvrnxQ+PdEsCt91rmvv39qRCYzEgGQaldK26hCKE=" - ssh $1 systemctl start migrate + + # Only start migrate service if it exists + if ssh $1 systemctl list-unit-files migrate.service >/dev/null 2>&1; then + ssh $1 systemctl start migrate + fi ''; overlays = [ihp.overlays.default];