Skip to content

Commit

Permalink
chore: format code via prettier (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan4yin authored Mar 16, 2024
1 parent af650be commit 9e6982f
Show file tree
Hide file tree
Showing 61 changed files with 313 additions and 397 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# open_collective: nixos-and-flakes-book
patreon: ryan4yin
custom: ['https://buymeacoffee.com/ryan4yin', 'https://afdian.net/a/ryan4yin']
custom: ["https://buymeacoffee.com/ryan4yin", "https://afdian.net/a/ryan4yin"]
13 changes: 7 additions & 6 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -24,8 +24,9 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Environment (please complete the following information):**
- NixOS Version: [e.g. 23.11]
- Nix version: [e.g. 2.18]

- NixOS Version: [e.g. 23.11]
- Nix version: [e.g. 2.18]

**Additional context**
Add any other context about the problem here.
9 changes: 3 additions & 6 deletions .github/ISSUE_TEMPLATE/custom.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
---
name: Custom issue template
about: Describe this issue template's purpose here.
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---


7 changes: 3 additions & 4 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

**Is your feature request related to a problem? Please describe.**
Expand Down
78 changes: 39 additions & 39 deletions .github/workflows/release-pdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,43 @@ jobs:
generate-pdf:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install nix
uses: cachix/install-nix-action@v23
with:
nix_path: "nixpkgs=channel:nixpkgs-unstable"
extra_nix_config: |
experimental-features = nix-command flakes
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Show nixpkgs version
run: nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'
- name: Run a command with nix develop
run: |
nix develop .#export-pdf --ignore-environment --command bash -c '
pnpm install
pnpm export-pdf
'
# # For debugging, upload the pdfs as artifacts
# - uses: actions/upload-artifact@v3
# with:
# name: pdf
# path: '*.pdf'
- name: Generate changelog
run: |
# Get the previous tag
git fetch --tags
PREVIOUS_TAG=$(git tag --sort=-creatordate | head -n 2 | tail -n 1)
# Generate the changelog
git log --pretty=format:"%h %s" $PREVIOUS_TAG..HEAD > CHANGELOG
- name: Checkout repository
uses: actions/checkout@v4
- name: Install nix
uses: cachix/install-nix-action@v23
with:
nix_path: "nixpkgs=channel:nixpkgs-unstable"
extra_nix_config: |
experimental-features = nix-command flakes
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Show nixpkgs version
run: nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'
- name: Run a command with nix develop
run: |
nix develop .#export-pdf --ignore-environment --command bash -c '
pnpm install
pnpm export-pdf
'
# # For debugging, upload the pdfs as artifacts
# - uses: actions/upload-artifact@v3
# with:
# name: pdf
# path: '*.pdf'
- name: Generate changelog
run: |
# Get the previous tag
git fetch --tags
PREVIOUS_TAG=$(git tag --sort=-creatordate | head -n 2 | tail -n 1)
# Generate the changelog
git log --pretty=format:"%h %s" $PREVIOUS_TAG..HEAD > CHANGELOG
echo "Changelog from $PREVIOUS_TAG to HEAD:"
cat CHANGELOG
- name: Release PDF
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
generate_release_notes: true
body_path: CHANGELOG
files: |
nixos-and-flakes-book.pdf
echo "Changelog from $PREVIOUS_TAG to HEAD:"
cat CHANGELOG
- name: Release PDF
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
generate_release_notes: true
body_path: CHANGELOG
files: |
nixos-and-flakes-book.pdf
38 changes: 20 additions & 18 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createRequire } from "module";
import { generateSitemap as sitemap } from "sitemap-ts";
import { PageData, defineConfig } from "vitepress";
import { createRequire } from "module"
import { generateSitemap as sitemap } from "sitemap-ts"
import { PageData, defineConfig } from "vitepress"

const require = createRequire(import.meta.url);
const require = createRequire(import.meta.url)

// https://vitepress.dev/reference/site-config
export default defineConfig({
Expand All @@ -18,7 +18,7 @@ export default defineConfig({
hostname: "https://nixos-and-flakes.thiscute.world/",
outDir: outDir,
generateRobotsTxt: true,
});
})
},

// SEO Improvement - JSON-LD
Expand All @@ -30,7 +30,7 @@ export default defineConfig({
["script", { type: "application/ld+json" }, getJSONLD(pageData)],
],
},
};
}
},

