weewx-proxy/flake.nix

131 lines
3.4 KiB
Nix
Raw Normal View History

2023-06-06 14:41:34 +00:00
{
description = "weewx-proxy development environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
# Tools
2023-06-06 14:41:34 +00:00
flake-parts.url = "github:hercules-ci/flake-parts";
flake-root.url = "github:srid/flake-root";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
pre-commit-hooks-nix = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.gitignore.follows = "gitignore";
};
2023-06-06 14:41:34 +00:00
};
outputs = inputs@{ flake-parts, gitignore, ... }:
2023-06-06 14:41:34 +00:00
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "aarch64-darwin" "x86_64-linux" "aarch64-linux" ];
imports = [
inputs.flake-root.flakeModule
inputs.treefmt-nix.flakeModule
inputs.pre-commit-hooks-nix.flakeModule
];
perSystem = { pkgs, config, lib, self', ... }:
2023-06-06 14:41:34 +00:00
let
pname = "weewx-proxy";
version = "0.0.1";
2024-07-15 11:02:57 +00:00
erlang = pkgs.beam_minimal.interpreters.erlang_26;
beamPackages = pkgs.beam_minimal.packagesWith erlang;
elixir = beamPackages.elixir_1_16;
2023-06-06 14:41:34 +00:00
inherit (pkgs.stdenv) isDarwin;
inherit (gitignore.lib) gitignoreSource;
2023-06-06 14:41:34 +00:00
in
{
treefmt = {
inherit (config.flake-root) projectRootFile;
flakeCheck = false;
2023-06-06 14:41:34 +00:00
programs = {
mix-format = {
enable = true;
package = elixir;
};
2023-06-06 14:41:34 +00:00
nixpkgs-fmt.enable = true;
shfmt.enable = true;
};
};
pre-commit = {
check.enable = false;
settings = {
2024-07-15 11:02:57 +00:00
excludes = [ "deps.nix" ];
hooks = {
deadnix.enable = true;
2024-07-15 11:02:57 +00:00
#statix.enable = true;
treefmt.enable = true;
};
};
2023-06-06 14:41:34 +00:00
};
packages.default = beamPackages.mixRelease {
inherit pname version;
src = gitignoreSource ./.;
2024-07-15 11:02:57 +00:00
mixNixDeps = import ./deps.nix { inherit lib beamPackages; };
2023-06-06 14:41:34 +00:00
};
packages.container = pkgs.dockerTools.buildLayeredImage {
name = pname;
tag = "v${version}";
config = {
Env = [
"LANG=C.UTF-8"
];
2023-06-06 14:41:34 +00:00
ExposedPorts = { "4040/tcp" = { }; };
Entrypoint = [ "${self'.packages.default}/bin/weewx_proxy" ];
Cmd = [ "start" ];
};
};
apps.default = { type = "app"; program = "${self'.packages.default}/bin/weewx_proxy"; };
devShells.default = pkgs.mkShell {
name = pname;
nativeBuildInputs = [
erlang
elixir
] ++ lib.optionals isDarwin (with pkgs.darwin.apple_sdk.frameworks;
[
CoreFoundation
CoreServices
]);
packages = [
pkgs.mosquitto
];
inputsFrom = [
config.flake-root.devShell
config.treefmt.build.devShell
config.pre-commit.devShell
];
ERL_INCLUDE_PATH = "${erlang}/lib/erlang/usr/include";
TREEFMT_CONFIG_FILE = config.treefmt.build.configFile;
};
2023-06-06 14:41:34 +00:00
};
};
}