···180 </listitem>
181 <listitem>
182 <para>
000000183 Prefer using the top-level <varname>lib</varname> over its alias
184 <literal>stdenv.lib</literal>. <varname>lib</varname> is unrelated to
185 <varname>stdenv</varname>, and so <literal>stdenv.lib</literal> should only
···180 </listitem>
181 <listitem>
182 <para>
183+ Arguments should be listed in the order they are used, with the
184+ exception of <varname>lib</varname>, which always goes first.
185+ </para>
186+ </listitem>
187+ <listitem>
188+ <para>
189 Prefer using the top-level <varname>lib</varname> over its alias
190 <literal>stdenv.lib</literal>. <varname>lib</varname> is unrelated to
191 <varname>stdenv</varname>, and so <literal>stdenv.lib</literal> should only
+2-2
doc/languages-frameworks/coq.section.md
···42Here is a simple package example. It is a pure Coq library, thus it depends on Coq. It builds on the Mathematical Components library, thus it also takes some `mathcomp` derivations as `extraBuildInputs`.
4344```nix
45-{ coq, mkCoqDerivation, mathcomp, mathcomp-finmap, mathcomp-bigenough,
46- lib, version ? null }:
47with lib; mkCoqDerivation {
48 /* namePrefix leads to e.g. `name = coq8.11-mathcomp1.11-multinomials-1.5.2` */
49 namePrefix = [ "coq" "mathcomp" ];
···42Here is a simple package example. It is a pure Coq library, thus it depends on Coq. It builds on the Mathematical Components library, thus it also takes some `mathcomp` derivations as `extraBuildInputs`.
4344```nix
45+{ lib, mkCoqDerivation, version ? null
46+, coq, mathcomp, mathcomp-finmap, mathcomp-bigenough }:
47with lib; mkCoqDerivation {
48 /* namePrefix leads to e.g. `name = coq8.11-mathcomp1.11-multinomials-1.5.2` */
49 namePrefix = [ "coq" "mathcomp" ];
+5-5
doc/languages-frameworks/idris.section.md
···69As an example of how a Nix expression for an Idris package can be created, here is the one for `idrisPackages.yaml`:
7071```nix
72-{ build-idris-package
073, fetchFromGitHub
74, contrib
75, lightyear
76-, lib
77}:
78build-idris-package {
79 name = "yaml";
···94 sha256 = "1g4pi0swmg214kndj85hj50ccmckni7piprsxfdzdfhg87s0avw7";
95 };
9697- meta = {
98 description = "Idris YAML lib";
99 homepage = "https://github.com/Heather/Idris.Yaml";
100- license = lib.licenses.mit;
101- maintainers = [ lib.maintainers.brainrape ];
102 };
103}
104```
···69As an example of how a Nix expression for an Idris package can be created, here is the one for `idrisPackages.yaml`:
7071```nix
72+{ lib
73+, build-idris-package
74, fetchFromGitHub
75, contrib
76, lightyear
077}:
78build-idris-package {
79 name = "yaml";
···94 sha256 = "1g4pi0swmg214kndj85hj50ccmckni7piprsxfdzdfhg87s0avw7";
95 };
9697+ meta = with lib; {
98 description = "Idris YAML lib";
99 homepage = "https://github.com/Heather/Idris.Yaml";
100+ license = licenses.mit;
101+ maintainers = [ maintainers.brainrape ];
102 };
103}
104```
+4-4
doc/languages-frameworks/maven.section.md
···116> Traditionally the Maven repository is at `~/.m2/repository`. We will override this to be the `$out` directory.
117118```nix
119-{ stdenv, lib, maven }:
120stdenv.mkDerivation {
121 name = "maven-repository";
122 buildInputs = [ maven ];
···168Regardless of which strategy is chosen above, the step to build the derivation is the same.
169170```nix
171-{ stdenv, lib, maven, callPackage }:
172# pick a repository derivation, here we will use buildMaven
173let repository = callPackage ./build-maven-repository.nix { };
174in stdenv.mkDerivation rec {
···222We make sure to provide this classpath to the `makeWrapper`.
223224```nix
225-{ stdenv, lib, maven, callPackage, makeWrapper, jre }:
226let
227 repository = callPackage ./build-maven-repository.nix { };
228in stdenv.mkDerivation rec {
···298We will modify the derivation above to add a symlink to our repository so that it's accessible to our JAR during the `installPhase`.
299300```nix
301-{ stdenv, lib, maven, callPackage, makeWrapper, jre }:
302# pick a repository derivation, here we will use buildMaven
303let repository = callPackage ./build-maven-repository.nix { };
304in stdenv.mkDerivation rec {
···116> Traditionally the Maven repository is at `~/.m2/repository`. We will override this to be the `$out` directory.
117118```nix
119+{ lib, stdenv, maven }:
120stdenv.mkDerivation {
121 name = "maven-repository";
122 buildInputs = [ maven ];
···168Regardless of which strategy is chosen above, the step to build the derivation is the same.
169170```nix
171+{ stdenv, maven, callPackage }:
172# pick a repository derivation, here we will use buildMaven
173let repository = callPackage ./build-maven-repository.nix { };
174in stdenv.mkDerivation rec {
···222We make sure to provide this classpath to the `makeWrapper`.
223224```nix
225+{ stdenv, maven, callPackage, makeWrapper, jre }:
226let
227 repository = callPackage ./build-maven-repository.nix { };
228in stdenv.mkDerivation rec {
···298We will modify the derivation above to add a symlink to our repository so that it's accessible to our JAR during the `installPhase`.
299300```nix
301+{ stdenv, maven, callPackage, makeWrapper, jre }:
302# pick a repository derivation, here we will use buildMaven
303let repository = callPackage ./build-maven-repository.nix { };
304in stdenv.mkDerivation rec {
+3-3
doc/languages-frameworks/ocaml.section.md
···32 propagatedBuildInputs = [ bigstringaf result ];
33 doCheck = true;
3435- meta = {
36 homepage = "https://github.com/inhabitedtype/angstrom";
37 description = "OCaml parser combinators built for speed and memory efficiency";
38- license = lib.licenses.bsd3;
39- maintainers = with lib.maintainers; [ sternenseemann ];
40 };
41}
42```
···32 propagatedBuildInputs = [ bigstringaf result ];
33 doCheck = true;
3435+ meta = with lib; {
36 homepage = "https://github.com/inhabitedtype/angstrom";
37 description = "OCaml parser combinators built for speed and memory efficiency";
38+ license = licenses.bsd3;
39+ maintainers = with maintainers; [ sternenseemann ];
40 };
41}
42```
+1-1
doc/languages-frameworks/perl.section.md
···110On Darwin, if a script has too many `-Idir` flags in its first line (its “shebang line”), it will not run. This can be worked around by calling the `shortenPerlShebang` function from the `postInstall` phase:
111112```nix
113-{ stdenv, lib, buildPerlPackage, fetchurl, shortenPerlShebang }:
114115ImageExifTool = buildPerlPackage {
116 pname = "Image-ExifTool";
···110On Darwin, if a script has too many `-Idir` flags in its first line (its “shebang line”), it will not run. This can be worked around by calling the `shortenPerlShebang` function from the `postInstall` phase:
111112```nix
113+{ lib, stdenv, buildPerlPackage, fetchurl, shortenPerlShebang }:
114115ImageExifTool = buildPerlPackage {
116 pname = "Image-ExifTool";
···32environment available for other contributors, you can create a `default.nix`
33file like so:
34```nix
35-let
36- pkgs = import <nixpkgs> {};
37- stdenv = pkgs.stdenv;
38-in with pkgs; {
39 myProject = stdenv.mkDerivation {
40 name = "myProject";
41 version = "1";
42- src = if pkgs.lib.inNixShell then null else nix;
4344 buildInputs = with rPackages; [
45 R
···32environment available for other contributors, you can create a `default.nix`
33file like so:
34```nix
35+with import <nixpkgs> {};
36+{
0037 myProject = stdenv.mkDerivation {
38 name = "myProject";
39 version = "1";
40+ src = if lib.inNixShell then null else nix;
4142 buildInputs = with rPackages; [
43 R
+1-1
doc/languages-frameworks/ruby.section.md
···232Now you can also also make a `default.nix` that looks like this:
233234```nix
235-{ lib, bundlerApp }:
236237bundlerApp {
238 pname = "mdl";
···232Now you can also also make a `default.nix` that looks like this:
233234```nix
235+{ bundlerApp }:
236237bundlerApp {
238 pname = "mdl";
+4-4
doc/languages-frameworks/rust.section.md
···19Rust applications are packaged by using the `buildRustPackage` helper from `rustPlatform`:
2021```
0022rustPlatform.buildRustPackage rec {
23 pname = "ripgrep";
24 version = "12.1.1";
···226the `cargoPatches` attribute to update or add it.
227228```
229-{ lib, rustPlatform, fetchFromGitHub }:
230-231rustPlatform.buildRustPackage rec {
232 (...)
233 cargoPatches = [
···263264```
265# Generated by carnix 0.6.5: carnix -o hello.nix --src ./. Cargo.lock --standalone
266-{ lib, stdenv, buildRustCrate, fetchgit }:
267let kernel = stdenv.buildPlatform.parsed.kernel.name;
268 # ... (content skipped)
269in
···292293```
294# Generated by carnix 0.6.5: carnix -o hello.nix --src ./. Cargo.lock --standalone
295-{ lib, stdenv, buildRustCrate, fetchgit }:
296let kernel = stdenv.buildPlatform.parsed.kernel.name;
297 # ... (content skipped)
298in
···19Rust applications are packaged by using the `buildRustPackage` helper from `rustPlatform`:
2021```
22+{ lib, rustPlatform }:
23+24rustPlatform.buildRustPackage rec {
25 pname = "ripgrep";
26 version = "12.1.1";
···228the `cargoPatches` attribute to update or add it.
229230```
00231rustPlatform.buildRustPackage rec {
232 (...)
233 cargoPatches = [
···263264```
265# Generated by carnix 0.6.5: carnix -o hello.nix --src ./. Cargo.lock --standalone
266+{ stdenv, buildRustCrate, fetchgit }:
267let kernel = stdenv.buildPlatform.parsed.kernel.name;
268 # ... (content skipped)
269in
···292293```
294# Generated by carnix 0.6.5: carnix -o hello.nix --src ./. Cargo.lock --standalone
295+{ stdenv, buildRustCrate, fetchgit }:
296let kernel = stdenv.buildPlatform.parsed.kernel.name;
297 # ... (content skipped)
298in
···1-import ./make-test-python.nix ( { pkgs, ... }: {
002 name = "opentabletdriver";
3 meta = {
4 maintainers = with pkgs.lib.maintainers; [ thiagokokada ];
···10 ./common/user-account.nix
11 ./common/x11.nix
12 ];
13- test-support.displayManager.auto.user = "alice";
14 hardware.opentabletdriver.enable = true;
15 };
16···18 ''
19 machine.start()
20 machine.wait_for_x()
21- machine.wait_for_unit("opentabletdriver.service", "alice")
2223- machine.succeed("cat /etc/udev/rules.d/30-opentabletdriver.rules")
24 # Will fail if service is not running
25- machine.succeed("otd detect")
026 '';
27})
···1+import ./make-test-python.nix ( { pkgs, ... }: let
2+ testUser = "alice";
3+in {
4 name = "opentabletdriver";
5 meta = {
6 maintainers = with pkgs.lib.maintainers; [ thiagokokada ];
···12 ./common/user-account.nix
13 ./common/x11.nix
14 ];
15+ test-support.displayManager.auto.user = testUser;
16 hardware.opentabletdriver.enable = true;
17 };
18···20 ''
21 machine.start()
22 machine.wait_for_x()
23+ machine.wait_for_unit("opentabletdriver.service", "${testUser}")
2425+ machine.succeed("cat /etc/udev/rules.d/99-opentabletdriver.rules")
26 # Will fail if service is not running
27+ # Needs to run as the same user that started the service
28+ machine.succeed("su - ${testUser} -c 'otd detect'")
29 '';
30})
+14-1
nixos/tests/podman.nix
···61 podman.succeed("podman stop sleeping")
62 podman.succeed("podman rm sleeping")
630000000000000064 with subtest("Run container rootless with crun"):
65 podman.succeed(su_cmd("tar cv --files-from /dev/null | podman import - scratchimg"))
66 podman.succeed(
···71 podman.succeed(su_cmd("podman ps | grep sleeping"))
72 podman.succeed(su_cmd("podman stop sleeping"))
73 podman.succeed(su_cmd("podman rm sleeping"))
74- # As of 2020-11-20, the runc backend doesn't work with cgroupsv2 yet, so we don't run that test.
7576 with subtest("Run container rootless with the default backend"):
77 podman.succeed(su_cmd("tar cv --files-from /dev/null | podman import - scratchimg"))
···36`nixosTests.chromium` (or basic manual testing) and `google-chrome` (which
37reuses `upstream-info.json`).
3800000000000000039## Backports
4041All updates are considered security critical and should be ported to the stable
···36`nixosTests.chromium` (or basic manual testing) and `google-chrome` (which
37reuses `upstream-info.json`).
3839+To run all automated NixOS VM tests for Chromium, ungoogled-chromium,
40+and Google Chrome (not recommended, currently 6x tests!):
41+```
42+nix-build nixos/tests/chromium.nix
43+```
44+45+A single test can be selected, e.g. to test `ungoogled-chromium` (see
46+`channelMap` in `nixos/tests/chromium.nix` for all available options):
47+```
48+nix-build nixos/tests/chromium.nix -A ungoogled
49+```
50+(Note: Testing Google Chrome requires `export NIXPKGS_ALLOW_UNFREE=1`.)
51+52+For custom builds it's possible to "override" `channelMap`.
53+54## Backports
5556All updates are considered security critical and should be ported to the stable
···25 else "");
26in stdenv.mkDerivation rec {
27 pname = "signal-desktop";
28- version = "1.39.5"; # Please backport all updates to the stable channel.
29 # All releases have a limited lifetime and "expire" 90 days after the release.
30 # When releases "expire" the application becomes unusable until an update is
31 # applied. The expiration date for the current release can be extracted with:
···3536 src = fetchurl {
37 url = "https://updates.signal.org/desktop/apt/pool/main/s/signal-desktop/signal-desktop_${version}_amd64.deb";
38- sha256 = "1x29ri4jxd1q2wbv5gf26x986x9sms4rxnhj7d5rhm6pz2ihzb2a";
39 };
4041 nativeBuildInputs = [
···25 else "");
26in stdenv.mkDerivation rec {
27 pname = "signal-desktop";
28+ version = "1.39.6"; # Please backport all updates to the stable channel.
29 # All releases have a limited lifetime and "expire" 90 days after the release.
30 # When releases "expire" the application becomes unusable until an update is
31 # applied. The expiration date for the current release can be extracted with:
···3536 src = fetchurl {
37 url = "https://updates.signal.org/desktop/apt/pool/main/s/signal-desktop/signal-desktop_${version}_amd64.deb";
38+ sha256 = "04fd81vc0dxk0b47crm5zacf4x79pdn483xicygnc1z6v7mnrmgk";
39 };
4041 nativeBuildInputs = [
···14 [[ "${1}" != "--force" ]] && exit 0
15fi
1617+# Updating the hash of deb package manually since there seems to be no way to do it automatically
18+oldDebPkgUrl="https://github.com/InfinityGhost/OpenTabletDriver/releases/download/v${old_version}/OpenTabletDriver.deb";
19+newDebPkgUrl="https://github.com/InfinityGhost/OpenTabletDriver/releases/download/v${new_version}/OpenTabletDriver.deb";
20+oldDebSha256=$(nix-prefetch-url "$oldDebPkgUrl")
21+newDebSha256=$(nix-prefetch-url "$newDebPkgUrl")
22+echo "oldDebSha256: $oldDebSha256 newDebSha256: $newDebSha256"
23+sed -i ./default.nix -re "s|\"$oldDebSha256\"|\"$newDebSha256\"|"
24+25cd ../../../..
26update-source-version opentabletdriver "$new_version"
27store_src="$(nix-build . -A opentabletdriver.src --no-out-link)"
···22 meta = with lib; {
23 description = "Redact and strip metadata from documents before publishing";
24 longDescription = ''
25- PDF Redact Tools helps with securely redacting and stripping metadata
26- from documents before publishing. Note that this is not a security tool.
27 It uses ImageMagick to parse PDFs. While ImageMagick is a versatile tool, it has
28 a history of several security bugs. A malicious PDF could exploit a bug in
29 ImageMagick to take over your computer. If you're working with potentially
···22 meta = with lib; {
23 description = "Redact and strip metadata from documents before publishing";
24 longDescription = ''
25+ PDF Redact Tools helps with securely redacting and stripping metadata
26+ from documents before publishing. Note that this is not a security tool.
27 It uses ImageMagick to parse PDFs. While ImageMagick is a versatile tool, it has
28 a history of several security bugs. A malicious PDF could exploit a bug in
29 ImageMagick to take over your computer. If you're working with potentially