head: [
Expand Down Expand Up @@ -78,14 +78,16 @@ export default defineConfig({

config: (md) => {
// add support for footnote
md.use(require("markdown-it-footnote"));
md.use(require("markdown-it-footnote"))
},
},

themeConfig: {
footer: {
message: 'Licensed under <a href="http://creativecommons.org/licenses/by-sa/4.0/?ref=chooser-v1" target="_blank">CC BY-SA 4.0</a>',
copyright: 'Copyright © 2023-present <a href="https://github.com/ryan4yin" target="_blank">Ryan Yin</a>',
message:
'Licensed under <a href="http://creativecommons.org/licenses/by-sa/4.0/?ref=chooser-v1" target="_blank">CC BY-SA 4.0</a>',
copyright:
'Copyright © 2023-present <a href="https://github.com/ryan4yin" target="_blank">Ryan Yin</a>',
},

search: {
Expand Down Expand Up @@ -115,7 +117,7 @@ export default defineConfig({
root: themeConfigEnglish(),
zh: themeConfigChinese(),
},
});
})

function themeConfigEnglish() {
return {
Expand Down Expand Up @@ -311,7 +313,7 @@ function themeConfigEnglish() {
},
],
},
};
}
}

function themeConfigChinese() {
Expand Down Expand Up @@ -401,7 +403,7 @@ function themeConfigChinese() {
items: [
{ text: "简介", link: "/zh/nixpkgs/intro.md" },
{ text: "callPackage", link: "/zh/nixpkgs/callpackage.md" },
{ text: "Overridding", link: "/zh/nixpkgs/overriding.md" },
{ text: "Overriding", link: "/zh/nixpkgs/overriding.md" },
{ text: "Overlays", link: "/zh/nixpkgs/overlays.md" },
{
text: "多 Nixpkgs 实例",
Expand Down Expand Up @@ -506,7 +508,7 @@ function themeConfigChinese() {
},
],
},
};
}
}

