diff --git a/content/tools/standalone/environments/_category_.json b/content/tools/standalone/environments/_category_.json new file mode 100644 index 000000000..67d6b5dfa --- /dev/null +++ b/content/tools/standalone/environments/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Environments", + "position": 3 +} diff --git a/content/tools/standalone/environments/nix.mdx b/content/tools/standalone/environments/nix.mdx new file mode 100644 index 000000000..bbf26931e --- /dev/null +++ b/content/tools/standalone/environments/nix.mdx @@ -0,0 +1,45 @@ +--- +title: "Preface" +description: "Using C and C++ with Nix: Preface" +hide_title: true +--- + +# Using C and C++ with Nix + +When it comes to using C++ with Nix, one may want to do several things: +1. Create a development shell with tools and libraries which is then used in the development loop +2. Package a new/existing project for other Nix and non-Nix users to use +3. Contribute to nixpkgs, so that the packaged project is readily available from the centralized repository +4. Create a CI/CD environment to evaluate the correctness of the project + +This series of articles explains all of these in detail, with focus on good practices. + +On top of that, we will show how to achieve each of those with flake and non-flake configurations and +how the code may differ when contributed to nixpkgs. + +:::caution +This series is **not** by any means a Nix tutorial, each section assumes the reader has a certain knowledge +acquired beforehand. We will be explaining some patterns and concepts, but you won't probably wont understand +much without having some decent understanding. + +If you are unsure about your Nix basics this is what I would recommend: + +1. Get familiar with the Nix language first: + - https://learnxinyminutes.com/docs/nix/ + - https://nix.dev/tutorials/nix-language#reading-nix-language + - https://nixcloud.io/tour/?id=introduction/nix + +2. Go through nix.dev to have a better grasp about Nix concepts and good practices: + - https://nix.dev + +3. You may want to read up on flakes as well, as they are ubiquitous in the community: + - https://nixos.wiki/wiki/Flakes + - https://nix.dev/concepts/flakes.html + - https://www.tweag.io/blog/2020-05-25-flakes/ + - https://jvns.ca/blog/2023/11/11/notes-on-nix-flakes/ + +4. For lower level knowledge, go through Nix pills: + - https://nixos.org/guides/nix-pills/ + +5. Toy with and explore the ecosystem - most knowledge is gained through first-hand experience. +::: diff --git a/content/tools/standalone/environments/nix/shells.mdx b/content/tools/standalone/environments/nix/shells.mdx new file mode 100644 index 000000000..67b8f7bb9 --- /dev/null +++ b/content/tools/standalone/environments/nix/shells.mdx @@ -0,0 +1,17 @@ +--- +sidebar_position: 1 +title: Nix C++ development shell +sidebar_label: Development shell +description: Learn how to setup a development shell with Nix +tags: [environemnt, tools, nix, nixos] +hide_title: true +--- + +import NotFinished from '@site/i18n/en/presets/NotFinished.mdx'; +import ImproveSection from '@site/i18n/en/presets/ImproveSection.mdx'; + + + +# Setting up a C++ development shell with Nix + + diff --git a/sidebars/common.ts b/sidebars/common.ts index bc0246504..b1a0f67e9 100644 --- a/sidebars/common.ts +++ b/sidebars/common.ts @@ -60,6 +60,9 @@ export function cat(name: string): SidebarItemConfig { return separatorBase(`${name}`, "sidebar-separator sidebar-category"); } +export const lessonsSeparator = cat("Lessons:"); +export const additionalSeparator = cat("Additional:"); + export function parseClassItemShorthand(id: string, e, flags: Flags = []): SidebarItemConfig { if (typeof e !== "string") { if (Array.isArray(e)) @@ -87,4 +90,4 @@ export function docsClassCat(label: string, id: string, flags: Flags, contents): link: { type: "doc", id: id }, items: contents.map(e => parseClassItemShorthand(id, e)) }; -} \ No newline at end of file +} diff --git a/sidebars/learn.ts b/sidebars/learn.ts index b1fae2816..ef1c9f1b4 100644 --- a/sidebars/learn.ts +++ b/sidebars/learn.ts @@ -1,13 +1,10 @@ import type { SidebarItemConfig, SidebarsConfig } from "./types"; -import { cat } from "./common"; +import { lessonsSeparator, additionalSeparator } from "./common"; function doc(sidebarLabel: string, docId: string): SidebarItemConfig { return { type: "doc", label: sidebarLabel, id: docId }; } -const lessonsSeparator = cat("Lessons:"); -const additionalSeparator = cat("Additional:"); - const sidebars: SidebarsConfig = { defaultSidebar: [ "index", @@ -305,4 +302,4 @@ const sidebars: SidebarsConfig = { ], }; -export default sidebars; \ No newline at end of file +export default sidebars; diff --git a/sidebars/tools.ts b/sidebars/tools.ts index 8e2a39c22..7b8f1cc63 100644 --- a/sidebars/tools.ts +++ b/sidebars/tools.ts @@ -1,4 +1,5 @@ import type { SidebarsConfig } from "./types"; +import { lessonsSeparator } from "./common"; const sidebars: SidebarsConfig = { defaultSidebar: [ @@ -51,9 +52,24 @@ const sidebars: SidebarsConfig = { "standalone/compilers/setup-clang-macos", ] }, + { + type: "category", + label: "Environments", + items: [ + { + type: "category", + label: "Nix", + link: { type: "doc", id: "standalone/environments/nix" }, + items: [ + lessonsSeparator, + "standalone/environments/nix/shells", + ] + } + ] + }, ] } ], }; -export default sidebars; \ No newline at end of file +export default sidebars;