Initial commit.

pull/2/head
Joshua Potter 2024-02-01 07:34:27 -07:00
commit 7b93f02375
28 changed files with 69420 additions and 0 deletions

7
.envrc Normal file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
if command -v git > /dev/null && on_git_branch; then
git config --local core.hooksPath .githooks/
fi
use flake

40
README.md Normal file
View File

@ -0,0 +1,40 @@
# Wiki
This is a collection of notes. We use [Quartz](https://quartz.jzhao.xyz/) to
transform Markdown content into a statically generated site. Markdown files are
primarily managed with [Obsidian](https://obsidian.md/). To serve Quartz
locally, run the following:
```bash
$ npx quartz build --serve
```
By default the server will live at `localhost:8080`.
## Building
If you make changes to the `package-lock.json` file, you'll need to update the
`npmDepsHash` value in `flake.nix`. The easiest way to discover this value is
by running the following:
```bash
$ prefetch-npm-deps package-lock.json
```
Alternatively, you can set the value of `npmDepsHash` to `lib.fakeHash` and run:
```bash
$ nix build
```
Nix will complain with the hash value it actually expected.
## Language Server
The [typescript-language-server](https://github.com/typescript-language-server/typescript-language-server)
(version 4.1.2) is included in this flake.
## Formatting
Formatting depends on [prettier](https://prettier.io/) (version 3.1.0). A
`pre-commit` hook is included in `.githooks` that can be used to format all
`*.jsx?` and `*.tsx?` files prior to commit. Install via:
```bash
$ git config --local core.hooksPath .githooks/
```
If running [direnv](https://direnv.net/), this hook is installed automatically
when entering the directory.

View File

@ -0,0 +1,3 @@
{
"alwaysUpdateLinks": true
}

View File

@ -0,0 +1,3 @@
[
"obsidian-to-anki-plugin"
]

View File

@ -0,0 +1,30 @@
{
"file-explorer": true,
"global-search": true,
"switcher": true,
"graph": true,
"backlink": true,
"canvas": true,
"outgoing-link": true,
"tag-pane": true,
"properties": false,
"page-preview": true,
"daily-notes": true,
"templates": true,
"note-composer": true,
"command-palette": true,
"slash-command": false,
"editor-status": true,
"bookmarks": true,
"markdown-importer": false,
"zk-prefixer": false,
"random-note": false,
"outline": true,
"word-count": true,
"slides": false,
"audio-recorder": false,
"workspaces": false,
"file-recovery": true,
"publish": false,
"sync": false
}

View File

@ -0,0 +1,20 @@
[
"file-explorer",
"global-search",
"switcher",
"graph",
"backlink",
"canvas",
"outgoing-link",
"tag-pane",
"page-preview",
"daily-notes",
"templates",
"note-composer",
"command-palette",
"editor-status",
"bookmarks",
"outline",
"word-count",
"file-recovery"
]

View File

@ -0,0 +1,5 @@
{
"folder": "journal/",
"template": "templates/daily",
"autorun": true
}

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1,117 @@
{
"settings": {
"CUSTOM_REGEXPS": {
"Basic": "",
"Basic (and reversed card)": "",
"Basic (optional reversed card)": "",
"Cloze": "",
"Image Occlusion": "",
"Image Occlusion Enhanced": ""
},
"FILE_LINK_FIELDS": {
"Basic": "Reference",
"Basic (and reversed card)": "Front",
"Basic (optional reversed card)": "Front",
"Cloze": "Reference",
"Image Occlusion": "Occlusion",
"Image Occlusion Enhanced": "ID (hidden)"
},
"CONTEXT_FIELDS": {
"Basic": "Context",
"Cloze": "Context"
},
"FOLDER_DECKS": {
"Linux": "",
"linux": ""
},
"FOLDER_TAGS": {
"Linux": "",
"linux": ""
},
"Syntax": {
"Begin Note": "%%ANKI",
"End Note": "END%%",
"Begin Inline Note": "STARTI",
"End Inline Note": "ENDI",
"Target Deck Line": "TARGET DECK",
"File Tags Line": "FILE TAGS",
"Delete Note Line": "DELETE",
"Frozen Fields Line": "FROZEN"
},
"Defaults": {
"Scan Directory": "",
"Tag": "",
"Deck": "Obsidian",
"Scheduling Interval": 0,
"Add File Link": false,
"Add Context": true,
"CurlyCloze": true,
"CurlyCloze - Highlights to Clozes": true,
"ID Comments": true,
"Add Obsidian Tags": true
},
"IGNORED_FILE_GLOBS": [
"**/*.excalidraw.md"
]
},
"Added Media": [],
"File Hashes": {
"index.md": "e48e895feeed7046425bb2ee15419770",
"Linux/Signals.md": "f58f1a36a9fe53928fdc3dc02fc4c3e3",
"linux/index.md": "6e50c924ee9e09294fd3b907fbdeaf0f",
"linux/signals.md": "e9ab74723981ebc232189c84d3b0da74",
"templates/daily.md": "0f22c7ef0b0f35efada88d61c95e9815",
"daily/2024-01-31.md": "72e343cef8d56e169cac7b360a88fcf0",
"posix/index.md": "f7b1ae55f8f5e8f50f89738b1aca9111",
"posix/signals.md": "26161c6a79a0c413032c6c17e460412c",
"gawk.md": "9bf70ef138a9a281b86400aee393cae7",
"bash/index.md": "3b5296277f095acdf16655adcdf524af",
"bash/shebang.md": "bc30f75bcddff59d6f907fae89c17283",
"bash/robustness.md": "e474fd33469fc393bfde45cd7b9411ba"
},
"fields_dict": {
"Basic": [
"Front",
"Back",
"Reference",
"Context"
],
"Basic (and reversed card)": [
"Front",
"Back",
"Reference"
],
"Basic (optional reversed card)": [
"Front",
"Back",
"Reference",
"Add Reverse"
],
"Cloze": [
"Text",
"Reference",
"Context"
],
"Image Occlusion": [
"Occlusion",
"Image",
"Header",
"Back Extra",
"Comments"
],
"Image Occlusion Enhanced": [
"ID (hidden)",
"Header",
"Image",
"Question Mask",
"Footer",
"Remarks",
"Sources",
"Extra 1",
"Extra 2",
"Answer Mask",
"Original Mask",
"Reference"
]
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,10 @@
{
"id": "obsidian-to-anki-plugin",
"name": "Obsidian_to_Anki",
"version": "3.6.0",
"minAppVersion": "0.9.20",
"description": "This is an Anki integration plugin! Designed for efficient bulk exporting.",
"author": "Pseudonium",
"authorUrl": "https://github.com/Pseudonium/Obsidian_to_Anki",
"isDesktopOnly": true
}

View File

@ -0,0 +1,19 @@
.anki-settings-table td, .anki-settings-table th {
border: 1px solid var(--background-modifier-border);
padding: 4px 10px;
}
.anki-settings-table {
border-collapse: collapse;
display: none;
}
.anki-center {
margin: auto;
padding: 5px;
padding-top: 30px;
}
.anki-rotated {
transform: rotate(-90deg);
}

View File

@ -0,0 +1,3 @@
{
"folder": "templates"
}

View File

@ -0,0 +1,8 @@
{
"types": {
"aliases": "aliases",
"cssclasses": "multitext",
"tags": "tags",
"title": "text"
}
}

3
content/bash/index.md Normal file
View File

@ -0,0 +1,3 @@
---
title: Bash
---

View File

@ -0,0 +1,58 @@
---
title: Measuring Command Robustness
TARGET DECK: Obsidian::STEM
FILE TAGS: bash
tags:
- bash
- shell
---
An interesting point Robbins[^robbins] discusses in his introduction to [[gawk]] is this idea of command robustness. He states that:
> A self-contained shell script is more reliable because there are no other files to misplace.
%%ANKI
Basic
What is a self-contained shell script?
Back: A shell script that does not rely on the presence of other files.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911473-->
END%%
%%ANKI
Basic
What makes a self-contained shell script more reliable?
Back: There are no other files to misplace.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911475-->
END%%
The point he is arguing is that the first command below is considered more robust than the second since the command is more loosely coupled to its environment:
```bash
$ awk 'program' input-file1 input-file2 ...
$ awk -f program-file input-file1 input-file2 ...
```
It's interesting to think what else can be used as a measure of a command's robustness:
* Required environment variables or environment variables formatted in a certain way
* `$PATH` needs to point to a specific location
* Whether the invoked program is present by default in a distribution or must be installed
* The ability to run with or without an associated TTY
* The ability to run with or without associated standard streams
* `stdout`, `stderr`, `stdin`
* How backwards compatible the invoked program is
* Version mismatch may silently cause the same invocation to fail
* Expected permissions
* EUID, read permissions on an input file, etc.
* Determinism of the program itself
* Does output rely entirely on input or can it make nondeterministic choices
* The amount of resources dedicated to the program
* Failure may occur if not enough memory is provided to the command
* Whether a program acts idempotently
* What happens if I run the command twice in a row?
* Whether a program acts atomically
* Is it possible intermediate files are left that affect subsequent runs?
[^robbins]: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)

55
content/bash/shebang.md Normal file
View File

@ -0,0 +1,55 @@
---
title: Shebang
TARGET DECK: Obsidian::STEM
FILE TAGS: bash
tags:
- bash
---
The shebang (also writting shabang or sha-bang) is a magic character at the start of a script indicating what command should be run when invoking the script directly. It always begins with ASCII characters `#!`.[^mendel]
%%ANKI
Basic
What ASCII characters do shebangs start with?
Back: `#!`
Reference: Cooper, Mendel. “Advanced Bash-Scripting Guide,” n.d., 916.
<!--ID: 1706726911458-->
END%%
%%ANKI
Basic
What class of programs can be specified in a shebang?
Back: Interpreters
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911461-->
END%%
%%ANKI
Basic
The OS will parse a shebang into what three parts?
Back: `#!`, the interpreter, and the rest of the line as a single argument.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911464-->
END%%
%%ANKI
Basic
What gotcha does Robbins highlight with shebang parsing?
Back: The remainder of the line following the interpreter is passed as a *single* argument.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911467-->
END%%
Some systems limit the length of interpreters to just 32 characters. A simple workaround when encountering this limitation is to introduce a symbolic link.
%%ANKI
Basic
What workaround is used when shabang interpreter names are too long?
Back: Introduce a symbolic link.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911470-->
END%%
[^mendel]: Cooper, Mendel. “Advanced Bash-Scripting Guide,” n.d., 916.
[^robbins]: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)

86
content/gawk.md Normal file
View File

@ -0,0 +1,86 @@
---
title: GAWK
TARGET DECK: Obsidian::STEM
FILE TAGS: linux::cli gawk
tags:
- linux
- cli
- gawk
---
## Introduction
%%ANKI
Basic
How was the name `awk` derived?
Back: By taking the first initials of the original three creators.
<!--ID: 1706726911434-->
END%%
%%ANKI
Basic
What does the term `awk` refer to?
Back: Both the `awk` program and the `awk` language.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911439-->
END%%
> Dark corners are basically fractal - no matter how much you illuminate, there's always a smaller but darker one.
The above quote is attributed to Brian Kernighan (one of the authors of the [[C]] K&R book).
%%ANKI
Cloze
Dark corners are basically {1:fractal} - {1:no matter how much you illuminate, there's always a smaller but darker one.} - Brian Kernighan
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911442-->
END%%
## Setup
Robbins[^robbins] suggests executing command `set +H` on [[bash]] startup to disable [[C]] shell-style command history.
## Usage
`awk` applies actions to lines matching specified patterns. In this way `awk` is said to be data-driven - we specify the lines `awk` should act on and `awk` is responsible for finding and acting on them. Instructions are provided via a **program**.
%%ANKI
Basic
What is the basic function of `awk`?
Back: To apply actions to lines matching specified patterns.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911445-->
END%%
An `awk` program consists of **rules**, each made up by a **pattern** and **action**. For example:
```awk
BEGIN { print "hello world" }
pattern { action }
```
%%ANKI
Basic
An `awk` program consists of a series of what?
Back: Rules.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911448-->
END%%
%%ANKI
Basic
A rule found in an `awk` program consists of what two parts?
Back: A pattern and an action.
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911451-->
END%%
%%ANKI
Basic
A standalone `awk` program usually has what shebang?
Back: `#!/bin/awk -f`
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
<!--ID: 1706726911454-->
END%%
[^robbins]: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)

5
content/index.md Normal file
View File

@ -0,0 +1,5 @@
---
title: About
---
Welcome to my personal notes. This is home for content I want to save or later reference that has no other obvious place to go. This site is generated with [Quartz](https://quartz.jzhao.xyz/). I primarily use [Obsidian](https://obsidian.md/) to edit the files found throughout.

View File

@ -0,0 +1,18 @@
---
title: "2024-01-31"
---
- [x] Anki Flashcards
- [x] KoL
- [x] Sheet Music (10 min.)
- [x] OGS (1 Life & Death Problem)
- [x] Korean (Read 1 Story)
- [x] Interview Prep (1 Practice Problem)
- [x] Log Work Hours (Max 3 hours)
* Spent time today getting FSRS enabled in Anki. I now have a separate "Obsidian" deck that I'll slowly be transferring cards over, with all cards generated from this project.
* Last night and continuing today, will also been migrating all my Zotero references to a new "Obsidian" collection. The goal is to be more mindful as to how I consume the content and create cards/take notes.
* Began working through "GAWK: Effective AWK Programming" by Arnold D. Robbins. This inspired some notes around shell commands and what it means for them to be [[robustness|robust]].
* Watched the following video on Go: [I'm Learning Strategy from this Go Book](https://www.youtube.com/watch?v=eXaScCrLPDI)
* Finished watching [05 - Columnar Databases & Compression](https://www.youtube.com/watch?v=q4W5r3GR0OU)
* Solved LeetCode problem [Reverse Integer](https://leetcode.com/problems/reverse-integer/).

3
content/posix/index.md Normal file
View File

@ -0,0 +1,3 @@
---
title: POSIX
---

115
content/posix/signals.md Normal file
View File

@ -0,0 +1,115 @@
---
title: Signals
TARGET DECK: Obsidian::STEM
FILE TAGS: posix::signal
tags:
- posix
- signal
---
This is an overview of specific POSIX signals.[^dowling]
Code | Name
----- | --------------
1 | SIGHUP
2 | SIGINT
4 | SIGILL
6 | SIGABRT
7 | SIGBUS
8 | SIGFPE
9 | SIGKILL
11 | SIGSEGV
13 | SIGPIPE
15 | SIGTERM
## Details
%%ANKI
Basic
What command can we run to access the official manual page for signals?
Back: `man 7 signal`
Reference: Dowling, “A List of Signals and What They Mean.”
Tags: linux::cli
<!--ID: 1706668253908-->
END%%
### SIGHUP (1)
A process receives a `SIGHUP` signal when the terminal it is attached to goes away before it finishes executing.
%%ANKI
Cloze
Signal {`SIGHUP`} corresponds to number {1}.
Reference: Dowling, “A List of Signals and What They Mean.”
<!--ID: 1706668531417-->
END%%
%%ANKI
Basic
What is the `HUP` in `SIGHUP` an acronym for?
Back: **H**ang **up**
Reference: Dowling, “A List of Signals and What They Mean.”
<!--ID: 1706669687254-->
END%%
%%ANKI
Basic
When does a process receive a `SIGHUP` signal?
Back: When the terminal it is attached to disappears before it finishes execution.
Reference: Dowling, “A List of Signals and What They Mean.”
<!--ID: 1706669687261-->
END%%
%%ANKI
Basic
What historical context led to `SIGHUP`'s name?
Back: This name refers to hanging up the telephone in the days of telephone modems.
Reference: Dowling, “A List of Signals and What They Mean.”
<!--ID: 1706669687266-->
END%%
%%ANKI
Basic
What command is used to make a program immune to `SIGHUP` signals?
Back: `nohup`
Reference: `man 1 nohup`
Tags: linux::cli
<!--ID: 1706670390877-->
END%%
%%ANKI
Basic
If a `nohup` program's `stdin` is a terminal, where is its input redirected from?
Back: An unreadable file.
Reference: `man 1 nohup`
Tags: linux::cli
<!--ID: 1706670390904-->
END%%
%%ANKI
Basic
If a `nohup` program's `stdout` is a terminal, where is its output redirected to?
Back: `nohup.out` if possible, `$HOME/nohup.out` otherwise.
Reference: `man 1 nohup`
Tags: linux::cli
<!--ID: 1706670390909-->
END%%
%%ANKI
Basic
If a `nohup` program's `stderr` is a terminal, where is its errors redirected to?
Back: `stdout`
Reference: `man 1 nohup`
Tags: linux::cli
<!--ID: 1706670390913-->
END%%
%%ANKI
Basic
What command can be run to view all processes that would receive a `SIGHUP` when the current terminal exits?
Back: `ps T`
Reference: `man 1 ps`
<!--ID: 1706670390919-->
END%%
[^dowling]: Dowling, “A List of Signals and What They Mean.”

View File

@ -0,0 +1,11 @@
---
title: "{{date:YYYY-MM-DD}}"
---
- [ ] Anki Flashcards
- [ ] KoL
- [ ] Sheet Music (10 min.)
- [ ] OGS (1 Life & Death Problem)
- [ ] Korean (Read 1 Story)
- [ ] Interview Prep (1 Practice Problem)
- [ ] Log Work Hours (Max 3 hours)

10
default.nix Normal file
View File

@ -0,0 +1,10 @@
(import
(
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
fetchTarball {
url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{ src = ./.; }
).defaultNix

76
flake.lock Normal file
View File

@ -0,0 +1,76 @@
{
"nodes": {
"flake-compat": {
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"revCount": 57,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1705309234,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1706371002,
"narHash": "sha256-dwuorKimqSYgyu8Cw6ncKhyQjUDOyuXoxDTVmAXq88s=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c002c6aa977ad22c60398daaa9be52f2203d0006",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

72
flake.nix Normal file
View File

@ -0,0 +1,72 @@
{
description = ''
A collection of my notes.
Uses [Quartz](https://quartz.jzhao.xyz/) to transform Markdown content into
a statically generated site. Markdown files are primarily managed with
[Obsidian](https://obsidian.md/).
'';
inputs = {
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
quartz = {
src = pkgs.fetchFromGitHub {
owner = "jrpotter";
repo = "quartz";
rev = "e2e1053fd45586c19829be224008673b17111e6b";
hash = pkgs.lib.fakeHash;
};
nodeDependencies = (pkgs.callPackage ./quartz {}).nodeDependencies;
};
in
{
packages = {
app = pkgs.stdenv.mkDerivation {
pname = "notebook";
version = "0.1.0";
src = ./.;
nativeBuildInputs = [ pkgs.nodejs ];
buildPhase = ''
cp -r ${quartz.src} quartz
cd quartz
find -type f -execdir chmod 644 {} +
find -type d -execdir chmod 755 {} +
ln -s ${quartz.nodeDependencies}/lib/node_modules ./node_modules
export PATH="${quartz.nodeDependencies}/bin:$PATH"
# export npm_config_cache=$PWD
# npx quartz build
'';
installPhase = ''
mkdir $out
'';
};
default = self.packages.${system}.app;
};
devShells.default = pkgs.mkShell {
packages = with pkgs; [
node2nix
nodePackages.prettier
nodePackages.typescript-language-server
nodejs
prefetch-npm-deps
typescript
];
};
});
}

84
quartz.config.ts Normal file
View File

@ -0,0 +1,84 @@
import { QuartzConfig } from "./quartz/cfg"
import * as Plugin from "./quartz/plugins"
const config: QuartzConfig = {
configuration: {
pageTitle: "My Notebook",
enableSPA: true,
enablePopovers: true,
analytics: {
provider: "plausible",
},
baseUrl: "wiki.jrpotter.com",
ignorePatterns: [
".obsidian",
"journal",
"private",
"templates",
],
defaultDateType: "created",
theme: {
typography: {
header: "Schibsted Grotesk",
body: "Source Sans Pro",
code: "IBM Plex Mono",
},
colors: {
lightMode: {
light: "#faf8f8",
lightgray: "#e5e5e5",
gray: "#b8b8b8",
darkgray: "#4e4e4e",
dark: "#2b2b2b",
secondary: "#284b63",
tertiary: "#84a59d",
highlight: "rgba(143, 159, 169, 0.15)",
},
darkMode: {
light: "#161618",
lightgray: "#393639",
gray: "#646464",
darkgray: "#d4d4d4",
dark: "#ebebec",
secondary: "#7b97aa",
tertiary: "#84a59d",
highlight: "rgba(143, 159, 169, 0.15)",
},
},
},
},
plugins: {
transformers: [
Plugin.FrontMatter(),
Plugin.TableOfContents(),
Plugin.CreatedModifiedDate({
// you can add 'git' here for last modified from Git
// if you do rely on git for dates, ensure defaultDateType is 'modified'
priority: ["frontmatter", "filesystem"],
}),
Plugin.Latex({ renderEngine: "katex" }),
Plugin.SyntaxHighlighting(),
Plugin.ObsidianFlavoredMarkdown(),
Plugin.GitHubFlavoredMarkdown(),
Plugin.CrawlLinks({ markdownLinkResolution: "shortest" }),
Plugin.Description(),
],
filters: [Plugin.RemoveDrafts()],
emitters: [
Plugin.AliasRedirects(),
Plugin.ComponentResources({ fontOrigin: "googleFonts" }),
Plugin.ContentPage(),
Plugin.FolderPage(),
Plugin.TagPage(),
Plugin.ContentIndex({
enableSiteMap: true,
enableRSS: true,
}),
Plugin.Assets(),
Plugin.Static(),
Plugin.NotFoundPage(),
],
},
}
export default config

52
quartz.layout.ts Normal file
View File

@ -0,0 +1,52 @@
import { PageLayout, SharedLayout } from "./quartz/cfg"
import * as Component from "./quartz/components"
// components shared across all pages
export const sharedPageComponents: SharedLayout = {
head: Component.Head(),
header: [
Component.MobileOnly(Component.Explorer()),
],
footer: Component.Footer({
links: {
Git: "https://git.jrpotter.com/r/wiki",
},
}),
}
// components for pages that display a single page (e.g. a single note)
export const defaultContentPageLayout: PageLayout = {
beforeBody: [
Component.Breadcrumbs(),
Component.ArticleTitle(),
Component.ContentMeta(),
Component.TagList(),
],
left: [
Component.PageTitle(),
Component.MobileOnly(Component.Spacer()),
Component.Search(),
Component.DesktopOnly(Component.Explorer()),
],
right: [
Component.Graph(),
Component.DesktopOnly(Component.TableOfContents()),
Component.Backlinks(),
],
}
// components for pages that display lists of pages (e.g. tags or folders)
export const defaultListPageLayout: PageLayout = {
beforeBody: [
Component.Breadcrumbs(),
Component.ArticleTitle(),
Component.ContentMeta(),
],
left: [
Component.PageTitle(),
Component.MobileOnly(Component.Spacer()),
Component.Search(),
Component.DesktopOnly(Component.Explorer()),
],
right: [],
}