From 9144fe4fb3b1d11e24441d54f55a26651cc3a8fa Mon Sep 17 00:00:00 2001 From: hiroqn Date: Mon, 5 Jan 2026 02:26:25 +0900 Subject: [PATCH 1/2] init --- .github/workflows/deploy.yaml | 25 ++++++++++++++ calendar.nix | 51 +++++++++++++++++++++++++++++ flake.lock | 61 +++++++++++++++++++++++++++++++++++ flake.nix | 42 ++++++++++++++++++++++++ packages/toml-to-ical.nix | 11 +++++++ 5 files changed, 190 insertions(+) create mode 100644 .github/workflows/deploy.yaml create mode 100644 calendar.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 packages/toml-to-ical.nix diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..1377fb6 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,25 @@ +--- +on: + push: + branches: + - init +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: cachix/install-nix-action@v31 + - run: nix build + - id: deployment + uses: actions/upload-pages-artifact@v4 + with: + path: result/ + deploy: + needs: build + runs-on: ubuntu-latest + permissions: + pages: write + id-token: write + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/calendar.nix b/calendar.nix new file mode 100644 index 0000000..01856ee --- /dev/null +++ b/calendar.nix @@ -0,0 +1,51 @@ +{ config, lib, ... }: +let + event = + with lib.types; + submodule { + options = { + uid = mkOption { + type = str; + }; + title = mkOption { + type = str; + }; + last_modified_on = mkOption { + type = str; + }; + start = mkOption { + type = str; + }; + end = mkOption { + type = str; + }; + }; + }; +in +{ + options.calendar.events = lib.mkOption { + type = lib.types.listOf event; + default = [ ]; + }; + + config = { + perSystem = + { + pkgs, + ... + }: + let + calendarTOML = pkgs.writers.writeTOML "calendar.toml" { + name = "nix-ja calendar"; + description = "Nix-ja event calendar"; + events = config.calendar.events; + }; + in + { + packages.calendar = pkgs.runCommand "calendar.ics" { } '' + mkdir -p $out + ${pkgs.toml-to-ical}/bin/toml-to-ical --input ${calendarTOML} --output $out/calendar.ics + ''; + }; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..9dd743b --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1765835352, + "narHash": "sha256-XswHlK/Qtjasvhd1nOa1e8MgZ8GS//jBoTqWtrS1Giw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "a34fae9c08a15ad73f295041fec82323541400a9", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1767379071, + "narHash": "sha256-EgE0pxsrW9jp9YFMkHL9JMXxcqi/OoumPJYwf+Okucw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fb7944c166a3b630f177938e478f0378e64ce108", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1765674936, + "narHash": "sha256-k00uTP4JNfmejrCLJOwdObYC9jHRrr/5M/a/8L2EIdo=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "2075416fcb47225d9b68ac469a5c4801a9c4dd85", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f587228 --- /dev/null +++ b/flake.nix @@ -0,0 +1,42 @@ +{ + description = "nix-ja website"; + + inputs = { + flake-parts.url = "github:hercules-ci/flake-parts"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = + inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + ./calendar.nix + ]; + systems = [ + "x86_64-linux" + "aarch64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; + perSystem = + { system, ... }: + let + overlay = final: prev: { + toml-to-ical = prev.callPackage ./packages/toml-to-ical.nix { }; + }; + pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ + overlay + ]; + }; + in + { + _module.args.pkgs = pkgs; + formatter = pkgs.nixfmt-tree; + packages.toml-to-ical = pkgs.toml-to-ical; + }; + flake = { + }; + }; +} diff --git a/packages/toml-to-ical.nix b/packages/toml-to-ical.nix new file mode 100644 index 0000000..2ad6be1 --- /dev/null +++ b/packages/toml-to-ical.nix @@ -0,0 +1,11 @@ +{ rustPlatform, fetchFromGitHub }: +rustPlatform.buildRustPackage { + name = "toml-to-ical"; + src = fetchFromGitHub { + owner = "rust-lang"; + repo = "calendar-generation"; + rev = "9bf0ccb9a892094fa232843a31b9c7a441645ffb"; + sha256 = "sha256-UYq5Nsg6JdFw5yhKnSCW5diaweYbGvkCnIuY98wjxvo="; + }; + cargoHash = "sha256-eg1IgW8f8iwryh1EvqnWOmehoJ1aAxuYJRbTgUE/zZ8="; +} From 1265f981e49f87fcad85fe5023544969e98a7cab Mon Sep 17 00:00:00 2001 From: hiroqn Date: Mon, 5 Jan 2026 02:29:28 +0900 Subject: [PATCH 2/2] update ci --- .github/workflows/deploy.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 1377fb6..e127bbc 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -8,7 +8,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: cachix/install-nix-action@v31 - - run: nix build + - uses: actions/checkout@v6 + - run: nix build .#calendar - id: deployment uses: actions/upload-pages-artifact@v4 with: