diff options
author | Mateus Cruz <mateuscolvr@gmail.com> | 2024-02-04 23:10:30 -0300 |
---|---|---|
committer | Mateus Cruz <mateuscolvr@gmail.com> | 2024-02-04 23:10:57 -0300 |
commit | f3ac99a84497868aded8ee7ec2822d1b12960fd7 (patch) | |
tree | a870e9bb38259e0641c282b2ba524ac9abe85346 /flake.nix |
initial commit
Diffstat (limited to 'flake.nix')
-rw-r--r-- | flake.nix | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..83eb5a3 --- /dev/null +++ b/flake.nix @@ -0,0 +1,70 @@ +{ + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:nix-ocaml/nix-overlays"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}.appendOverlays [ + (self: super: { + ocamlPackages = super.ocaml-ng.ocamlPackages_5_1.overrideScope' + (oself: osuper: { + pg_query = osuper.pg_query.overrideAttrs (prev: { + propagatedBuildInputs = prev.propagatedBuildInputs ++ [ osuper.cmdliner ]; + }); + }); + }) + ]; + + pkgs' = pkgs.pkgsCross.musl64; + + rinhadebackend = pkgs'.ocamlPackages.buildDunePackage { + pname = "rinhadebackend"; + version = "0.0.1"; + src = ./.; + buildInputs = with pkgs'.ocamlPackages; [ + ppx_rapper + ppx_rapper_eio + yojson + eio_main + piaf + routes + caqti-driver-postgresql + ppx_expect + + logs + ]; + }; + + in { + devShells.default = pkgs'.mkShell rec { + nativeBuildInputs = with pkgs'.ocamlPackages; [ + dune_3 + findlib + ocaml + ocaml-lsp + ocamlformat + ]; + + buildInputs = rinhadebackend.buildInputs + ++ (with pkgs'.ocamlPackages; [ utop ]); + }; + + packages.default = rinhadebackend; + + packages.docker = pkgs'.dockerTools.buildImage { + name = "ghcr.io/molvrr/rinhadebackend"; + tag = "latest"; + copyToRoot = pkgs'.buildEnv { + name = "image-root"; + paths = [ pkgs'.bashInteractive pkgs'.coreutils pkgs'.curl rinhadebackend ]; + pathsToLink = [ "/bin" ]; + }; + config = { Cmd = [ "rinhadebackend" ]; }; + }; + + formatter = pkgs.nixfmt; + }); +} |