network_inventory/flake.nix

86 lines
2.9 KiB
Nix
Raw Normal View History

2021-12-08 18:07:49 +01:00
{
description = "A Python API for various tools I use at work.";
inputs = {
2023-06-21 21:22:39 +02:00
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
2023-10-19 20:15:49 +02:00
systems.url = "github:nix-systems/default";
devenv.url = "github:cachix/devenv";
2021-12-08 18:07:49 +01:00
};
2023-10-19 20:15:49 +02:00
nixConfig = {
extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=";
extra-substituters = "https://devenv.cachix.org";
};
2024-03-11 15:39:08 +01:00
outputs =
{
self,
nixpkgs,
devenv,
systems,
}@inputs:
2023-10-19 20:15:49 +02:00
let
forEachSystem = nixpkgs.lib.genAttrs (import systems);
in
{
2024-03-11 15:39:08 +01:00
devShells = forEachSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
2024-03-11 15:38:29 +01:00
config = self.devShells.${system}.default.config;
2024-03-11 15:39:08 +01:00
in
{
default = devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
{
2024-03-11 15:38:29 +01:00
enterShell = ''
2024-03-11 16:20:54 +01:00
export PATH=$PATH:$DEVENV_ROOT/tooling/bin/
2024-03-11 15:38:29 +01:00
ln -sf ${config.process-managers.process-compose.configFile} ${config.env.DEVENV_ROOT}/process-compose.yml
'';
2024-03-11 15:39:08 +01:00
env = {
DJANGO_SETTINGS_MODULE = "network_inventory.settings.local";
PC_PORT_NUM = "9999";
2024-03-11 15:39:08 +01:00
PYTHON_KEYRING_BACKEND = "keyring.backends.fail.Keyring";
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
pkgs.stdenv.cc.cc
# Add any missing library needed You can use the nix-index package
# to locate them, e.g.
# nix-locate -w --top-level --at-root /lib/libudev.so.1
2023-10-19 20:15:49 +02:00
];
2024-03-11 16:48:07 +01:00
WEBPORT = "8080";
2024-03-11 15:39:08 +01:00
};
languages.python = {
enable = true;
package = pkgs.python310;
poetry = {
activate.enable = true;
2023-10-19 20:15:49 +02:00
enable = true;
2024-03-11 15:39:08 +01:00
install.enable = true;
2023-10-19 20:15:49 +02:00
};
2024-03-11 15:39:08 +01:00
};
process.implementation = "process-compose";
process-managers.process-compose.enable = true;
# https://github.com/cachix/devenv/blob/main/examples/process-compose/devenv.nix
processes = {
webserver = {
2024-03-11 16:48:07 +01:00
exec = "poetry run python ./src/manage.py runserver 0.0.0.0:${config.env.WEBPORT}";
process-compose.depends_on = {
setup = {
condition = "process_completed_successfully";
};
};
};
2024-03-11 15:39:08 +01:00
setup.exec = "dev setup";
};
services.postgres = {
enable = true;
initialDatabases = [ { name = "django"; } ];
package = pkgs.postgresql_15;
};
}
];
};
}
);
2023-10-19 20:15:49 +02:00
};
2021-12-08 18:07:49 +01:00
}