Skip to content

Commit

Permalink
Merge pull request #2016 from digitallyinduced/simplify-migrate-service
Browse files Browse the repository at this point in the history
nixos: simplify migrate service by using IHP_MIGRATION_DIR
  • Loading branch information
mpscholten authored Nov 23, 2024
2 parents 611b881 + 1a0c987 commit 6f2ed28
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions NixSupport/nixosModules/services/migrate.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,15 @@
let cfg = config.services.ihp;
in
{
systemd.services.migrate =
let migrateApp = pkgs.stdenv.mkDerivation {
name = "migrate-app";
src = cfg.migrations;
buildPhase = ''
mkdir -p $out/Application/Migration
find "$src" -mindepth 1 -type f -exec cp {} $out/Application/Migration \;
'';
};
in {
serviceConfig = {
Type = "oneshot";
};
script = ''
cd ${migrateApp}
${ihp.apps."${pkgs.system}".migrate.program}
'';
environment = {
DATABASE_URL = cfg.databaseUrl;
MINIMUM_REVISION = "${toString cfg.minimumRevision}";
IHP_MIGRATION_DIR = cfg.ihpMigrationDir;
};
systemd.services.migrate = {
serviceConfig = {
Type = "oneshot";
ExecStart = ihp.apps."${pkgs.system}".migrate.program;
};
environment = {
DATABASE_URL = cfg.databaseUrl;
MINIMUM_REVISION = "${toString cfg.minimumRevision}";
IHP_MIGRATION_DIR = cfg.migrations;
};
};
}

0 comments on commit 6f2ed28

Please sign in to comment.