From b0a4bf79d6523ec17b96393f8bafe0c31669bc6d Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Wed, 6 Dec 2023 19:36:23 -0500 Subject: [PATCH] add: nixpkgs.md --- en/blog/nix-rapid.md | 6 +++--- en/blog/nixify-haskell-project-intro.md | 10 +++++----- en/nixpkgs.md | 7 +++++++ en/treefmt.md | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 en/nixpkgs.md diff --git a/en/blog/nix-rapid.md b/en/blog/nix-rapid.md index 753ca270..13abc78e 100644 --- a/en/blog/nix-rapid.md +++ b/en/blog/nix-rapid.md @@ -101,14 +101,14 @@ $ nix eval .#foo ### Graph -A flake can refer to other flakes in its inputs. Phrased differently, a flake's outputs can be used as inputs in other flakes. The most common example is the [nixpkgs](https://zero-to-nix.com/concepts/nixpkgs) flake which gets used as an input in most flakes. Intuitively, you may visualize a flake to be a node in a larger graph, with inputs being the incoming arrows and outputs being the outgoing arrows. +A flake can refer to other flakes in its inputs. Phrased differently, a flake's outputs can be used as inputs in other flakes. The most common example is the [[nixpkgs]] flake which gets used as an input in most flakes. Intuitively, you may visualize a flake to be a node in a larger graph, with inputs being the incoming arrows and outputs being the outgoing arrows. ### Inputs > [!info] To learn more > - [URL-like syntax][flake-url] used by the `url` attribute -Let's do something more interesting with our `flake.nix` by adding the nixpkgs input: +Let's do something more interesting with our `flake.nix` by adding the [[nixpkgs]] input: ```nix { @@ -123,7 +123,7 @@ Let's do something more interesting with our `flake.nix` by adding the nixpkgs i } ``` -The nixpkgs flake has an output called `legacyPackages`, which is indexed by the platform (called "system" in Nix-speak), further containing all the packages for that system. We assign that package to our flake output key `foo`. +The [[nixpkgs]] flake has an output called `legacyPackages`, which is indexed by the platform (called "system" in Nix-speak), further containing all the packages for that system. We assign that package to our flake output key `foo`. >[!tip] You can use [[repl|`nix repl`]] to explore the outputs of any flake, using TAB completion: > diff --git a/en/blog/nixify-haskell-project-intro.md b/en/blog/nixify-haskell-project-intro.md index 7d1f0fe8..8314273c 100644 --- a/en/blog/nixify-haskell-project-intro.md +++ b/en/blog/nixify-haskell-project-intro.md @@ -14,7 +14,7 @@ Nix is a powerful package manager and build system that provides reproducible an > We strongly recommend flakes for anyone getting started with Nix. Flakes is [production ready despite being marked as experimental](https://determinate.systems/posts/experimental-does-not-mean-unstable). >[!info] -> The [Haskell infrastructure in nixpkgs](https://community.flake.parts/haskell-flake/nixpkgs-haskell) is the simplest way to get started with Nixifying a Haskell project. There are also other approaches (like [haskell.nix](https://github.com/input-output-hk/haskell.nix), [stacklock2nix](https://github.com/cdepillabout/stacklock2nix)). Later in the blog post series, we'll explore [haskell-flake](https://community.flake.parts/haskell-flake) which builds on top of the Haskell infrastructure in nixpkgs +> The [Haskell infrastructure in nixpkgs](https://community.flake.parts/haskell-flake/nixpkgs-haskell) is the simplest way to get started with Nixifying a Haskell project. There are also other approaches (like [haskell.nix](https://github.com/input-output-hk/haskell.nix), [stacklock2nix](https://github.com/cdepillabout/stacklock2nix)). Later in the blog post series, we'll explore [haskell-flake](https://community.flake.parts/haskell-flake) which builds on top of the Haskell infrastructure in [[nixpkgs]]. If you're unfamiliar with Nix, we have [[nix-rapid]] available to help you get started quickly or you can take your time and explore it at [Zero to Nix](https://zero-to-nix.com). A basic understanding of the Nix expression language is assumed. @@ -32,7 +32,7 @@ can get the development environment up and running with one command. - **Multi-platform**: Same configuration generally works on macOS, Linux and WSL. >[!note] macOS support -> Although macOS doesn't have first-class support in nixpkgs, [it is getting there](https://github.com/NixOS/nixpkgs/issues/116341). +> Although [[macos]] doesn't have first-class support in [[nixpkgs]], [it is getting there](https://github.com/NixOS/nixpkgs/issues/116341). [^1]: Considering the packages are available in Nix for the host platform. @@ -90,7 +90,7 @@ A nix flake such as the one above consumes certain `inputs` and produces certain A flake can reference other flakes, which are specified in the `inputs` attribute. We will use the [URL-like representation](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake.html#url-like-syntax) to specify our input flakes. -In this example, we will use [GNU hello](https://www.gnu.org/software/hello) package from [`nixpkgs`](https://github.com/NixOS/nixpkgs) flake. Therefore, we'll specify the nixpkgs flake as an input, specifically using its `nixpkgs-unstable` branch. +In this example, we will use [GNU hello](https://www.gnu.org/software/hello) package from [[nixpkgs]] flake. Therefore, we'll specify the [[nixpkgs]] flake as an input, specifically using its `nixpkgs-unstable` branch. >[!note] The `nixpkgs-unstable` naming > The `nixpkgs-unstable` branch is named as such because of the frequent updates it receives and doesn't imply that it is unsafe. @@ -107,7 +107,7 @@ The inputs argument is an attrset containing `self` as well as the flake inputs [Refer here](https://nixos.wiki/wiki/Flakes#Output_schema) for a detailed schema of `outputs`. Note that the `nixpkgs` key within the inputs attrset refers to the `outputs` of the `flake.nix` located at `nixpkgs.url`. If `nixpkgs.flake = false` is set, then the parameter will represent the source code. -The body of the function defines the flake outputs. Within the `let` block we define two values -- `system` (set as "aarch64-darwin" in this example, assuming we are on an ARM mac) and `pkgs` (referring to nixpkgs packages for `system`). In our example, `system` is hardcoded to a single system, but [forAllSystems](https://zero-to-nix.com/concepts/flakes#system-specificity) can be used to define packages for an array of systems. +The body of the function defines the flake outputs. Within the `let` block we define two values -- `system` (set as "aarch64-darwin" in this example, assuming we are on an ARM mac) and `pkgs` (referring to [[nixpkgs]] packages for `system`). In our example, `system` is hardcoded to a single system, but [forAllSystems](https://zero-to-nix.com/concepts/flakes#system-specificity) can be used to define packages for an array of systems. Here are some standard outputs a flake may produce: @@ -183,7 +183,7 @@ Tl;dr Here is the `flake.nix` for this section: Let's break it down! ### haskellPackages -Consult [the official manual](https://nixos.org/manual/nixpkgs/unstable/#haskell) to learn more about the Haskell infrastructure in nixpkgs, but for the purpose of our blog post it is suffice to know that: +Consult [the official manual](https://nixos.org/manual/nixpkgs/unstable/#haskell) to learn more about the Haskell infrastructure in [[nixpkgs]], but for the purpose of our blog post it is suffice to know that: - `pkgs.haskellPackages` is an attribute set that contains all Haskell packages maintained within `nixpkgs`. - Since our local package (`todo-app`) is not already included in `pkgs.haskellPackages`, we need to manually add it. diff --git a/en/nixpkgs.md b/en/nixpkgs.md new file mode 100644 index 00000000..1b2272aa --- /dev/null +++ b/en/nixpkgs.md @@ -0,0 +1,7 @@ +nixpkgs () contains a collection of [[nix]] packages. It also includes various utility functions for [[nix]], as well as the [[nixos]] Linux distribution. + +In [[flakes|flakes]], nixpkgs is the most commonly used input. + +## Links + +- [Zero to Nix: nixpkgs](https://zero-to-nix.com/concepts/nixpkgs) \ No newline at end of file diff --git a/en/treefmt.md b/en/treefmt.md index b42d10cd..d8f776ba 100644 --- a/en/treefmt.md +++ b/en/treefmt.md @@ -83,7 +83,7 @@ If there are folders where you wouldn't want to run the formatter on, use the fo ### Use a different package for formatter -The package shipped with the current nixpkgs might not be the desired one, follow the snippet below to override the package (assuming `nixpkgs-21_11` is present in your flake's inputs). +The package shipped with the current [[nixpkgs]] might not be the desired one, follow the snippet below to override the package (assuming `nixpkgs-21_11` is present in your flake's inputs). ```nix # Inside mkFlake's `perSystem.treefmt.config`