Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
on:
push:
branches:
- init
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: cachix/install-nix-action@v31
- uses: actions/checkout@v6
- run: nix build .#calendar
- 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
51 changes: 51 additions & 0 deletions calendar.nix
Original file line number Diff line number Diff line change
@@ -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
'';
};
};
}
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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 = {
};
};
}
11 changes: 11 additions & 0 deletions packages/toml-to-ical.nix
Original file line number Diff line number Diff line change
@@ -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=";
}