-
Notifications
You must be signed in to change notification settings - Fork 41
Add documentation for Flakes #23
base: master
Are you sure you want to change the base?
Conversation
sevanspowell
commented
Feb 10, 2022
- Add some beginning resources for understanding Nix Flakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent, thanks @sevanspowell !
Can we put all the files flat under docs/code/nix
and use order
to control their ordering?
And there are also some (but not all) sections from cardano-wallet/docs/contributing/Nix.md
that could be integrated here.
{ | ||
description = "A very basic flake"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.11"; | ||
}; | ||
|
||
outputs = { self, nixpkgs }: | ||
let | ||
pkgs = nixpkgs.legacyPackages.x86_64-linux | ||
in { | ||
devShell.x86_64-linux = pkgs.mkShell { | ||
nativeBuildInputs = [ | ||
pkgs.python3 | ||
]; | ||
}; | ||
}; | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we cut down the examples so that they are still self-contained, but only deal with the topic of this page?
For example, remove pinning of nixpkgs, unless the page is about version pinning.
But here is a more interesting example of what could be put in the shell:
{ | |
description = "A very basic flake"; | |
inputs = { | |
nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.11"; | |
}; | |
outputs = { self, nixpkgs }: | |
let | |
pkgs = nixpkgs.legacyPackages.x86_64-linux | |
in { | |
devShell.x86_64-linux = pkgs.mkShell { | |
nativeBuildInputs = [ | |
pkgs.python3 | |
]; | |
}; | |
}; | |
} | |
``` | |
{ | |
description = "Flake with a development environment"; | |
outputs = { self, nixpkgs }: { | |
devShell.x86_64-linux = | |
with nixpkgs.legacyPackages.x86_64-linux; | |
mkShell { | |
nativeBuildInputs = [ | |
(python3.withPackages (ps: [ ps.numpy ps.toolz ps.requests ])) | |
]; | |
}; | |
}; | |
} | |
``` | |
This is an example of adding Python and some Python Wheels to the shell. More information (for those interested) can be found in the | |
[Nixpkgs Manual Python section](https://nixos.org/manual/nixpkgs/stable/#python). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This builds on tutorial 2, and so I left the version pinning in to minimize required code changes from the last flake.nix
, but feel free to remove.
date: 2021-02-09 | ||
--- | ||
|
||
Presuming nix is already installed, Nix flakes are available from Nix version 2.4 and up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we also integrate some of the material from these documents?
experimental-features = nix-command flakes | ||
``` | ||
|
||
## NixOS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NixOS-specific instructions probably aren't necessary. Especially because nix.extraOptions
has become nix.settings.experimental-features
in the latest nixos-unstable versions.
## Non-NixOS | ||
|
||
``` | ||
$ nix-env -iA nixpkgs.nixUnstable # or nixpkgs.nix_2_4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplest way is probably to ask users to run:
nix upgrade-nix
If that doesn't work, then reinstall it using the instructions here: https://nixos.org/manual/nix/stable/installation/installing-binary.html#multi-user-installation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't work on NixOS
nix upgrade-nix
error: Nix on NixOS must be upgraded via 'nixos-rebuild'
date: 2021-02-09 | ||
--- | ||
|
||
The `flake.nix` has the following schema: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a feeling this will go out of date, and the original sources could just be linked.
On the other hand, the flake schema is not well documented.
The resources I use are:
|
||
- Unify the management of inputs (make redundant tools like `niv`). | ||
- Remove sources of impurity that existed in the previous model. | ||
- Standardize the output format of repositories. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One other benefit of this new format is that it facilitates composability, so it becomes easier to connect one flake's outputs to other flake's inputs.
- Add some beginning resources for Nix Flakes.
e6bbfe1
to
47779b6
Compare
I do not want this service and did Not apply for it
…On Fri, 22 Apr 2022, 7:42 am Yura Lazarev, ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In docs/code/Flakes/Tutorials/Installation.md
<#23 (comment)>
:
> @@ -0,0 +1,40 @@
+---
+title: 01-Installation
+date: 2021-02-09
+---
+
+Presuming nix is already installed, Nix flakes are available from Nix version 2.4 and up.
+
+## Non-NixOS
+
+```
+$ nix-env -iA nixpkgs.nixUnstable # or nixpkgs.nix_2_4
Doesn't work on NixOS
nix upgrade-nix
error: Nix on NixOS must be upgraded via 'nixos-rebuild'
—
Reply to this email directly, view it on GitHub
<#23 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AP6TJ4ZMJKWHYBGQWQ72NDTVGKGEBANCNFSM5N7O6TLQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|