From ac861e12fcc7c9f202a120fb4cb05d6891c40dd8 Mon Sep 17 00:00:00 2001 From: "Shahar \"Dawn\" Or" Date: Thu, 31 Oct 2024 18:57:24 +0700 Subject: [PATCH] flake.nix with treefmt --- .github/workflows/ci.yml | 2 - Cargo.toml | 36 +++---- README.md | 6 ++ builder/Cargo.toml | 40 ++++---- builder/src/components/calendar/snippet.js | 89 +++++++++-------- flake.lock | 105 +++++++++++++++++++++ flake.nix | 34 +++++++ fmt.nix | 22 +++++ mobs/love.yaml | 2 +- mobs/malaga.yml | 2 +- mobs/mobile_game_dev_fridays.yaml | 2 +- mobs/mobrpg.yaml | 4 +- mobs/more.yaml | 2 +- mobs/pangolin.yaml | 1 - reactive/Cargo.toml | 10 +- shell.nix | 41 ++++---- ssg-child/Cargo.toml | 15 ++- ssg-parent/Cargo.toml | 18 ++-- systems.nix | 4 + tailwind.config.js | 6 +- 20 files changed, 308 insertions(+), 133 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 fmt.nix create mode 100644 systems.nix diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 68a1cb1e..81b31958 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,6 @@ jobs: path: ${{ steps.get_output_dir.outputs.output_dir }} outputs: output_dir: ${{ steps.get_output_dir.outputs.output_dir }} - deploy-preview: if: github.event_name == 'pull_request' needs: build @@ -70,7 +69,6 @@ jobs: message: | Branch deployed for review at: ${{ steps.deploy.outputs.URL }} - deploy-production: if: github.ref == 'refs/heads/main' needs: build diff --git a/Cargo.toml b/Cargo.toml index 26dc5ae0..8a8cc9c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,27 +1,27 @@ -[workspace] -members = ["builder"] - -[package] -name = "_" -version = "0.0.0" -edition = "2021" - -[features] -tokio_console = ["dep:console-subscriber"] - [dependencies] -anyhow = { version = "1.0.66", features = ["backtrace"] } +anyhow = {version = "1.0.66", features = ["backtrace"]} camino = "1.1.4" -chrono = { version = "0.4.19", features = ["serde"] } -clap = { version = "4.1.4", features = ["derive"] } -console-subscriber = { version = "0.1.8", optional = true } +chrono = {version = "0.4.19", features = ["serde"]} +clap = {version = "4.1.4", features = ["derive"]} +console-subscriber = {version = "0.1.8", optional = true} futures = "0.3.28" indexmap = "1.9.2" once_cell = "1.16.0" -serde = { version = "1.0.138", features = ["derive"] } +serde = {version = "1.0.138", features = ["derive"]} serde_json = "1.0.82" -ssg-parent = { version = "0.0.0", path = "ssg-parent" } +ssg-parent = {version = "0.0.0", path = "ssg-parent"} thiserror = "1.0.40" # TODO less features -tokio = { version = "1.21.0", features = ["full"] } +tokio = {version = "1.21.0", features = ["full"]} url = "2.3.1" + +[features] +tokio_console = ["dep:console-subscriber"] + +[package] +name = "_" +version = "0.0.0" +edition = "2021" + +[workspace] +members = ["builder"] diff --git a/README.md b/README.md index c6b24752..82361a16 100644 --- a/README.md +++ b/README.md @@ -17,12 +17,17 @@ $ cargo run -- --help ## Build time generated content 1. All content is generated by components. + 1. A component is a type that implements `maud::Render`. + 1. A component `Foo` and its implementations are in a module `crate::components::foo`. + 1. The `crate::components` module re-exports all the components. + 1. Components are never imported directly into scope. Instead, the `crate::components` module is brought into scope. A component `Foo` is referred to as `components::Foo`. + 1. Component fields are `pub(crate)`. No constructor methods. An example of how a component is used: @@ -33,6 +38,7 @@ $ cargo run -- --help }) } ``` + 1. Some types that implement `maud::Render` are not components. This is because they are used as HTML attribute values. The `maud::Render` trait is used for attribute values, as well. diff --git a/builder/Cargo.toml b/builder/Cargo.toml index 529cc980..33a0f23f 100644 --- a/builder/Cargo.toml +++ b/builder/Cargo.toml @@ -1,21 +1,13 @@ -[package] -name = "builder" -version = "0.0.0" -edition = "2021" - -[features] -tokio_console = ["dep:console-subscriber"] - [dependencies] -anyhow = { version = "1.0.66", features = ["backtrace"] } +anyhow = {version = "1.0.66", features = ["backtrace"]} camino = "1.1.4" -chrono = { version = "0.4.19", features = ["serde"] } -chrono-tz = { version = "0.6.1", features = ["serde"] } -clap = { version = "4.1.4", features = ["derive"] } +chrono = {version = "0.4.19", features = ["serde"]} +chrono-tz = {version = "0.6.1", features = ["serde"]} +clap = {version = "4.1.4", features = ["derive"]} comrak = "0.17.1" -console-subscriber = { version = "0.1.8", optional = true } +console-subscriber = {version = "0.1.8", optional = true} const_format = "0.2.30" -csscolorparser = { version = "0.6.0", features = ["serde"] } +csscolorparser = {version = "0.6.0", features = ["serde"]} custom_attrs = "1.6.0" derive_more = "0.99.17" futures = "0.3.28" @@ -26,15 +18,23 @@ itertools = "0.10.5" maud = "0.24.0" once_cell = "1.16.0" relative-path = "1.8.0" -rrule = { version = "0.10.0", features = ["serde"] } +rrule = {version = "0.10.0", features = ["serde"]} schema = "0.1.0" -serde = { version = "1.0.138", features = ["derive"] } +serde = {version = "1.0.138", features = ["derive"]} serde_json = "1.0.82" serde_yaml = "0.9.11" -ssg-child = { version = "0.0.0", path = "../ssg-child" } -strum = { version = "0.24.1", features = ["derive"] } -syn = { version = "2.0.5", features = ["full"] } +ssg-child = {version = "0.0.0", path = "../ssg-child"} +strum = {version = "0.24.1", features = ["derive"]} +syn = {version = "2.0.5", features = ["full"]} thiserror = "1.0.40" # TODO less features -tokio = { version = "1.21.0", features = ["full"] } +tokio = {version = "1.21.0", features = ["full"]} url = "2.3.1" + +[features] +tokio_console = ["dep:console-subscriber"] + +[package] +name = "builder" +version = "0.0.0" +edition = "2021" diff --git a/builder/src/components/calendar/snippet.js b/builder/src/components/calendar/snippet.js index 271f71e4..3e10c44e 100644 --- a/builder/src/components/calendar/snippet.js +++ b/builder/src/components/calendar/snippet.js @@ -1,67 +1,74 @@ /* global FullCalendar */ -; (function initCalendar({ events, displayEventTime, selectors }) { - window.addEventListener('DOMContentLoaded', () => { - const styleElm = document.createElement('style'); +(function initCalendar({ events, displayEventTime, selectors }) { + window.addEventListener("DOMContentLoaded", () => { + const styleElm = document.createElement("style"); document.head.append(styleElm); - styleElm.sheet.insertRule('.fc .fc-toolbar .fc-toolbar-title { font-size: inherit }') - styleElm.sheet.insertRule('.fc .fc-toolbar.fc-header-toolbar { margin-bottom: 0.5em; }') - styleElm.sheet.insertRule('.fc .fc-timegrid-slot { height: 2.5em; }') - styleElm.sheet.insertRule('.fc .fc-col-header-cell-cushion { text-decoration: none; }') + styleElm.sheet.insertRule( + ".fc .fc-toolbar .fc-toolbar-title { font-size: inherit }", + ); + styleElm.sheet.insertRule( + ".fc .fc-toolbar.fc-header-toolbar { margin-bottom: 0.5em; }", + ); + styleElm.sheet.insertRule(".fc .fc-timegrid-slot { height: 2.5em; }"); + styleElm.sheet.insertRule( + ".fc .fc-col-header-cell-cushion { text-decoration: none; }", + ); - const calendarContainerElm = document.querySelector(selectors.calendarContainer) + const calendarContainerElm = document.querySelector( + selectors.calendarContainer, + ); const calendar = new FullCalendar.Calendar(calendarContainerElm, { - initialView: 'timeGridWeek', - slotDuration: '01:00:00', + initialView: "timeGridWeek", + slotDuration: "01:00:00", expandRows: true, - dayHeaderFormat: { weekday: 'short' }, + dayHeaderFormat: { weekday: "short" }, views: { timeGridWeek: { - allDaySlot: false - } + allDaySlot: false, + }, }, events, eventContent: ({ event }) => ({ html: event.extendedProps.eventContent }), - height: 'auto', - contentHeight: 'auto', + height: "auto", + contentHeight: "auto", eventMinHeight: 40, nowIndicator: true, displayEventTime, - eventBorderColor: 'transparent', + eventBorderColor: "transparent", headerToolbar: false, stickyHeaderDates: false, - }) + }); - const dateRangeElm = document.querySelector(selectors.dateRange) - const timezoneElm = document.querySelector(selectors.timezone) + const dateRangeElm = document.querySelector(selectors.dateRange); + const timezoneElm = document.querySelector(selectors.timezone); - calendar.on('datesSet', (dateInfo) => { - const start = new Intl.DateTimeFormat().format(dateInfo.start) - const end = new Intl.DateTimeFormat().format(dateInfo.end) - dateRangeElm.textContent = `${start} – ${end}` - timezoneElm.textContent = `Time zone: ${Intl.DateTimeFormat().resolvedOptions().timeZone}` - }) + calendar.on("datesSet", (dateInfo) => { + const start = new Intl.DateTimeFormat().format(dateInfo.start); + const end = new Intl.DateTimeFormat().format(dateInfo.end); + dateRangeElm.textContent = `${start} – ${end}`; + timezoneElm.textContent = `Time zone: ${Intl.DateTimeFormat().resolvedOptions().timeZone}`; + }); - const buttonPrevElm = document.querySelector(selectors.buttonPrev) + const buttonPrevElm = document.querySelector(selectors.buttonPrev); - buttonPrevElm.addEventListener('click', () => { - calendar.prev() - }) + buttonPrevElm.addEventListener("click", () => { + calendar.prev(); + }); - const buttonNextElm = document.querySelector(selectors.buttonNext) + const buttonNextElm = document.querySelector(selectors.buttonNext); - buttonNextElm.addEventListener('click', () => { - calendar.next() - }) + buttonNextElm.addEventListener("click", () => { + calendar.next(); + }); - const buttonTodayElm = document.querySelector(selectors.buttonToday) + const buttonTodayElm = document.querySelector(selectors.buttonToday); - buttonTodayElm.addEventListener('click', () => { - calendar.today() - }) - - calendar.render() - }) -}) + buttonTodayElm.addEventListener("click", () => { + calendar.today(); + }); + calendar.render(); + }); +}); diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..66a12de1 --- /dev/null +++ b/flake.lock @@ -0,0 +1,105 @@ +{ + "nodes": { + "devshell": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1728330715, + "narHash": "sha256-xRJ2nPOXb//u1jaBnDP56M7v5ldavjbtR6lfGqSvcKg=", + "owner": "numtide", + "repo": "devshell", + "rev": "dd6b80932022cea34a019e2bb32f6fa9e494dfef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1727826117, + "narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1730272153, + "narHash": "sha256-B5WRZYsRlJgwVHIV6DvidFN7VX7Fg9uuwkRW9Ha8z+w=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2d2a9ddbe3f2c00747398f3dc9b05f7f2ebb0f53", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixpkgs-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "devshell": "devshell", + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "systems": "systems", + "treefmt-nix": "treefmt-nix" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1730321837, + "narHash": "sha256-vK+a09qq19QNu2MlLcvN4qcRctJbqWkX7ahgPZ/+maI=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "746901bb8dba96d154b66492a29f5db0693dbfcc", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..1c868211 --- /dev/null +++ b/flake.nix @@ -0,0 +1,34 @@ +{ + nixConfig.extra-experimental-features = [ "pipe-operators" ]; + + inputs = { + devshell = { + url = "github:numtide/devshell"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + flake-parts = { + url = "github:hercules-ci/flake-parts"; + inputs.nixpkgs-lib.follows = "nixpkgs"; + }; + + nixpkgs.url = "nixpkgs/nixpkgs-unstable"; + + systems.url = "github:nix-systems/default"; + + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = + inputs: + inputs.flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + ./fmt.nix + ./systems.nix + inputs.devshell.flakeModule + ]; + }; +} diff --git a/fmt.nix b/fmt.nix new file mode 100644 index 00000000..c5472fb4 --- /dev/null +++ b/fmt.nix @@ -0,0 +1,22 @@ +{ inputs, ... }: +{ + imports = [ inputs.treefmt-nix.flakeModule ]; + + perSystem.treefmt = { + projectRootFile = "flake.nix"; + programs = { + nixfmt.enable = true; + prettier.enable = true; + rustfmt.enable = true; + shfmt.enable = true; + toml-sort.enable = true; + }; + settings = { + formatter.shfmt.includes = [ "git_hooks/*" ]; + global.excludes = [ + ".editorconfig" + "LICENSE" + ]; + }; + }; +} diff --git a/mobs/love.yaml b/mobs/love.yaml index 17827801..1d7b43bf 100644 --- a/mobs/love.yaml +++ b/mobs/love.yaml @@ -24,7 +24,7 @@ freeform_copy: | status: !Open | ## Join us - + If you're interested in JavaScript, TypeScript and open source, consider applying to our mob. For more details and application, see [this gist](https://gist.github.com/mightyiam/6618d6ae649dc26ef485a21ccfe1eb3e). diff --git a/mobs/malaga.yml b/mobs/malaga.yml index cc9f3776..36a39df2 100644 --- a/mobs/malaga.yml +++ b/mobs/malaga.yml @@ -18,7 +18,7 @@ freeform_copy: | We are working on a simple way to get people collaborating by creating a global ensemble platform status: !Open | ## Join us - + No application process, we would welcome all who are able to join regardless of ruby ability. From newbies onwards. All friendly humans are welcome. Please contact [Ian](https://twitter.com/alterisian) with any questions about mobs/ensembles/flocks. Simply add your twitter handle to: [helloworld.rb](https://github.com/alterisian/helloworld/blob/main/helloworld.rb) diff --git a/mobs/mobile_game_dev_fridays.yaml b/mobs/mobile_game_dev_fridays.yaml index c4e2a9ac..d16340a7 100644 --- a/mobs/mobile_game_dev_fridays.yaml +++ b/mobs/mobile_game_dev_fridays.yaml @@ -26,7 +26,7 @@ freeform_copy: | - building our own games! status: !Open | ## Join us - + We hold our meetings on gather here: [https://app.gather.town/app/QNYoCWpW3rf8b0C5/XP%20Lounge](https://app.gather.town/app/QNYoCWpW3rf8b0C5/XP%20Lounge) See you there! diff --git a/mobs/mobrpg.yaml b/mobs/mobrpg.yaml index fbdd40cf..e3f09009 100644 --- a/mobs/mobrpg.yaml +++ b/mobs/mobrpg.yaml @@ -23,10 +23,10 @@ text_color: black freeform_copy: | ## What we do - We work on an [open source webapp](https://github.com/gregorriegler/mob-programming-rpg) for the Mob Programming RPG. + We work on an [open source webapp](https://github.com/gregorriegler/mob-programming-rpg) for the Mob Programming RPG. status: !Public | ## How to join - + Just show up. We're happy to onboard new contributors. Go to the README and check out the "[Contribute](https://github.com/gregorriegler/mob-programming-rpg/blob/main/README.md#contribute)" section. diff --git a/mobs/more.yaml b/mobs/more.yaml index 6847d954..55e0858b 100644 --- a/mobs/more.yaml +++ b/mobs/more.yaml @@ -39,7 +39,7 @@ freeform_copy: | status: !Open | ## Join us - + If you're interested in levelling up your software development and Rust skills, consider joining us. For more details and application, see [this gist](https://gist.github.com/mightyiam/6618d6ae649dc26ef485a21ccfe1eb3e). diff --git a/mobs/pangolin.yaml b/mobs/pangolin.yaml index 4136e15f..f3dbd72c 100644 --- a/mobs/pangolin.yaml +++ b/mobs/pangolin.yaml @@ -29,4 +29,3 @@ freeform_copy: | This includes some advanced topics such as futures, streams and reactive programming. status: !Terminated - diff --git a/reactive/Cargo.toml b/reactive/Cargo.toml index 245f7e60..b3baca59 100644 --- a/reactive/Cargo.toml +++ b/reactive/Cargo.toml @@ -1,10 +1,10 @@ -[package] -name = "reactive" -version = "0.1.0" -edition = "2021" - [dependencies] futures = "0.3.28" notify = "6.1.1" open = "5.0.0" tokio = "1.29.1" + +[package] +name = "reactive" +version = "0.1.0" +edition = "2021" diff --git a/shell.nix b/shell.nix index 373b8210..a7c517f6 100644 --- a/shell.nix +++ b/shell.nix @@ -1,4 +1,7 @@ -{pkgs ? import {}}: let +{ + pkgs ? import { }, +}: +let pipe = pkgs.lib.trivial.pipe; toUpper = pkgs.lib.strings.toUpper; replaceStrings = builtins.replaceStrings; @@ -7,25 +10,25 @@ targetTriple = "x86_64-unknown-linux-gnu"; envTargetTriple = pipe targetTriple [ toUpper - (replaceStrings ["-"] ["_"]) + (replaceStrings [ "-" ] [ "_" ]) ]; in - pkgs.mkShell { - nativeBuildInputs = with pkgs; [ - tokio-console - rustup - mob - nodejs-18_x - nodePackages.typescript-language-server - nodePackages.typescript - ]; +pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + tokio-console + rustup + mob + nodejs-18_x + nodePackages.typescript-language-server + nodePackages.typescript + ]; - CARGO_BUILD_TARGET = targetTriple; - "CARGO_TARGET_${envTargetTriple}_LINKER" = "${pkgs.clang}/bin/clang"; - RUSTFLAGS = concatStringsSep " " [ - "--codegen link-arg=-fuse-ld=${pkgs.mold}/bin/mold" - "--cfg tokio_unstable" - ]; + CARGO_BUILD_TARGET = targetTriple; + "CARGO_TARGET_${envTargetTriple}_LINKER" = "${pkgs.clang}/bin/clang"; + RUSTFLAGS = concatStringsSep " " [ + "--codegen link-arg=-fuse-ld=${pkgs.mold}/bin/mold" + "--cfg tokio_unstable" + ]; - MOB_TIMER_ROOM = "mobusoperandi_website"; - } + MOB_TIMER_ROOM = "mobusoperandi_website"; +} diff --git a/ssg-child/Cargo.toml b/ssg-child/Cargo.toml index 796404cc..aa4c9eb2 100644 --- a/ssg-child/Cargo.toml +++ b/ssg-child/Cargo.toml @@ -1,8 +1,3 @@ -[package] -name = "ssg-child" -version = "0.0.0" -edition = "2021" - [dependencies] async-trait = "0.1.64" camino = "1.1.4" @@ -15,12 +10,16 @@ lazy-regex = "2.5.0" once_cell = "1.17.1" readext = "0.1.0" relative-path = "1.8.0" -reqwest = { version = "0.11.11", default-features = false, features = ["rustls-tls"] } +reqwest = {version = "0.11.11", default-features = false, features = ["rustls-tls"]} reqwest-middleware = "0.2.0" task-local-extensions = "0.1.3" thiserror = "1.0.38" # TODO less features -tokio = { version = "1.21.0", features = ["fs", "tokio-macros", "full"] } +tokio = {version = "1.21.0", features = ["fs", "tokio-macros", "full"]} url = "2.3.1" -zip = { version = "0.6.2", default-features = false, features = ["deflate"] } +zip = {version = "0.6.2", default-features = false, features = ["deflate"]} +[package] +name = "ssg-child" +version = "0.0.0" +edition = "2021" diff --git a/ssg-parent/Cargo.toml b/ssg-parent/Cargo.toml index f131a506..d3cf9a8b 100644 --- a/ssg-parent/Cargo.toml +++ b/ssg-parent/Cargo.toml @@ -1,21 +1,21 @@ -[package] -name = "ssg-parent" -version = "0.0.0" -edition = "2021" - [dependencies] async-trait = "0.1.64" camino = "1.1.4" colored = "2.0.0" -derive_more = { version = "1.0.0-beta.3", features = ["debug"] } +derive_more = {version = "1.0.0-beta.3", features = ["debug"]} futures = "0.3.28" live-server = "0.6.0" once_cell = "1.17.1" open = "4.1.0" portpicker = "0.1.1" -reactive = { version = "0.1.0", path = "../reactive" } -reqwest = { version = "0.11.11", default-features = false, features = ["rustls-tls"] } +reactive = {version = "0.1.0", path = "../reactive"} +reqwest = {version = "0.11.11", default-features = false, features = ["rustls-tls"]} thiserror = "1.0.38" # TODO less features -tokio = { version = "1.21.0", features = ["fs", "tokio-macros", "full"] } +tokio = {version = "1.21.0", features = ["fs", "tokio-macros", "full"]} url = "2.3.1" + +[package] +name = "ssg-parent" +version = "0.0.0" +edition = "2021" diff --git a/systems.nix b/systems.nix new file mode 100644 index 00000000..aa9cd586 --- /dev/null +++ b/systems.nix @@ -0,0 +1,4 @@ +{ inputs, ... }: +{ + systems = import inputs.systems; +} diff --git a/tailwind.config.js b/tailwind.config.js index bde5a96f..f7d8a60c 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,5 +1,3 @@ module.exports = { - plugins: [ - require('@tailwindcss/typography') - ] -} + plugins: [require("@tailwindcss/typography")], +};