From a684fbe5914998a2707a20b7cf48ab054a0b1f25 Mon Sep 17 00:00:00 2001 From: April Eaton Date: Mon, 1 Dec 2025 18:35:13 +0100 Subject: [PATCH] Project init --- .envrc | 1 + .gitignore | 1 + day_1/.github/workflows/test.yml | 23 ++++++++ day_1/.gitignore | 4 ++ day_1/README.md | 24 ++++++++ day_1/gleam.toml | 19 +++++++ day_1/manifest.toml | 11 ++++ day_1/src/day_1.gleam | 5 ++ day_1/test/day_1_test.gleam | 13 +++++ flake.lock | 96 ++++++++++++++++++++++++++++++++ flake.nix | 60 ++++++++++++++++++++ 11 files changed, 257 insertions(+) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 day_1/.github/workflows/test.yml create mode 100644 day_1/.gitignore create mode 100644 day_1/README.md create mode 100644 day_1/gleam.toml create mode 100644 day_1/manifest.toml create mode 100644 day_1/src/day_1.gleam create mode 100644 day_1/test/day_1_test.gleam create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..29963da --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.direnv/ diff --git a/day_1/.github/workflows/test.yml b/day_1/.github/workflows/test.yml new file mode 100644 index 0000000..f6e42b5 --- /dev/null +++ b/day_1/.github/workflows/test.yml @@ -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: "28" + gleam-version: "1.13.0" + rebar3-version: "3" + # elixir-version: "1" + - run: gleam deps download + - run: gleam test + - run: gleam format --check src test diff --git a/day_1/.gitignore b/day_1/.gitignore new file mode 100644 index 0000000..599be4e --- /dev/null +++ b/day_1/.gitignore @@ -0,0 +1,4 @@ +*.beam +*.ez +/build +erl_crash.dump diff --git a/day_1/README.md b/day_1/README.md new file mode 100644 index 0000000..a6cac8a --- /dev/null +++ b/day_1/README.md @@ -0,0 +1,24 @@ +# day_1 + +[![Package Version](https://img.shields.io/hexpm/v/day_1)](https://hex.pm/packages/day_1) +[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/day_1/) + +```sh +gleam add day_1@1 +``` +```gleam +import day_1 + +pub fn main() -> Nil { + // TODO: An example of the project in use +} +``` + +Further documentation can be found at . + +## Development + +```sh +gleam run # Run the project +gleam test # Run the tests +``` diff --git a/day_1/gleam.toml b/day_1/gleam.toml new file mode 100644 index 0000000..8299130 --- /dev/null +++ b/day_1/gleam.toml @@ -0,0 +1,19 @@ +name = "day_1" +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" diff --git a/day_1/manifest.toml b/day_1/manifest.toml new file mode 100644 index 0000000..27177f5 --- /dev/null +++ b/day_1/manifest.toml @@ -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.67.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "6368313DB35963DC02F677A513BB0D95D58A34ED0A9436C8116820BF94BE3511" }, + { name = "gleeunit", version = "1.9.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "DA9553CE58B67924B3C631F96FE3370C49EB6D6DC6B384EC4862CC4AAA718F3C" }, +] + +[requirements] +gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" } +gleeunit = { version = ">= 1.0.0 and < 2.0.0" } diff --git a/day_1/src/day_1.gleam b/day_1/src/day_1.gleam new file mode 100644 index 0000000..e5f6c54 --- /dev/null +++ b/day_1/src/day_1.gleam @@ -0,0 +1,5 @@ +import gleam/io + +pub fn main() -> Nil { + io.println("Hello from day_1!") +} diff --git a/day_1/test/day_1_test.gleam b/day_1/test/day_1_test.gleam new file mode 100644 index 0000000..fba3c88 --- /dev/null +++ b/day_1/test/day_1_test.gleam @@ -0,0 +1,13 @@ +import gleeunit + +pub fn main() -> Nil { + gleeunit.main() +} + +// gleeunit test functions end in `_test` +pub fn hello_world_test() { + let name = "Joe" + let greeting = "Hello, " <> name <> "!" + + assert greeting == "Hello, Joe!" +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..7ee74e2 --- /dev/null +++ b/flake.lock @@ -0,0 +1,96 @@ +{ + "nodes": { + "devshell": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1764011051, + "narHash": "sha256-M7SZyPZiqZUR/EiiBJnmyUbOi5oE/03tCeFrTiUZchI=", + "owner": "numtide", + "repo": "devshell", + "rev": "17ed8d9744ebe70424659b0ef74ad6d41fc87071", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1763759067, + "narHash": "sha256-LlLt2Jo/gMNYAwOgdRQBrsRoOz7BPRkzvNaI/fzXi2Q=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "2cccadc7357c0ba201788ae99c4dfa90728ef5e0", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1762156382, + "narHash": "sha256-Yg7Ag7ov5+36jEFC1DaZh/12SEXo6OO3/8rqADRxiqs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "7241bcbb4f099a66aafca120d37c65e8dda32717", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1761765539, + "narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "719359f4562934ae99f5443f20aa06c2ffff91fc", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1764517877, + "narHash": "sha256-pp3uT4hHijIC8JUK5MEqeAWmParJrgBVzHLNfJDZxg4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2d293cbfa5a793b4c50d17c05ef9e385b90edf6c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "devshell": "devshell", + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs_2" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d6093e8 --- /dev/null +++ b/flake.nix @@ -0,0 +1,60 @@ +{ + description = "Description for the project"; + + inputs = { + flake-parts.url = "github:hercules-ci/flake-parts"; + devshell.url = "github:numtide/devshell"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = + inputs@{ flake-parts, devshell, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + # To import an internal flake module: ./other.nix + # To import an external flake module: + # 1. Add foo to inputs + # 2. Add foo as a parameter to the outputs function + # 3. Add here: foo.flakeModule + devshell.flakeModule + + ]; + systems = [ + "x86_64-linux" + "aarch64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; + perSystem = + { + config, + self', + inputs', + pkgs, + system, + ... + }: + { + # Per-system attributes can be defined here. The self' and inputs' + # module parameters provide easy access to attributes of the same + # system. + # + devshells.default = { + devshell.packages = with pkgs; [ + gleam + glas + beam28Packages.erlang + ]; + }; + + # Equivalent to inputs'.nixpkgs.legacyPackages.hello; + packages.default = pkgs.hello; + }; + flake = { + # The usual flake attributes can be defined here, including system- + # agnostic ones like nixosModule and system-enumerating ones, although + # those are more easily expressed in perSystem. + + }; + }; +}