From 53b17eca2bab30ccd534ca2a6d7865fbb2add825 Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Thu, 1 Feb 2024 08:21:45 -0700 Subject: [PATCH 1/9] Add daily branch. --- notes/journal/2024-02-01.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 notes/journal/2024-02-01.md diff --git a/notes/journal/2024-02-01.md b/notes/journal/2024-02-01.md new file mode 100644 index 0000000..5580b72 --- /dev/null +++ b/notes/journal/2024-02-01.md @@ -0,0 +1,18 @@ +--- +title: "2024-02-01" +--- + +- [x] Anki Flashcards +- [x] KoL +- [ ] Sheet Music (10 min.) +- [ ] OGS (1 Life & Death Problem) +- [x] Korean (Read 1 Story) +- [ ] Interview Prep (1 Practice Problem) +- [ ] Log Work Hours (Max 3 hours) + +* Today was the first day using the FSRS algorithm with Anki. Continuing to use Just "Again" and "Good" on my original deck and using all options when using the Obsidian-generated deck. Goal is to eventually migrate back to using all the options. +* Read 해님 달님 (The Sun and the Moon) from Korean stories. + +TODO: +Migrate Quartz +Finish Database readings -- 2.42.0 From 1862cbb609f3cc843076fc62dec5e597c736630f Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Thu, 1 Feb 2024 11:56:04 -0700 Subject: [PATCH 2/9] Finish up primary TODOs. --- notes/journal/2024-02-01.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/notes/journal/2024-02-01.md b/notes/journal/2024-02-01.md index 5580b72..056adaf 100644 --- a/notes/journal/2024-02-01.md +++ b/notes/journal/2024-02-01.md @@ -12,7 +12,4 @@ title: "2024-02-01" * Today was the first day using the FSRS algorithm with Anki. Continuing to use Just "Again" and "Good" on my original deck and using all options when using the Obsidian-generated deck. Goal is to eventually migrate back to using all the options. * Read 해님 달님 (The Sun and the Moon) from Korean stories. - -TODO: -Migrate Quartz -Finish Database readings +* Read sections 11.2 and 13.6 of "Database System Concepts". -- 2.42.0 From 533c24f42f3fad27cb9b47d780f2af9eb2841695 Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Thu, 1 Feb 2024 12:15:50 -0700 Subject: [PATCH 3/9] Mark off music practice. --- notes/journal/2024-02-01.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/notes/journal/2024-02-01.md b/notes/journal/2024-02-01.md index 056adaf..a6735b8 100644 --- a/notes/journal/2024-02-01.md +++ b/notes/journal/2024-02-01.md @@ -4,7 +4,7 @@ title: "2024-02-01" - [x] Anki Flashcards - [x] KoL -- [ ] Sheet Music (10 min.) +- [x] Sheet Music (10 min.) - [ ] OGS (1 Life & Death Problem) - [x] Korean (Read 1 Story) - [ ] Interview Prep (1 Practice Problem) @@ -13,3 +13,4 @@ title: "2024-02-01" * Today was the first day using the FSRS algorithm with Anki. Continuing to use Just "Again" and "Good" on my original deck and using all options when using the Obsidian-generated deck. Goal is to eventually migrate back to using all the options. * Read 해님 달님 (The Sun and the Moon) from Korean stories. * Read sections 11.2 and 13.6 of "Database System Concepts". +* Practiced [reverse keyboard identification](https://www.musictheory.net/exercises/keyboard-reverse). -- 2.42.0 From b2578161c415a1d502cd7d8e020f178664e4273f Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Thu, 1 Feb 2024 14:49:01 -0700 Subject: [PATCH 4/9] Add more gawk flashcards. --- .../plugins/obsidian-to-anki-plugin/data.json | 13 +- notes/bash/quoting.md | 47 ++++++++ notes/bash/robustness.md | 10 +- notes/bash/shebang.md | 9 +- notes/gawk.md | 113 +++++++++++++++++- notes/posix/signals.md | 35 +++++- 6 files changed, 211 insertions(+), 16 deletions(-) create mode 100644 notes/bash/quoting.md diff --git a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json index c1a444c..c9f6fab 100644 --- a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json +++ b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json @@ -60,14 +60,17 @@ "Linux/Signals.md": "f58f1a36a9fe53928fdc3dc02fc4c3e3", "linux/index.md": "6e50c924ee9e09294fd3b907fbdeaf0f", "linux/signals.md": "e9ab74723981ebc232189c84d3b0da74", - "templates/daily.md": "0f22c7ef0b0f35efada88d61c95e9815", + "templates/daily.md": "7866014e730e85683155207a02e367d8", "daily/2024-01-31.md": "72e343cef8d56e169cac7b360a88fcf0", "posix/index.md": "f7b1ae55f8f5e8f50f89738b1aca9111", - "posix/signals.md": "26161c6a79a0c413032c6c17e460412c", - "gawk.md": "9bf70ef138a9a281b86400aee393cae7", + "posix/signals.md": "2120ddd933fc0d57abb93c33f639afd8", + "gawk.md": "c0cf6decdf02f5513e386525b02bdf58", "bash/index.md": "3b5296277f095acdf16655adcdf524af", - "bash/shebang.md": "bc30f75bcddff59d6f907fae89c17283", - "bash/robustness.md": "e474fd33469fc393bfde45cd7b9411ba" + "bash/shebang.md": "ad178efeb4a05190b80b5df108c175c7", + "bash/robustness.md": "de97cd77aae047b5eea27440b43c9c42", + "journal/2024-02-01.md": "f4cc061bfc8e41ce15ae9a354c65ffe9", + "journal/2024-01-31.md": "7c7fbfccabc316f9e676826bf8dfe970", + "bash/quoting.md": "8086c0a576f30d77248faac16a4be79e" }, "fields_dict": { "Basic": [ diff --git a/notes/bash/quoting.md b/notes/bash/quoting.md new file mode 100644 index 0000000..c65e09f --- /dev/null +++ b/notes/bash/quoting.md @@ -0,0 +1,47 @@ +--- +title: Quoting +TARGET DECK: Obsidian::STEM +FILE TAGS: bash +tags: + - bash +--- + +%%ANKI +Basic +How do you escape a `'` within a single-quote string? +Back: This is impossible. +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) + +END%% + +%%ANKI +Basic +What does the null string refer to? +Back: The empty string, i.e. `""`. +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) + +END%% + +%%ANKI +Basic +When does Bash remove null strings from a command? +Back: When they occur as part of a non-null command-line 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) + +END%% + +%%ANKI +Basic +What is wrong with the following command? +```bash +$ # -F specifies the field separator +$ awk -F"" 'program' files +``` +Back: Bash removes the null string before executing the command. +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) + +END%% + +## References + +* 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) \ No newline at end of file diff --git a/notes/bash/robustness.md b/notes/bash/robustness.md index 9e67484..ffbc400 100644 --- a/notes/bash/robustness.md +++ b/notes/bash/robustness.md @@ -7,7 +7,9 @@ tags: - shell --- -An interesting point Robbins[^robbins] discusses in his introduction to [[gawk]] is this idea of command robustness. He states that: +## Overview + +An interesting point 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. @@ -27,7 +29,7 @@ Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 202 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: +He argues that the first command below is more robust than the second since the command is more loosely coupled to its environment: ```bash $ awk 'program' input-file1 input-file2 ... @@ -55,4 +57,6 @@ It's interesting to think what else can be used as a measure of a command's robu * 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) +## References + +* 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) diff --git a/notes/bash/shebang.md b/notes/bash/shebang.md index 34ccf02..25e10f4 100644 --- a/notes/bash/shebang.md +++ b/notes/bash/shebang.md @@ -6,6 +6,8 @@ tags: - bash --- +## Overview + 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 @@ -44,12 +46,13 @@ Some systems limit the length of interpreters to just 32 characters. A simple wo %%ANKI Basic -What workaround is used when shabang interpreter names are too long? +What workaround is used when shebang 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) END%% -[^mendel]: Cooper, Mendel. “Advanced Bash-Scripting Guide,” n.d., 916. +## References -[^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) \ No newline at end of file +* Cooper, Mendel. “Advanced Bash-Scripting Guide,” n.d., 916. +* 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) \ No newline at end of file diff --git a/notes/gawk.md b/notes/gawk.md index c472189..c13b809 100644 --- a/notes/gawk.md +++ b/notes/gawk.md @@ -8,7 +8,7 @@ tags: - gawk --- -## Introduction +## Overview %%ANKI Basic @@ -25,7 +25,7 @@ Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 202 END%% -> Dark corners are basically fractal - no matter how much you illuminate, there's always a smaller but darker one. +> Dark corners are basically fractal - no matter how much you illuminate, there's always a smaller but darker one. #quote The above quote is attributed to Brian Kernighan (one of the authors of the [[C]] K&R book). @@ -83,4 +83,111 @@ Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 202 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) +%%ANKI +Basic +Write the `awk` command that searches file `mail-list` for string `li`. +Back: +```bash +$ awk '/li/ { print }' mail-list +``` +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) + +END%% + +%%ANKI +Basic +How is an `awk` rule without a pattern interpreted? +Back: As applying the specified action for every input line. +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) + +END%% + +%%ANKI +Basic +How is an `awk` rule without an action interpreted? +Back: As printing every line matching the specified pattern. +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) + +END%% + +%%ANKI +Basic +Describe what the following command does in in a single sentence: +```bash +$ awk 'length($0) > 80' data +``` +Back: Prints every line of `data` that is longer than `80` characters. +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) + +END%% + +**Targets** are specified as `$n` where `n` is a placeholder for the `n`th whitespace-separated **field**s of the input line. For example, `$1` refers to the first field of the input line. `$0` is a special target referring to the entire list of arguments, i.e. the entire line. + +%%ANKI +Basic +What is `$0` a placeholder for? +Back: The entire input line. +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) + +END%% + +%%ANKI +Basic +What is `$1` a placeholder for? +Back: The first field of the input line. +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) + +END%% + +%%ANKI +Basic +What is the `BEGIN` pattern? +Back: Code associated with it executes before any input is read. +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) + +END%% + +%%ANKI +Basic +What is the `END` pattern? +Back: Code associated with it executes after all input has been read. +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) + +END%% + +%%ANKI +Basic +Describe what the following command does in in a single sentence: +```bash +$ awk 'NF > 0' data +``` +Back: Prints every line of `data` with at least one field. +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) + +END%% + +%%ANKI +Basic +Describe what the following command does in in a single sentence: +```bash +$ awk 'END { print NR }' data +``` +Back: Prints the number of lines in `data`. +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) + +END%% + +%%ANKI +Basic +Describe what the following command does in in a single sentence: +```bash +$ awk 'NR % 2 == 0' data +``` +Back: Prints every even-numbered line in `data`. +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) + +END%% + +## References + +* 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) \ No newline at end of file diff --git a/notes/posix/signals.md b/notes/posix/signals.md index d563053..29916c9 100644 --- a/notes/posix/signals.md +++ b/notes/posix/signals.md @@ -7,7 +7,9 @@ tags: - signal --- -This is an overview of specific POSIX signals.[^dowling] +## Overview + +This is an overview of specific POSIX signals. Code | Name ----- | -------------- @@ -112,4 +114,33 @@ Reference: `man 1 ps` END%% -[^dowling]: Dowling, “A List of Signals and What They Mean.” +### SIGINT (2) + +Indicates the process was interrupted by the user. Happens when pressing `Ctrl-C` from the controlling terminal. + +%%ANKI +Cloze +Signal {`SIGINT`} corresponds to number {2}. +Reference: Dowling, “A List of Signals and What They Mean.” + +END%% + +%%ANKI +Basic +What control sequence usually triggers a `SIGINT`? +Back: `Ctrl-C` +Reference: Dowling, “A List of Signals and What They Mean.” + +END%% + +%%ANKI +Basic +What is the `INT` in `SIGINT` short for? +Back: **Int**errupt +Reference: Dowling, “A List of Signals and What They Mean.” + +END%% + +## References + +* Dowling, “A List of Signals and What They Mean.” -- 2.42.0 From 0ee310216f28522b83e5fece1618688013b35346 Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Thu, 1 Feb 2024 15:00:26 -0700 Subject: [PATCH 5/9] More flashcards. --- notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json | 4 ++-- notes/bash/quoting.md | 2 +- notes/gawk.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json index c9f6fab..dcb8a18 100644 --- a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json +++ b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json @@ -64,13 +64,13 @@ "daily/2024-01-31.md": "72e343cef8d56e169cac7b360a88fcf0", "posix/index.md": "f7b1ae55f8f5e8f50f89738b1aca9111", "posix/signals.md": "2120ddd933fc0d57abb93c33f639afd8", - "gawk.md": "c0cf6decdf02f5513e386525b02bdf58", + "gawk.md": "4517acfbf4e186e8cc66a9002fbad73f", "bash/index.md": "3b5296277f095acdf16655adcdf524af", "bash/shebang.md": "ad178efeb4a05190b80b5df108c175c7", "bash/robustness.md": "de97cd77aae047b5eea27440b43c9c42", "journal/2024-02-01.md": "f4cc061bfc8e41ce15ae9a354c65ffe9", "journal/2024-01-31.md": "7c7fbfccabc316f9e676826bf8dfe970", - "bash/quoting.md": "8086c0a576f30d77248faac16a4be79e" + "bash/quoting.md": "b1d8869a91001f8b22f0cdc54d806f61" }, "fields_dict": { "Basic": [ diff --git a/notes/bash/quoting.md b/notes/bash/quoting.md index c65e09f..5712e00 100644 --- a/notes/bash/quoting.md +++ b/notes/bash/quoting.md @@ -32,7 +32,7 @@ END%% %%ANKI Basic -What is wrong with the following command? +Why does the following not work correctly? ```bash $ # -F specifies the field separator $ awk -F"" 'program' files diff --git a/notes/gawk.md b/notes/gawk.md index c13b809..607513a 100644 --- a/notes/gawk.md +++ b/notes/gawk.md @@ -38,7 +38,7 @@ END%% ## Setup -Robbins[^robbins] suggests executing command `set +H` on [[bash]] startup to disable [[C]] shell-style command history. +Robbins suggests executing command `set +H` on [[bash]] startup to disable [[C]] shell-style command history. ## Usage -- 2.42.0 From 6dec7996e212cd002cd1ffe286e326a180dce0d6 Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Thu, 1 Feb 2024 15:58:14 -0700 Subject: [PATCH 6/9] Add notes on nix. --- .../plugins/obsidian-to-anki-plugin/data.json | 4 +- notes/nix/callPackage.md | 116 ++++++++++++++++++ notes/nix/index.md | 3 + 3 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 notes/nix/callPackage.md create mode 100644 notes/nix/index.md diff --git a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json index dcb8a18..5cbd355 100644 --- a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json +++ b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json @@ -70,7 +70,9 @@ "bash/robustness.md": "de97cd77aae047b5eea27440b43c9c42", "journal/2024-02-01.md": "f4cc061bfc8e41ce15ae9a354c65ffe9", "journal/2024-01-31.md": "7c7fbfccabc316f9e676826bf8dfe970", - "bash/quoting.md": "b1d8869a91001f8b22f0cdc54d806f61" + "bash/quoting.md": "b1d8869a91001f8b22f0cdc54d806f61", + "nix/callPackage.md": "5ef6bc5d1a549c55d43ebb4d48c64427", + "nix/index.md": "dd5ddd19e95d9bdbe020c68974d77a33" }, "fields_dict": { "Basic": [ diff --git a/notes/nix/callPackage.md b/notes/nix/callPackage.md new file mode 100644 index 0000000..54682c9 --- /dev/null +++ b/notes/nix/callPackage.md @@ -0,0 +1,116 @@ +--- +title: callPackage +TARGET DECK: Obsidian::STEM +FILE TAGS: nix +tags: + - nix +--- + +## Overview + +We first examine `lib.makeOverridable`. It's implementation isn't too important but understanding how it's used is. We adapt the example found in [nixpkgs](https://github.com/NixOS/nixpkgs/blob/56df668386ac83c5bcddf9849c645cf0d25706d7/lib/customisation.nix#L77): + +```nix +nix-repl> x = {a, b}: { example = a + b; } +nix-repl> y = lib.makeOverridable x { a = 1; b = 2; } +nix-repl> y +{ override = «lambda»; overrideDerivation = «lambda»; example = 3; } +nix-repl> y.override { a = 10; } +{ override = «lambda»; overrideDerivation = «lambda»; example = 12; } +``` + +`lib.makeOverridable` is an example of partial function application. Notice `y` still contains the result (`example`) of evaluating `x`. We can re-run the computation with a different value (in this case `a`) by invoking `y.override`. + +%%ANKI +Basic +What is the result of the following? +```nix +x = {a, b}: { example = a + b; } +lib.functionArgs x +``` +Back: `{ a = false; b = false; }` +Reference: Yin, Ryan. “NixOS and Flakes Book.” Nix, February 1, 2024. [https://github.com/ryan4yin/nixos-and-flakes-book](https://github.com/ryan4yin/nixos-and-flakes-book) + +END%% + +%%ANKI +Basic +What does each boolean returned by `lib.functionArgs` indicate? +Back: Whether the associated attribute has a default value. +Reference: Yin, Ryan. “NixOS and Flakes Book.” Nix, February 1, 2024. [https://github.com/ryan4yin/nixos-and-flakes-book](https://github.com/ryan4yin/nixos-and-flakes-book) + +END%% + +%%ANKI +Basic +What additional attributes is included in the set returned by `lib.makeOverridable`? +Back: `override` and `overrideDerivation`. +Reference: Yin, Ryan. “NixOS and Flakes Book.” Nix, February 1, 2024. [https://github.com/ryan4yin/nixos-and-flakes-book](https://github.com/ryan4yin/nixos-and-flakes-book) + +END%% + +%%ANKI +Basic +What is the value of `y.example` in the following? +```nix +x = {a, b}: { example = a + b; } +y = lib.makeOverridable x { a = 1; b = 2; } +``` +Back: `3` +Reference: Yin, Ryan. “NixOS and Flakes Book.” Nix, February 1, 2024. [https://github.com/ryan4yin/nixos-and-flakes-book](https://github.com/ryan4yin/nixos-and-flakes-book) + +END%% + +%%ANKI +Basic +What is the value of `(y.override { a = 10; }).example` in the following? +```nix +x = {a, b}: { example = a + b; } +y = lib.makeOverridable x { a = 1; b = 2; } +``` +Back: `12` +Reference: Yin, Ryan. “NixOS and Flakes Book.” Nix, February 1, 2024. [https://github.com/ryan4yin/nixos-and-flakes-book](https://github.com/ryan4yin/nixos-and-flakes-book) + +END%% + +Now we can understand how `pkgs.callPackage` works. The following is a simplification of the [actual implementation](https://github.com/NixOS/nixpkgs/blob/56df668386ac83c5bcddf9849c645cf0d25706d7/lib/customisation.nix#L153): + +```nix +callPackageWith = autoArgs: fn: args: + let + f = if isFunction fn then fn else import fn; + fargs = functionArgs f; + allArgs = intersectArgs fargs autoArgs // args; + in + lib.makeOverridable f allArgs + +callPackage = callPackageWith pkgs; +``` + +%%ANKI +Basic +What two functions is `callPackage` implemented on top of? +Back: `callPackageWith` and `lib.makeOverridable`. +Reference: Yin, Ryan. “NixOS and Flakes Book.” Nix, February 1, 2024. [https://github.com/ryan4yin/nixos-and-flakes-book](https://github.com/ryan4yin/nixos-and-flakes-book) + +END%% + +%%ANKI +Basic +What is the purpose of `callPackage`? +Back: It calls package functions with arguments automatic supplied if not overridden. +Reference: Yin, Ryan. “NixOS and Flakes Book.” Nix, February 1, 2024. [https://github.com/ryan4yin/nixos-and-flakes-book](https://github.com/ryan4yin/nixos-and-flakes-book) + +END%% + +%%ANKI +Basic +What attribute must be invoked in `callPackage`'s return value to override arguments? +Back: `override` +Reference: Yin, Ryan. “NixOS and Flakes Book.” Nix, February 1, 2024. [https://github.com/ryan4yin/nixos-and-flakes-book](https://github.com/ryan4yin/nixos-and-flakes-book) + +END%% + +## Reference + +* Yin, Ryan. “NixOS and Flakes Book.” Nix, February 1, 2024. [https://github.com/ryan4yin/nixos-and-flakes-book](https://github.com/ryan4yin/nixos-and-flakes-book) \ No newline at end of file diff --git a/notes/nix/index.md b/notes/nix/index.md new file mode 100644 index 0000000..39e7a6e --- /dev/null +++ b/notes/nix/index.md @@ -0,0 +1,3 @@ +--- +title: Nix +--- -- 2.42.0 From f35913e6b0a09c683d4d78e4af1508c38a3f83f1 Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Thu, 1 Feb 2024 17:16:36 -0700 Subject: [PATCH 7/9] Quartz note. --- notes/journal/2024-02-01.md | 1 + 1 file changed, 1 insertion(+) diff --git a/notes/journal/2024-02-01.md b/notes/journal/2024-02-01.md index a6735b8..7363ea0 100644 --- a/notes/journal/2024-02-01.md +++ b/notes/journal/2024-02-01.md @@ -11,6 +11,7 @@ title: "2024-02-01" - [ ] Log Work Hours (Max 3 hours) * Today was the first day using the FSRS algorithm with Anki. Continuing to use Just "Again" and "Good" on my original deck and using all options when using the Obsidian-generated deck. Goal is to eventually migrate back to using all the options. +* Spent some time migrating the Quartz setup to use Nix instead. I lose the ability to run Quartz locally (at least without more work), but upgrades are significantly easier. Theoretically the only thing I should care about is that my notes look good in Markdown/Obsidian anyways so fine with this trade-off. * Read 해님 달님 (The Sun and the Moon) from Korean stories. * Read sections 11.2 and 13.6 of "Database System Concepts". * Practiced [reverse keyboard identification](https://www.musictheory.net/exercises/keyboard-reverse). -- 2.42.0 From 498c2d361246ef01fac743d3f0afad132f7d2a11 Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Thu, 1 Feb 2024 17:18:05 -0700 Subject: [PATCH 8/9] More checks. --- notes/journal/2024-02-01.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notes/journal/2024-02-01.md b/notes/journal/2024-02-01.md index 7363ea0..49417bc 100644 --- a/notes/journal/2024-02-01.md +++ b/notes/journal/2024-02-01.md @@ -5,10 +5,10 @@ title: "2024-02-01" - [x] Anki Flashcards - [x] KoL - [x] Sheet Music (10 min.) -- [ ] OGS (1 Life & Death Problem) +- [x] OGS (1 Life & Death Problem) - [x] Korean (Read 1 Story) - [ ] Interview Prep (1 Practice Problem) -- [ ] Log Work Hours (Max 3 hours) +- [x] Log Work Hours (Max 3 hours) * Today was the first day using the FSRS algorithm with Anki. Continuing to use Just "Again" and "Good" on my original deck and using all options when using the Obsidian-generated deck. Goal is to eventually migrate back to using all the options. * Spent some time migrating the Quartz setup to use Nix instead. I lose the ability to run Quartz locally (at least without more work), but upgrades are significantly easier. Theoretically the only thing I should care about is that my notes look good in Markdown/Obsidian anyways so fine with this trade-off. -- 2.42.0 From 234de7270a8e847e29f3618616912b741ceb4ca5 Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Fri, 2 Feb 2024 04:40:59 -0700 Subject: [PATCH 9/9] callPackage. --- notes/journal/2024-02-01.md | 1 + 1 file changed, 1 insertion(+) diff --git a/notes/journal/2024-02-01.md b/notes/journal/2024-02-01.md index 49417bc..bf3f32a 100644 --- a/notes/journal/2024-02-01.md +++ b/notes/journal/2024-02-01.md @@ -15,3 +15,4 @@ title: "2024-02-01" * Read 해님 달님 (The Sun and the Moon) from Korean stories. * Read sections 11.2 and 13.6 of "Database System Concepts". * Practiced [reverse keyboard identification](https://www.musictheory.net/exercises/keyboard-reverse). +* Spent time learning how Nix's `callpackage` function works. -- 2.42.0