Setting up an app that references files in a nix flake


For my app, I am using go-migrate to handle my database migrations. It references a folder in my git repo and requires a POSTGRES_URL variable to be set.

I would love to set up so that I can run nix run myapp#migrate-up or myapp#migrate-down respectively and trying to understand how I would do that with a nix flake.

I’ve figured out that I probably need to set up something like

... # Import the package
        goMigrate = nixpkgs.legacyPackages.${system}.go-migrate;

... #Later in my outputs
        apps."myApp"."migrate-up" = {
          type = "app";
          program = "${goMigrate}/bin/migrate -database ??? -path ???/migrations up";

My questions are:

  1. How can I setup a configuration variable for the database connection string?
  2. How can I reference a path that belongs to the app project which contains my migration files?

Thanks in advance.