iceshrimp/flake.nix

87 lines
2.6 KiB
Nix
Raw Normal View History

{
2023-07-03 07:18:30 +09:00
description = "Firefish development flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
# Flake Parts framework(https://flake.parts)
flake-parts.url = "github:hercules-ci/flake-parts";
# Devenv for better devShells(https://devenv.sh)
devenv.url = "github:cachix/devenv";
# Fenix for rust development
fenix.url = "github:nix-community/fenix";
fenix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.devenv.flakeModule
];
2023-07-24 11:09:15 +09:00
# Define the systems that this works on. Only tested with x86_64-linux, add more if you test and it works.
systems = [
"x86_64-linux"
];
# Expose these attributes for every system defined above.
perSystem = { config, pkgs, ... }: {
# Devenv shells
devenv = {
shells = {
# The default shell, used by nix-direnv
default = {
2023-07-27 05:27:59 +09:00
name = "iceshrimp-dev-shell";
# Add additional packages to our environment
packages = [
2023-07-27 20:45:15 +09:00
pkgs.yarn-berry
pkgs.python3
];
# No need to warn on a new version, we'll update as needed.
devenv.warnOnNewVersion = false;
# Enable typescript support
languages.typescript.enable = true;
2023-07-31 03:44:55 +09:00
# Enable javascript for NPM and Yarn
languages.javascript.enable = true;
languages.javascript.package = pkgs.nodejs_18;
# Enable stable Rust for the backend
languages.rust.enable = true;
2023-07-27 05:27:59 +09:00
languages.rust.channel = "stable";
processes = {
2023-07-31 03:44:55 +09:00
dev-server.exec = "yarn run dev";
};
scripts = {
2023-07-24 16:57:15 +09:00
build.exec = "yarn run build";
clean.exec = "yarn run clean";
clear-state.exec = "rm -rf .devenv/state/redis .devenv/state/postgres";
2023-07-24 16:57:15 +09:00
format.exec = "yarn run format";
install-deps.exec = "yarn install";
migrate.exec = "yarn run migrate";
prepare-config.exec = "cp .config/devenv.yml .config/default.yml";
};
services = {
postgres = {
enable = true;
package = pkgs.postgresql_12;
initialDatabases = [{
2023-07-27 05:27:59 +09:00
name = "iceshrimp";
}];
initialScript = ''
2023-07-27 07:28:11 +09:00
CREATE USER iceshrimp WITH PASSWORD 'iceshrimp';
2023-07-27 20:17:56 +09:00
ALTER USER iceshrimp WITH SUPERUSER;
2023-07-27 07:28:11 +09:00
GRANT ALL ON DATABASE iceshrimp TO iceshrimp;
'';
listen_addresses = "127.0.0.1";
port = 5432;
};
redis = {
enable = true;
bind = "127.0.0.1";
port = 6379;
};
};
};
};
};
};
};
}