Skip to content

Commit

Permalink
feat(containers): provide migrations in lockpad image
Browse files Browse the repository at this point in the history
  • Loading branch information
justinrubek committed Nov 13, 2023
1 parent e0cc996 commit 2879967
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
4 changes: 3 additions & 1 deletion containers/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@
name = "image-root";
paths = [
self'.packages.cli
self'.packages.sqlx-cli
self'.packages.sqlx-migrations
];
pathsToLink = ["/bin"];
pathsToLink = ["/bin" "/migrations"];
};

config = {
Expand Down
6 changes: 4 additions & 2 deletions flake-parts/shells.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
lib,
...
}: let
inherit (self'.packages) rust-toolchain;
inherit (self'.packages) rust-toolchain sqlx-cli sqlx-migrations;
inherit (self'.legacyPackages) cargoExtraPackages ciPackages;

devTools = [
Expand All @@ -18,13 +18,15 @@
pkgs.cargo-udeps
pkgs.cargo-nextest
pkgs.bacon
pkgs.sqlx-cli
# version control
pkgs.cocogitto
inputs'.bomper.packages.cli
# database
self'.packages.postgresql
pkgs.pgcli
sqlx-cli
sqlx-migrations

# misc
pkgs.skopeo
];
Expand Down
21 changes: 21 additions & 0 deletions flake-parts/sqlx.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{self, ...} @ part-inputs: {
imports = [];

perSystem = {
pkgs,
inputs',
self',
...
}: let
inherit (pkgs) sqlx-cli;
in {
packages = {
inherit sqlx-cli;
# copy the migrations directory into a derivation
sqlx-migrations = pkgs.runCommand "sqlx-migrations" {} ''
mkdir -p $out
cp -r ${self}/migrations $out
'';
};
};
}
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
./flake-parts/pre-commit.nix

./flake-parts/postgres.nix
./flake-parts/sqlx.nix
./flake-parts/scylla.nix

inputs.process-compose.flakeModule
Expand Down

0 comments on commit 2879967

Please sign in to comment.