init gleam

This commit is contained in:
41666 2025-04-29 18:19:33 -07:00
parent ac8220c015
commit f941e6902e
10 changed files with 176 additions and 42 deletions

23
.github/workflows/test.yml vendored Normal file
View file

@ -0,0 +1,23 @@
name: test
on:
push:
branches:
- master
- main
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
with:
otp-version: "27.1.2"
gleam-version: "1.10.0"
rebar3-version: "3"
# elixir-version: "1"
- run: gleam deps download
- run: gleam test
- run: gleam format --check src test

8
.gitignore vendored
View file

@ -1,3 +1,7 @@
.direnv/
*.beam
*.ez
/build
erl_crash.dump
result
.env
.env
.direnv

24
README.md Normal file
View file

@ -0,0 +1,24 @@
# switcheroo
[![Package Version](https://img.shields.io/hexpm/v/switcheroo)](https://hex.pm/packages/switcheroo)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/switcheroo/)
```sh
gleam add switcheroo@1
```
```gleam
import switcheroo
pub fn main() -> Nil {
// TODO: An example of the project in use
}
```
Further documentation can be found at <https://hexdocs.pm/switcheroo>.
## Development
```sh
gleam run # Run the project
gleam test # Run the tests
```

62
flake.lock generated
View file

@ -1,20 +1,35 @@
{
"nodes": {
"flake-parts": {
"flake-utils": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
"systems": "systems"
},
"locked": {
"lastModified": 1743550720,
"narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "c621e8422220273271f52058f618c94e405bb0f5",
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nix-gleam": {
"locked": {
"lastModified": 1717670865,
"narHash": "sha256-+dAPiKAwCzlKWtx3aIHXfR6jydh1JyangewqZKJx500=",
"owner": "arnarg",
"repo": "nix-gleam",
"rev": "c69abe0e57a01991654d3de63dcd93a8b91b98ff",
"type": "github"
},
"original": {
"owner": "arnarg",
"repo": "nix-gleam",
"type": "github"
}
},
@ -34,26 +49,27 @@
"type": "github"
}
},
"nixpkgs-lib": {
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nix-gleam": "nix-gleam",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1743296961,
"narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa",
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",

View file

@ -1,20 +1,42 @@
{
description = "plapkit";
description = "My gleam application";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
};
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nix-gleam.url = "github:arnarg/nix-gleam";
outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-linux" ];
perSystem = { config, self', pkgs, lib, system, ... }: rec {
devShells.default = import ./shell.nix { inherit pkgs; };
outputs = {
self,
nixpkgs,
flake-utils,
nix-gleam,
}: (
flake-utils.lib.eachDefaultSystem
(system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
nix-gleam.overlays.default
];
};
in rec {
packages.default = pkgs.buildGleamApplication {
# The pname and version will be read from the `gleam.toml`
# file generated by gleam.
# But this can be overwritten here too:
# pname = "my-app";
# version = "1.2.3";
# The target is read from the `gleam.toml` file too.
# Default is "erlang" if nothing is specified but
# this can also be overwritten here too:
# target = "javascript";
# Erlang package can be overridden but defaults to
# `pkgs.erlang`.
# erlangPackage = pkgs.erlang_nox;
packages.default = pkgs.buildGoModule {
name = "switcheroo";
src = ./.;
vendorHash = "sha256-YY7Hj7lSq7vEoMEIu/zmweWzd7p7KF+4YCUX2SJ7kwI=";
};
packages.container = pkgs.dockerTools.buildImage {
@ -30,6 +52,6 @@
Cmd = [ "${packages.default}/bin/switcheroo" ];
};
};
};
};
})
);
}

19
gleam.toml Normal file
View file

@ -0,0 +1,19 @@
name = "switcheroo"
version = "1.0.0"
# Fill out these fields if you intend to generate HTML documentation or publish
# your project to the Hex package manager.
#
# description = ""
# licences = ["Apache-2.0"]
# repository = { type = "github", user = "", repo = "" }
# links = [{ title = "Website", href = "" }]
#
# For a full reference of all the available options, you can have a look at
# https://gleam.run/writing-gleam/gleam-toml/.
[dependencies]
gleam_stdlib = ">= 0.44.0 and < 2.0.0"
[dev-dependencies]
gleeunit = ">= 1.0.0 and < 2.0.0"

11
manifest.toml Normal file
View file

@ -0,0 +1,11 @@
# This file was generated by Gleam
# You typically do not need to edit this file
packages = [
{ name = "gleam_stdlib", version = "0.59.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "F8FEE9B35797301994B81AF75508CF87C328FE1585558B0FFD188DC2B32EAA95" },
{ name = "gleeunit", version = "1.3.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "A7DD6C07B7DA49A6E28796058AA89E651D233B357D5607006D70619CD89DAAAB" },
]
[requirements]
gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }

View file

@ -1,7 +1,5 @@
{ pkgs ? import <nixpkgs> {} }: pkgs.mkShell {
buildInputs = with pkgs; [
go
just
sqlite
gleam
];
}

5
src/switcheroo.gleam Normal file
View file

@ -0,0 +1,5 @@
import gleam/io
pub fn main() -> Nil {
io.println("Hello from switcheroo!")
}

View file

@ -0,0 +1,12 @@
import gleeunit
import gleeunit/should
pub fn main() -> Nil {
gleeunit.main()
}
// gleeunit test functions end in `_test`
pub fn hello_world_test() {
1
|> should.equal(1)
}