dotfiles/flake.nix
2024-02-03 13:11:23 +02:00

73 lines
2.3 KiB
Nix

{
description = "Prymn";
nixConfig = {
extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=";
extra-substituters = "https://devenv.cachix.org";
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
devenv.url = "github:cachix/devenv";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
inputs.rust-overlay.follows = "rust-overlay";
};
};
outputs = { self, nixpkgs, devenv, flake-utils, rust-overlay, crane }@inputs:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import ./nix/overlay.nix) (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
rustBuilder = import ./nix/rust.nix { inherit crane pkgs system; };
in
{
packages = {
devenv-up = self.devShells.${system}.default.config.procfileScript;
};
devShells.default = devenv.lib.mkShell {
inherit pkgs inputs;
modules = [
({ pkgs, config, ... }: {
packages = [
pkgs.elixir
pkgs.elixir-ls
pkgs.rustToolchain
pkgs.natscli
] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [ pkgs.inotify-tools ];
services.postgres = {
enable = true;
package = pkgs.postgresql_16;
initialDatabases = [{ name = "prymn_dev"; }];
initialScript = "CREATE USER postgres SUPERUSER;";
};
processes.nats-server.exec = "${pkgs.nats-server}/bin/nats-server -c ./agent/server.conf";
enterShell = ''
echo happy deving
'';
})
];
};
checks.rustTest = rustBuilder.test;
checks.rustClippy = rustBuilder.clippy;
checks.rustFormat = rustBuilder.format;
packages.agent-x86_64-linux = rustBuilder.package "x86_64-linux";
packages.agent-aarch64-linux = rustBuilder.package "aarch64-linux";
});
}