add flake support
This commit is contained in:
parent
472aa83b3e
commit
8fa5d38f82
2 changed files with 100 additions and 0 deletions
73
flake.nix
Normal file
73
flake.nix
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
description = "Backend development flake";
|
||||
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||
outputs = {nixpkgs, ... }: let
|
||||
forAllSystems = nixpkgs.lib.genAttrs [
|
||||
"aarch64-linux"
|
||||
"i686-linux"
|
||||
"x86_64-linux"
|
||||
"aarch64-darwin"
|
||||
"x86_64-darwin"
|
||||
];
|
||||
in {
|
||||
devShells = forAllSystems (system: let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
config = {
|
||||
android_sdk.accept_license = true;
|
||||
allowUnfree = true;
|
||||
};
|
||||
};
|
||||
in {
|
||||
default = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
(python312.withPackages (
|
||||
ppkgs:
|
||||
with python312Packages; [
|
||||
pip # python package manager
|
||||
fastapi # web framework
|
||||
pandas # data manipulation
|
||||
pydantic # data validation
|
||||
uvicorn # ASGI server
|
||||
sqlalchemy # ORM
|
||||
python-multipart # fastapi multipart form data
|
||||
]
|
||||
))
|
||||
fastapi-cli
|
||||
sqlitestudio
|
||||
];
|
||||
};
|
||||
});
|
||||
# app for backing up the data
|
||||
apps = forAllSystems (system: let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
config = {
|
||||
android_sdk.accept_license = true;
|
||||
allowUnfree = true;
|
||||
};
|
||||
};
|
||||
in {
|
||||
default = pkgs.fastapi-cli;
|
||||
backup-db = pkgs.writeShellApplication {
|
||||
name = "backup-db";
|
||||
runtimeInputs = [ pkgs.zip ];
|
||||
text = ''
|
||||
# date
|
||||
DATE=$(date +%Y-%m-%d)
|
||||
# backup directory
|
||||
BACKUP_DIR=~/aifred-backup/
|
||||
# create backup directory if it doesn't exist
|
||||
mkdir -p $BACKUP_DIR
|
||||
|
||||
# backup file name
|
||||
BACKUP_FILE=$BACKUP_DIR/backup-$DATE.zip
|
||||
zip -r $BACKUP_FILE data/
|
||||
|
||||
# move backup file to backup directory
|
||||
mv #BACKUP_FILE $BACKUP_DIR
|
||||
'';
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue