Merge pull request #116257 from SuperSandro2000/code-fences

doc/languages-frameworks/*: add missing languages to code fences

Sandro 3a6116c5 354703e6

+7 -7
doc/languages-frameworks/agda.section.md
···
## How to use Agda
Agda can be installed from `agda`:
-
```
+
```ShellSession
$ nix-env -iA agda
```
···
For example, suppose we wanted a version of Agda which has access to the standard library. This can be obtained with the expressions:
-
```
+
```nix
agda.withPackages [ agdaPackages.standard-library ]
```
or
-
```
+
```nix
agda.withPackages (p: [ p.standard-library ])
```
···
Agda will not by default use these libraries. To tell Agda to use the library we have some options:
* Call `agda` with the library flag:
-
```
+
```ShellSession
$ agda -l standard-library -i . MyFile.agda
```
* Write a `my-library.agda-lib` file for the project you are working on which may look like:
···
Agda modules can be compiled with the `--compile` flag. A version of `ghc` with `ieee754` is made available to the Agda program via the `--with-compiler` flag.
This can be overridden by a different version of `ghc` as follows:
-
```
+
```nix
agda.withPackages {
pkgs = [ ... ];
ghc = haskell.compiler.ghcHEAD;
···
## Adding Agda packages to Nixpkgs
To add an Agda package to `nixpkgs`, the derivation should be written to `pkgs/development/libraries/agda/${library-name}/` and an entry should be added to `pkgs/top-level/agda-packages.nix`. Here it is called in a scope with access to all other Agda libraries, so the top line of the `default.nix` can look like:
-
```
+
```nix
{ mkDerivation, standard-library, fetchFromGitHub }:
```
and `mkDerivation` should be called instead of `agdaPackages.mkDerivation`. Here is an example skeleton derivation for iowa-stdlib:
-
```
+
```nix
mkDerivation {
version = "1.5.0";
pname = "iowa-stdlib";
+3 -3
doc/languages-frameworks/dotnet.section.md
···
For local development, it's recommended to use nix-shell to create a dotnet environment:
-
```
+
```nix
# shell.nix
with import <nixpkgs> {};
···
It's very likely that more than one sdk will be needed on a given project. Dotnet provides several different frameworks (E.g dotnetcore, aspnetcore, etc.) as well as many versions for a given framework. Normally, dotnet is able to fetch a framework and install it relative to the executable. However, this would mean writing to the nix store in nixpkgs, which is read-only. To support the many-sdk use case, one can compose an environment using `dotnetCorePackages.combinePackages`:
-
```
+
```nix
with import <nixpkgs> {};
mkShell {
···
This will produce a dotnet installation that has the dotnet 3.1, 3.0, and 2.1 sdk. The first sdk listed will have it's cli utility present in the resulting environment. Example info output:
-
```
+
```ShellSesssion
$ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.1.101
+9 -9
doc/languages-frameworks/idris.section.md
···
The easiest way to get a working idris version is to install the `idris` attribute:
-
```
+
```ShellSesssion
$ # On NixOS
$ nix-env -i nixos.idris
$ # On non-NixOS
···
And then:
-
```
+
```ShellSesssion
$ # On NixOS
$ nix-env -iA nixos.myIdris
$ # On non-NixOS
···
```
To see all available Idris packages:
-
```
+
```ShellSesssion
$ # On NixOS
$ nix-env -qaPA nixos.idrisPackages
$ # On non-NixOS
···
```
Similarly, entering a `nix-shell`:
-
```
+
```ShellSesssion
$ nix-shell -p 'idrisPackages.with-packages (with idrisPackages; [ contrib pruviloj ])'
```
···
To have access to these libraries in idris, call it with an argument `-p <library name>` for each library:
-
```
+
```ShellSesssion
$ nix-shell -p 'idrisPackages.with-packages (with idrisPackages; [ contrib pruviloj ])'
[nix-shell:~]$ idris -p contrib -p pruviloj
```
A listing of all available packages the Idris binary has access to is available via `--listlibs`:
-
```
+
```ShellSesssion
$ idris --listlibs
00prelude-idx.ibc
pruviloj
···
Assuming this file is saved as `yaml.nix`, it's buildable using
-
```
+
```ShellSesssion
$ nix-build -E '(import <nixpkgs> {}).idrisPackages.callPackage ./yaml.nix {}'
```
···
in another file (say `default.nix`) to be able to build it with
-
```
+
```ShellSesssion
$ nix-build -A yaml
```
···
For example you could set
-
```
+
```nix
build-idris-package {
idrisBuildOptions = [ "--log" "1" "--verbose" ]
+4 -4
doc/languages-frameworks/python.section.md
···
By default `nix-shell` will start a `bash` session with this interpreter in our
`PATH`, so if we then run:
-
```
+
```Python console
[nix-shell:~/src/nixpkgs]$ python3
Python 3.8.1 (default, Dec 18 2019, 19:06:26)
[GCC 9.2.0] on linux
···
Note that no other modules are in scope, even if they were imperatively
installed into our user environment as a dependency of a Python application:
-
```
+
```Python console
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
···
Executing this script requires a `python3` that has `numpy`. Using what we learned
in the previous section, we could startup a shell and just run it like so:
-
```
-
nix-shell -p 'python38.withPackages(ps: with ps; [ numpy ])' --run 'python3 foo.py'
+
```ShellSesssion
+
$ nix-shell -p 'python38.withPackages(ps: with ps; [ numpy ])' --run 'python3 foo.py'
The dot product of [1 2] and [3 4] is: 11
```
+3 -3
doc/languages-frameworks/qt.section.md
···
### Example adding a Qt library {#qt-library-all-packages-nix}
The following represents the contents of `qt5-packages.nix`.
-
```
+
```nix
{
# ...
···
### Example adding a Qt application {#qt-application-all-packages-nix}
The following represents the contents of `qt5-packages.nix`.
-
```
+
```nix
{
# ...
···
```
The following represents the contents of `all-packages.nix`.
-
```
+
```nix
{
# ...
+27 -26
doc/languages-frameworks/rust.section.md
···
To install the rust compiler and cargo put
-
```
-
rustc
-
cargo
+
```nix
+
environment.systemPackages = [
+
rustc
+
cargo
+
];
```
-
into the `environment.systemPackages` or bring them into
-
scope with `nix-shell -p rustc cargo`.
+
into your `configuration.nix` or bring them into scope with `nix-shell -p rustc cargo`.
For other versions such as daily builds (beta and nightly),
use either `rustup` from nixpkgs (which will manage the rust installation in your home directory),
···
Rust applications are packaged by using the `buildRustPackage` helper from `rustPlatform`:
-
```
+
```nix
{ lib, rustPlatform }:
rustPlatform.buildRustPackage rec {
···
such as the one in the example above. `cargoHash` should instead be
used for [SRI](https://www.w3.org/TR/SRI/) hashes. For example:
-
```
+
```nix
cargoHash = "sha256-l1vL2ZdtDRxSGvP0X/l3nMw8+6WF67KPutJEzUROjg8=";
```
···
then be taken from the failed build. A fake hash can be used for
`cargoSha256` as follows:
-
```
+
```nix
cargoSha256 = lib.fakeSha256;
```
For `cargoHash` you can use:
-
```
+
```nix
cargoHash = lib.fakeHash;
```
···
source code in a reproducible way. If it is missing or out-of-date one can use
the `cargoPatches` attribute to update or add it.
-
```
+
```nix
rustPlatform.buildRustPackage rec {
(...)
cargoPatches = [
···
Now, the file produced by the call to `carnix`, called `hello.nix`, looks like:
-
```
+
```nix
# Generated by carnix 0.6.5: carnix -o hello.nix --src ./. Cargo.lock --standalone
{ stdenv, buildRustCrate, fetchgit }:
let kernel = stdenv.buildPlatform.parsed.kernel.name;
···
`Cargo.lock`. Then, `carnix` needs to be run again, and produces the
following nix file:
-
```
+
```nix
# Generated by carnix 0.6.5: carnix -o hello.nix --src ./. Cargo.lock --standalone
{ stdenv, buildRustCrate, fetchgit }:
let kernel = stdenv.buildPlatform.parsed.kernel.name;
···
Starting from that file, one can add more overrides, to add features
or build inputs by overriding the hello crate in a seperate file.
-
```
+
```nix
with import <nixpkgs> {};
((import ./hello.nix).hello {}).override {
crateOverrides = defaultCrateOverrides // {
···
the override above can be read, as in the following example, which
patches the derivation:
-
```
+
```nix
with import <nixpkgs> {};
((import ./hello.nix).hello {}).override {
crateOverrides = defaultCrateOverrides // {
···
`libc` in the example above, where `libc` is a dependency of the main
crate, we could do:
-
```
+
```nix
with import <nixpkgs> {};
((import hello.nix).hello {}).override {
crateOverrides = defaultCrateOverrides // {
···
- The version of rustc used to compile the crate:
-
```
+
```nix
(hello {}).override { rust = pkgs.rust; };
```
- Whether to build in release mode or debug mode (release mode by
default):
-
```
+
```nix
(hello {}).override { release = false; };
```
- Whether to print the commands sent to rustc when building
(equivalent to `--verbose` in cargo:
-
```
+
```nix
(hello {}).override { verbose = false; };
```
- Extra arguments to be passed to `rustc`:
-
```
+
```nix
(hello {}).override { extraRustcOpts = "-Z debuginfo=2"; };
```
···
`postInstall`. As an example, here is how to create a new module
before running the build script:
-
```
+
```nix
(hello {}).override {
preConfigure = ''
echo "pub const PATH=\"${hi.out}\";" >> src/path.rs"
···
compile `diesel_cli` only with the `postgres` feature, and no default
features, we would write:
-
```
+
```nix
(callPackage ./diesel.nix {}).diesel {
default = false;
postgres = true;
···
A typical `shell.nix` might look like:
-
```
+
```nix
with import <nixpkgs> {};
stdenv.mkDerivation {
···
```
You should now be able to run the following:
-
```
+
```ShellSesssion
$ nix-shell --pure
$ cargo build
$ cargo test
···
To control your rust version (i.e. use nightly) from within `shell.nix` (or
other nix expressions) you can use the following `shell.nix`
-
```
+
```nix
# Latest Nightly
with import <nixpkgs> {};
let src = fetchFromGitHub {
···
```
Now run:
-
```
+
```ShellSession
$ rustc --version
rustc 1.26.0-nightly (188e693b3 2018-03-26)
```
···
Add the following to your `configuration.nix`, `home-configuration.nix`, `shell.nix`, or similar:
-
```
+
```nix
{ pkgs ? import <nixpkgs> {
overlays = [
(import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz))
+4 -4
doc/languages-frameworks/vim.section.md
···
First create a vim-scripts file having one plugin name per line. Example:
-
```
+
```vim
"tlib"
{'name': 'vim-addon-sql'}
{'filetype_regex': '\%(vim)$', 'names': ['reload', 'vim-dev-plugin']}
···
You should get a Vim buffer with the nix derivations (output1) and vam.pluginDictionaries (output2).
You can add your Vim to your system's configuration file like this and start it by "vim-my":
-
```
+
```nix
my-vim =
let plugins = let inherit (vimUtils) buildVimPluginFrom2Nix; in {
copy paste output1 here
···
Sample output1:
-
```
+
```nix
"reload" = buildVimPluginFrom2Nix { # created by nix#NixDerivation
name = "reload";
src = fetchgit {
···
Some plugins require overrides in order to function properly. Overrides are placed in [overrides.nix](/pkgs/misc/vim-plugins/overrides.nix). Overrides are most often required when a plugin requires some dependencies, or extra steps are required during the build process. For example `deoplete-fish` requires both `deoplete-nvim` and `vim-fish`, and so the following override was added:
-
```
+
```nix
deoplete-fish = super.deoplete-fish.overrideAttrs(old: {
dependencies = with super; [ deoplete-nvim vim-fish ];
});