Created
September 25, 2025 16:44
-
-
Save Comamoca/c033d9a22e4bef7107857a4fbc114039 to your computer and use it in GitHub Desktop.
Build gleam application with gleam2nix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| inputs = { | |
| nixpkgs.url = "github:nixos/nixpkgs?ref=nixpkgs-unstable"; | |
| treefmt-nix.url = "github:numtide/treefmt-nix"; | |
| flake-parts.url = "github:hercules-ci/flake-parts"; | |
| systems.url = "github:nix-systems/default"; | |
| git-hooks-nix.url = "github:cachix/git-hooks.nix"; | |
| devenv.url = "github:cachix/devenv"; | |
| gleam-overlay.url = "github:Comamoca/gleam-overlay"; | |
| gleam2nix.url = "git+https://git.isincredibly.gay/srxl/gleam2nix"; | |
| gleam2nix.inputs.nixpkgs.follows = "nixpkgs"; | |
| fenix.url = "github:nix-community/fenix"; | |
| fenix.inputs.nixpkgs.follows = "nixpkgs"; | |
| }; | |
| outputs = | |
| inputs@{ | |
| self, | |
| systems, | |
| nixpkgs, | |
| flake-parts, | |
| ... | |
| }: | |
| flake-parts.lib.mkFlake { inherit inputs; } { | |
| imports = [ | |
| inputs.treefmt-nix.flakeModule | |
| inputs.git-hooks-nix.flakeModule | |
| inputs.devenv.flakeModule | |
| ]; | |
| systems = import inputs.systems; | |
| perSystem = | |
| { | |
| config, | |
| pkgs, | |
| system, | |
| ... | |
| }: | |
| let | |
| hello = inputs.gleam2nix.lib.${system}.buildGleamApplication { | |
| pname = "hello"; | |
| version = "1.0.0"; | |
| src = pkgs.lib.cleanSource ./.; | |
| gleamNix = import ./gleam.nix { inherit (pkgs) lib; }; | |
| gleam = pkgs.gleam.bin.latest; | |
| }; | |
| git-secrets' = pkgs.writeShellApplication { | |
| name = "git-secrets"; | |
| runtimeInputs = [ pkgs.git-secrets ]; | |
| text = '' | |
| git secrets --scan | |
| ''; | |
| }; | |
| in | |
| { | |
| _module.args.pkgs = import inputs.nixpkgs { | |
| inherit system; | |
| overlays = [ | |
| inputs.gleam-overlay.overlays.default | |
| inputs.gleam2nix.overlays.default | |
| inputs.fenix.overlays.default | |
| ]; | |
| config = { }; | |
| }; | |
| treefmt = { | |
| projectRootFile = "flake.nix"; | |
| programs = { | |
| nixfmt.enable = true; | |
| }; | |
| settings.formatter = { }; | |
| }; | |
| pre-commit = { | |
| check.enable = true; | |
| settings = { | |
| hooks = { | |
| treefmt.enable = true; | |
| ripsecrets.enable = true; | |
| git-secrets = { | |
| enable = true; | |
| name = "git-secrets"; | |
| entry = "${git-secrets'}/bin/git-secrets"; | |
| language = "system"; | |
| types = [ "text" ]; | |
| }; | |
| }; | |
| }; | |
| }; | |
| devenv.shells.default = { | |
| packages = with pkgs; [ | |
| nil | |
| beam28Packages.rebar3 | |
| gleam2nix | |
| ]; | |
| languages = { | |
| gleam = { | |
| enable = true; | |
| package = pkgs.gleam.bin.latest; | |
| }; | |
| erlang = { | |
| enable = true; | |
| }; | |
| # javascript = { | |
| # enable = true; | |
| # }; | |
| # deno = { | |
| # enable = true; | |
| # }; | |
| }; | |
| enterShell = ''''; | |
| }; | |
| packages.default = hello; | |
| }; | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment