Skip to content

Commit

Permalink
add nix shell file to start invidious and database
Browse files Browse the repository at this point in the history
  • Loading branch information
lamarios committed Dec 21, 2023
1 parent 04aade7 commit f49868b
Show file tree
Hide file tree
Showing 8 changed files with 1,168 additions and 1 deletion.
66 changes: 66 additions & 0 deletions nix/clipious.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{ pkgs, ci ? false}:

let

helpers = {
postgres = {
setup = builtins.readFile ./helpers/postgres/init_db.sh;
clean = builtins.readFile ./helpers/postgres/clean.sh;
packages = pkgs: [ pkgs.postgresql ];
};

invidious = {
setup = builtins.readFile ./helpers/invidious/setup.sh;
clean = "pkill invidious";
packages = pkgs: [ pkgs.invidious ];
};

};
in
{
helpers = helpers;

packages =
builtins.concatLists [
(helpers.postgres.packages pkgs)
(helpers.invidious.packages pkgs)
];

prepareShell = {setupScripts ? [], cleanupScripts ? [] }: ''
######################################################################
# Create a diretory for the generated artifacts #
######################################################################
mkdir .nix-shell
export NIX_SHELL_DIR=$PWD/.nix-shell
''
+ helpers.postgres.setup
+ helpers.invidious.setup
+
builtins.concatStringsSep "\n" setupScripts
+ ''
#clean up will be triggered once the shell exits
trap \
"''
+ helpers.postgres.clean
+ helpers.invidious.clean
+ builtins.concatStringsSep "\n" cleanupScripts
+
''
########################################################
# Delete `.nix-shell` directory #
# ---------------------------------- #
# The first step is going back to the project root, #
# otherwise `.nix-shell` won't get deleted. #
########################################################
cd $PWD
rm -rf $PGDATA
cd $PWD
rm -rf $NIX_SHELL_DIR
" \
EXIT
'';

}
Loading

0 comments on commit f49868b

Please sign in to comment.