function getJSONLD(pageData: PageData) {
Expand All @@ -518,7 +520,7 @@ function getJSONLD(pageData: PageData) {
"inLanguage":"en",
"description":"An unofficial and opinionated book for beginners",
"name":"${pageData.title}"
}`;
}`
} else if (pageData.relativePath === "zh/index.md") {
return `{
"@context":"http://schema.org",
Expand All @@ -527,12 +529,12 @@ function getJSONLD(pageData: PageData) {
"inLanguage":"zh-CN",
"description":"一份非官方的新手指南",
"name":"${pageData.title}"
}`;
}`
} else {
let lang = pageData.relativePath.startsWith("zh/") ? "zh-CN" : "en";
let lang = pageData.relativePath.startsWith("zh/") ? "zh-CN" : "en"
let url = `https:\/\/nixos-and-flakes.thiscute.world\/${pageData.relativePath
.replace(/\.md$/, "")
.replace(/\/index\$/, "/")}`;
.replace(/\/index\$/, "/")}`
return `{
"@context":"http://schema.org",
"@type":"TechArticle",
Expand All @@ -544,6 +546,6 @@ function getJSONLD(pageData: PageData) {
},
"keywords":"NixOS, Nix, Flakes, Linux, Tutorial",
"url":"${url}"
}`;
}`
}
}
10 changes: 5 additions & 5 deletions docs/.vitepress/style/print.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@media print {
.VPNav,
.VPLocalNav,
.VPDocFooter {
display: none !important;
}
.VPNav,
.VPLocalNav,
.VPDocFooter {
display: none !important;
}
}
20 changes: 10 additions & 10 deletions docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// .vitepress/theme/index.ts
import DefaultTheme from "vitepress/theme";
import giscusTalk from "vitepress-plugin-comment-with-giscus";
import { useData, useRoute } from "vitepress";
import DefaultTheme from "vitepress/theme"
import giscusTalk from "vitepress-plugin-comment-with-giscus"
import { useData, useRoute } from "vitepress"

// custom CSS
import "../style/print.css";
import "../style/print.css"

export default {
// Extending the Default Theme
...DefaultTheme,
enhanceApp(ctx) {
DefaultTheme.enhanceApp(ctx);
DefaultTheme.enhanceApp(ctx)
// ...
},
setup() {
// Get frontmatter and route
const { frontmatter } = useData();
const route = useRoute();
const { frontmatter } = useData()
const route = useRoute()

// Obtain configuration from: https://giscus.app/
giscusTalk(
Expand All @@ -41,7 +41,7 @@ export default {
// The default is true, which means enabled, this parameter can be ignored;
// If it is false, it means it is not enabled.
// You can use `comment: true` preface to enable it separately on the page.
true,
);
true
)
},
};
}
37 changes: 18 additions & 19 deletions docs/.vitepress/vitepress-pdf.config.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
import { defineUserConfig } from "vitepress-export-pdf";
import config from './config'

import { defineUserConfig } from "vitepress-export-pdf"
import config from "./config"

// convert `config.themeConfig?.sidebar` to a list of routes
let routeOrder = [];
const sidebar = config.locales.root.themeConfig?.sidebar;
let routeOrder = []
const sidebar = config.locales.root.themeConfig?.sidebar
if (sidebar) {
sidebar.forEach((it) => {
if (it.items) {
it.items.forEach((subItem) => {
routeOrder.push(subItem.link.replace(/\.md$/, ""));
});
routeOrder.push(subItem.link.replace(/\.md$/, ""))
})
}
});
})
}

// print routeOrder in terminal
console.log("routeOrder: ", routeOrder);
console.log("routeOrder: ", routeOrder)

export default defineUserConfig({
routePatterns: ["!/zh/**"], // exclude zh-CN pages
sorter: (pageA, pageB) => {
const aIndex = routeOrder.findIndex(route => route === pageA.path);
const bIndex = routeOrder.findIndex(route => route === pageB.path);
const index = aIndex - bIndex;
// console.log(`sorter: ${pageA.path} vs ${pageB.path} = ${index}`);
return index;
},
urlOrigin: "https://nixos-and-flakes.thiscute.world/",
});
routePatterns: ["!/zh/**"], // exclude zh-CN pages
sorter: (pageA, pageB) => {
const aIndex = routeOrder.findIndex((route) => route === pageA.path)
const bIndex = routeOrder.findIndex((route) => route === pageB.path)
const index = aIndex - bIndex
// console.log(`sorter: ${pageA.path} vs ${pageB.path} = ${index}`);
return index
},
urlOrigin: "https://nixos-and-flakes.thiscute.world/",
})
5 changes: 2 additions & 3 deletions docs/advanced-topics/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ Once you have become familiar with NixOS, you can explore advanced topics and di
## Community

- [Nix Official - Community](https://nixos.org/community/): Contains information about the Nix community, forums, realtime chat, meetups, RFCs, the official team architecture, etc.
- [Nix Channel Status](https://status.nixos.org/): The build status of each Nix channel.
- [Nix Channel Status](https://status.nixos.org/): The build status of each Nix channel.
- [nix-community/NUR](https://github.com/nix-community/NUR): Although Nixpkgs contains a large number of packages, some packages are not included in Nixpkgs due to reasons such as review speed and licensing agreements. NUR is a decentralized Nix package repository where anyone can create their own Nix repository and add it to NUR for others to use. If you want to use a package that is not in Nixpkgs, you can try to find it here. If you want to share your own Nix package with others, you can create and share your own Nix repository according to the README of NUR.

## Documentation and Videos

- [Eelco Dolstra - The Purely Functional Software Deployment Model - 2006](https://edolstra.github.io/pubs/phd-thesis.pdf): Eelco Dolstra's seminal PhD thesis about the Nix package manager,
- [Eelco Dolstra - The Purely Functional Software Deployment Model - 2006](https://edolstra.github.io/pubs/phd-thesis.pdf): Eelco Dolstra's seminal PhD thesis about the Nix package manager,
- [Nix Reference Manual](https://nixos.org/manual/nix/stable/package-management/profiles.html): A comprehensive guide to the Nix package manager, covering its design and usage from the command line.
- [nixpkgs Manual](https://nixos.org/manual/nixpkgs/unstable/): The manual for nixpkgs, which introduces its parameters, explains how to use, modify, and package Nix packages.
- [NixOS Manual](https://nixos.org/manual/nixos/unstable/): A user manual for NixOS, providing configuration instructions for system-level components such as Wayland/X11 and GPU.
Expand All @@ -22,7 +22,6 @@ And there are many official videos on the [NixOS Foundation](https://www.youtube
- [Summer of Nix 2022 — Public Lecture Series](https://www.youtube.com/playlist?list=PLt4-_lkyRrOMWyp5G-m_d1wtTcbBaOxZk): A series of public lectures hosted by the NixOS Foundation, presented by core members of the Nix community such as Eelco Dolstra and Armijn Hemel. The content covers the development history of Nix, the history of NixOS, and the future of Nix, among other topics.
- [Summer of Nix 2023 — Nix Developer Dialogues](https://www.youtube.com/playlist?list=PLt4-_lkyRrOPcBuz_tjm6ZQb-6rJjU3cf): A series of dialogues between core members of the Nix community in 2023. The content includes the evolution and architectural challenges of Nixpkgs, exploration of Nix's module system, discussion of the Nix ecosystem, AI applications in Nixpkgs, and the application of Nix in the commercial field and open source economics.


## Advanced Techniques and Community Projects

Once you are comfortable with Flakes, you can explore more advanced techniques and community projects. Here are some popular ones to try out:
Expand Down
Loading

0 comments on commit 9e6982f

Please sign in to comment.