2023-06-06 14:41:34 +00:00
|
|
|
{
|
|
|
|
description = "weewx-proxy development environment";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
2023-07-30 22:53:38 +00:00
|
|
|
|
|
|
|
# Tools
|
|
|
|
|
2023-06-06 14:41:34 +00:00
|
|
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
2023-07-09 12:43:26 +00:00
|
|
|
|
2023-07-30 22:53:38 +00:00
|
|
|
flake-root.url = "github:srid/flake-root";
|
|
|
|
|
|
|
|
treefmt-nix = {
|
|
|
|
url = "github:numtide/treefmt-nix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
2023-07-09 12:43:26 +00:00
|
|
|
gitignore = {
|
|
|
|
url = "github:hercules-ci/gitignore.nix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2023-07-30 22:53:38 +00:00
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2023-07-09 12:43:26 +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" ];
|
|
|
|
|
2023-07-30 22:53:38 +00:00
|
|
|
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;
|
2023-07-09 12:43:26 +00:00
|
|
|
inherit (gitignore.lib) gitignoreSource;
|
2023-06-06 14:41:34 +00:00
|
|
|
in
|
|
|
|
{
|
2023-07-30 22:53:38 +00:00
|
|
|
treefmt = {
|
|
|
|
inherit (config.flake-root) projectRootFile;
|
|
|
|
flakeCheck = false;
|
2023-06-06 14:41:34 +00:00
|
|
|
|
2023-07-30 22:53:38 +00:00
|
|
|
programs = {
|
|
|
|
mix-format = {
|
|
|
|
enable = true;
|
|
|
|
package = elixir;
|
|
|
|
};
|
2023-06-06 14:41:34 +00:00
|
|
|
|
2023-07-30 22:53:38 +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" ];
|
2023-07-30 22:53:38 +00:00
|
|
|
|
|
|
|
hooks = {
|
|
|
|
deadnix.enable = true;
|
2024-07-15 11:02:57 +00:00
|
|
|
#statix.enable = true;
|
2023-07-30 22:53:38 +00:00
|
|
|
treefmt.enable = true;
|
|
|
|
};
|
|
|
|
};
|
2023-06-06 14:41:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
packages.default = beamPackages.mixRelease {
|
|
|
|
inherit pname version;
|
|
|
|
|
2023-07-09 12:43:26 +00:00
|
|
|
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 = {
|
2023-07-30 22:53:38 +00:00
|
|
|
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"; };
|
2023-07-30 22:53:38 +00:00
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|