From 00e239ff58f414f9467b98e856f5cdb1693e2cba Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Tue, 25 Jun 2024 11:21:27 +0100 Subject: [PATCH] Allow `devenv up` to work in downstream flakes --- README.md | 10 ++++++++++ flake.nix | 14 +++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b35aa4..db8fb90 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,10 @@ provided by this flake's outputs: devShells = element-nix-flakes.outputs.composeShell [ "synapse" ]; + # Use the `setupPackages` function to configure `devenv up` + # to use the `services` and `processes` defined in the + # "synapse" project module. + packages = element-nix-flakes.outputs.setupPackages "synapse"; }; } ``` @@ -104,6 +108,12 @@ Note that `composeShell` takes a list as an argument. You can provide multiple project names in this list, and `composeShell` will build a development shell dependencies from all projects combined together. +`setupPackages` is another function provided by the `nix-flakes` flake, which +must be called (and its output set to `packages`) in order to utilise the +`devenv up` functionality. This will start any `processes` and `services` +defined in the project module - for instance, starting up the project and +any database/redis/language servers etc needed for development. + ## Development ### Adding a new project diff --git a/flake.nix b/flake.nix index af683df..434bb21 100644 --- a/flake.nix +++ b/flake.nix @@ -8,7 +8,7 @@ rust-overlay.url = "github:oxalica/rust-overlay"; }; - outputs = inputs@{ devenv, nixpkgs, rust-overlay, systems, ... }: + outputs = inputs@{ self, devenv, nixpkgs, rust-overlay, systems, ... }: let # The local directory where project-specific flakes are stored. projectFlakesDirectory = ./project-flakes; @@ -98,5 +98,17 @@ }; } ); + # Define a function `setupPackages` that downstream flakes can use to correctly + # configure the `devenv up` functionality. + # + # This function creates an entry intended to be inserted into a downstream flake's + # `packages` flake output. + # + # See the README for how to use this in a downstream flake. + setupPackages = projectName: forEachSystem (system: + { + devenv-up = self.devShells.${system}.${projectName}.config.procfileScript; + } + ); }; } \ No newline at end of file