Skip to content

Commit

Permalink
Merge pull request #4 from djacu/meta/add-website
Browse files Browse the repository at this point in the history
meta/add website
  • Loading branch information
djacu authored Feb 9, 2024
2 parents 45e9069 + c98f2c8 commit 628ec75
Show file tree
Hide file tree
Showing 10 changed files with 1,562 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/netlify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# .github/workflows/netlify.yml
name: Build and Deploy to Netlify

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Nix
uses: cachix/install-nix-action@v22
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Cachix
uses: cachix/cachix-action@v14
with:
name: djacu-nixos-modules-lessons
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- name: Build Site
run: |
nix build .#site
mkdir ./dist
cp -R ./result/* ./dist/
chmod -R +w ./dist/
- name: Deploy to Netlify
uses: nwtgck/[email protected]
with:
publish-dir: './dist'
production-branch: main
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Deploy from GitHub Actions"
enable-pull-request-comment: true
enable-commit-comment: true
enable-commit-status: true
overwrites-pull-request-comment: true
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### Nix ###
result

### Mkdocs ###
site/.cache

### Site ###
# Lessons are built during nix build
site/docs/lessons
144 changes: 144 additions & 0 deletions flake.lock

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

92 changes: 92 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
description = "LaTeX Document Demo";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
poetry2nix.url = "github:nix-community/poetry2nix";
poetry2nix.inputs.flake-utils.follows = "flake-utils";
poetry2nix.inputs.nixpkgs.follows = "nixpkgs";
};

outputs = {
self,
nixpkgs,
flake-utils,
poetry2nix,
}:
flake-utils.lib.eachSystem ["x86_64-linux"] (system: let
pkgs = nixpkgs.legacyPackages.${system};
lib = pkgs.lib;
inherit
(poetry2nix.lib.mkPoetry2Nix {inherit pkgs;})
mkPoetryEnv
;

lessonsLib = import ./lib/lessons.nix {inherit self pkgs lib;};

site-env = mkPoetryEnv {
projectDir = self + /site;
python = pkgs.python311;
};

lessonsDocumentation = lessonsLib.generateLessonsDocumentation {lessonsPath = ./lessons;};

site = pkgs.stdenvNoCC.mkDerivation {
name = "modules-lessons-site";
src = self + "/site";
nativeBuildInputs = [site-env];

buildPhase = ''
cp -r ${lessonsDocumentation}/* ./docs/
mkdir -p .cache/plugin/social
cp ${pkgs.roboto}/share/fonts/truetype/Roboto-* .cache/plugin/social/
mkdocs build --site-dir dist
'';
installPhase = ''
mkdir $out
cp -R dist/* $out/
'';
};
in {
devShells = {
poetry = pkgs.mkShell {
packages = [
pkgs.poetry
pkgs.python311
];
};
site = pkgs.mkShell {
buildInputs = [
pkgs.poetry
site-env
];
};
};
packages =
{
}
// {
inherit
site
lessonsDocumentation
;
};

apps = {
copyLessonsToSite = {
type = "app";
program = "${lessonsLib.copyLessonsToSite}/bin/copy-lessons-to-site";
};
};

checks =
{}
// {
inherit
site
;
};

inherit lessonsLib;
});
}
2 changes: 2 additions & 0 deletions lessons/010-basic-types/lesson.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Notice in the [config][config] file, we have declared values for all these optio

If you execute the run file (`./run`), you should see an output that matches what we have configured.

[//]: # (evaluatedLesson)

[nixos-manual-basic-types]: https://nixos.org/manual/nixos/stable/#sec-option-types
[options]: ./options.nix
[config]: ./config.nix
Loading

1 comment on commit 628ec75

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.