Running a Flake app from another Flake app

Hello everyone,

I’m a bit new to Flakes, and I’ve been trying to figure out the correct way to run a Flake app from another Flake app. For example, I want to use the deploy app to run first the infra.compile app and then the infra.apply app. Is there a way to do this?

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-21.05";

    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs-unstable.legacyPackages.${system};
      }; in {
        apps = {
          infra = rec {
            type = "app";

            compile = {
              type = "app";
              program = toString (pkgs.writers.writeBash "compile" ''
                ...
              '');
            };

            apply = {
              type = "app";
              program = toString (pkgs.writers.writeBash "apply" ''
                ...
              '');
            };

          deploy = {
            type = "app";

            # I want to run the compile app and then the apply app here
            program = ...;
          };
        };
      });
}

Hi. How about this?

          deploy = {
            type = "app";

            # I want to run the compile app and then the apply app here
            program = toString (pkgs.writeShellScript "final" ''
              ${compile.program}
              ${apply.program}
            '');
          };
1 Like