Skip to content

Commit

Permalink
Allow devenv up to work in downstream flakes
Browse files Browse the repository at this point in the history
  • Loading branch information
anoadragon453 committed Jun 25, 2024
1 parent 0777054 commit 00e239f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
}
```
Expand All @@ -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
Expand Down
14 changes: 13 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
);
};
}

0 comments on commit 00e239f

Please sign in to comment.