doc: cleanup (#400164)

This commit is contained in:
Aleksana 2025-04-21 13:53:40 +08:00 committed by GitHub
commit c4170d9f2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 347 additions and 238 deletions

View File

@ -33,7 +33,7 @@ let
version = "0.6.30"; version = "0.6.30";
src = fetchurl { src = fetchurl {
url = "https://github.com/nukeop/nuclear/releases/download/v${version}/${pname}-v${version}.AppImage"; url = "https://github.com/nukeop/nuclear/releases/download/v${version}/nuclear-v${version}.AppImage";
hash = "sha256-he1uGC1M/nFcKpMM9JKY4oeexJcnzV0ZRxhTjtJz6xw="; hash = "sha256-he1uGC1M/nFcKpMM9JKY4oeexJcnzV0ZRxhTjtJz6xw=";
}; };
in in

View File

@ -49,6 +49,8 @@ stdenvNoCC.mkDerivation (
''; '';
buildPhase = '' buildPhase = ''
runHook preBuild
substituteInPlace ./languages-frameworks/python.section.md \ substituteInPlace ./languages-frameworks/python.section.md \
--subst-var-by python-interpreter-table "$(<"${pythonInterpreterTable}")" --subst-var-by python-interpreter-table "$(<"${pythonInterpreterTable}")"
@ -84,9 +86,13 @@ stdenvNoCC.mkDerivation (
--section-toc-depth 1 \ --section-toc-depth 1 \
manual.md \ manual.md \
out/index.html out/index.html
runHook postBuild
''; '';
installPhase = '' installPhase = ''
runHook preInstall
dest="$out/share/doc/nixpkgs" dest="$out/share/doc/nixpkgs"
mkdir -p "$(dirname "$dest")" mkdir -p "$(dirname "$dest")"
mv out "$dest" mv out "$dest"
@ -97,6 +103,8 @@ stdenvNoCC.mkDerivation (
mkdir -p $out/nix-support/ mkdir -p $out/nix-support/
echo "doc manual $dest manual.html" >> $out/nix-support/hydra-build-products echo "doc manual $dest manual.html" >> $out/nix-support/hydra-build-products
echo "doc manual $dest nixpkgs-manual.epub" >> $out/nix-support/hydra-build-products echo "doc manual $dest nixpkgs-manual.epub" >> $out/nix-support/hydra-build-products
runHook postInstall
''; '';
passthru = { passthru = {

View File

@ -27,8 +27,8 @@ let
} ":"; } ":";
}; };
# the INI file can now be given as plain old nix values
in in
# the INI file can now be given as plain old nix values
customToINI { customToINI {
main = { main = {
pushinfo = true; pushinfo = true;

View File

@ -23,15 +23,15 @@ In Nixpkgs, `cargo-tauri.hook` overrides the default build and install phases.
wrapGAppsHook4, wrapGAppsHook4,
}: }:
rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage (finalAttrs: {
# . . . # ...
useFetchCargoVendor = true; useFetchCargoVendor = true;
cargoHash = "..."; cargoHash = "...";
# Assuming our app's frontend uses `npm` as a package manager # Assuming our app's frontend uses `npm` as a package manager
npmDeps = fetchNpmDeps { npmDeps = fetchNpmDeps {
name = "${pname}-npm-deps-${version}"; name = "${finalAttrs.pname}-npm-deps-${finalAttrs.version}";
inherit src; inherit src;
hash = "..."; hash = "...";
}; };
@ -61,8 +61,8 @@ rustPlatform.buildRustPackage rec {
# And make sure we build there too # And make sure we build there too
buildAndTestSubdir = cargoRoot; buildAndTestSubdir = cargoRoot;
# . . . # ...
} })
``` ```
## Variables controlling cargo-tauri {#tauri-hook-variables-controlling} ## Variables controlling cargo-tauri {#tauri-hook-variables-controlling}

View File

@ -208,8 +208,12 @@ mkDerivation {
libraryName = "IAL-1.3"; libraryName = "IAL-1.3";
buildPhase = '' buildPhase = ''
runHook preBuild
patchShebangs find-deps.sh patchShebangs find-deps.sh
make make
runHook postBuild
''; '';
} }
``` ```

View File

@ -105,10 +105,17 @@ pkgs.stdenv.mkDerivation {
src = myWebApp; src = myWebApp;
}; };
nativeBuildInputs = [
writableTmpDirAsHomeHook # note 3
];
buildPhase = '' buildPhase = ''
runHook preBuild
cp --reflink=auto --no-preserve=mode -R $bowerComponents/bower_components . # note 2 cp --reflink=auto --no-preserve=mode -R $bowerComponents/bower_components . # note 2
export HOME=$PWD # note 3
${pkgs.nodePackages.gulp}/bin/gulp build # note 4 ${pkgs.nodePackages.gulp}/bin/gulp build # note 4
runHook postBuild
''; '';
installPhase = "mv gulpdist $out"; installPhase = "mv gulpdist $out";

View File

@ -42,8 +42,8 @@ buildDartApplication rec {
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "sass"; owner = "sass";
repo = pname; repo = "dart-sass";
rev = version; tag = version;
hash = "sha256-U6enz8yJcc4Wf8m54eYIAnVg/jsGi247Wy8lp1r1wg4="; hash = "sha256-U6enz8yJcc4Wf8m54eYIAnVg/jsGi247Wy8lp1r1wg4=";
}; };

View File

@ -22,7 +22,7 @@ buildDubPackage rec {
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "CyberShadow"; owner = "CyberShadow";
repo = "btdu"; repo = "btdu";
rev = "v${version}"; tag = "v${version}";
hash = "sha256-3sSZq+5UJH02IO0Y1yL3BLHDb4lk8k6awb5ZysBQciE="; hash = "sha256-3sSZq+5UJH02IO0Y1yL3BLHDb4lk8k6awb5ZysBQciE=";
}; };

View File

@ -41,12 +41,13 @@ One advantage is that when `pkgs.zlib` is updated, it will automatically update
(pkgs.zlib.override { (pkgs.zlib.override {
stdenv = pkgs.emscriptenStdenv; stdenv = pkgs.emscriptenStdenv;
}).overrideAttrs }).overrideAttrs
(old: rec { (old: {
buildInputs = old.buildInputs ++ [ pkg-config ]; buildInputs = old.buildInputs ++ [ pkg-config ];
# we need to reset this setting! # we need to reset this setting!
env = (old.env or { }) // { env = (old.env or { }) // {
NIX_CFLAGS_COMPILE = ""; NIX_CFLAGS_COMPILE = "";
}; };
configurePhase = '' configurePhase = ''
# FIXME: Some tests require writing at $HOME # FIXME: Some tests require writing at $HOME
HOME=$TMPDIR HOME=$TMPDIR
@ -57,15 +58,29 @@ One advantage is that when `pkgs.zlib` is updated, it will automatically update
runHook postConfigure runHook postConfigure
''; '';
dontStrip = true; dontStrip = true;
outputs = [ "out" ]; outputs = [ "out" ];
buildPhase = '' buildPhase = ''
runHook preBuild
emmake make emmake make
runHook postBuild
''; '';
installPhase = '' installPhase = ''
runHook preInstall
emmake make install emmake make install
runHook postInstall
''; '';
checkPhase = '' checkPhase = ''
runHook preCheck
echo "================= testing zlib using node =================" echo "================= testing zlib using node ================="
echo "Compiling a custom test" echo "Compiling a custom test"
@ -84,6 +99,8 @@ One advantage is that when `pkgs.zlib` is updated, it will automatically update
echo "it seems to work! very good." echo "it seems to work! very good."
fi fi
echo "================= /testing zlib using node =================" echo "================= /testing zlib using node ================="
runHook postCheck
''; '';
postPatch = pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isDarwin '' postPatch = pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isDarwin ''
@ -102,8 +119,9 @@ One advantage is that when `pkgs.zlib` is updated, it will automatically update
This `xmlmirror` example features an Emscripten package that is defined completely from this context and no `pkgs.zlib.override` is used. This `xmlmirror` example features an Emscripten package that is defined completely from this context and no `pkgs.zlib.override` is used.
```nix ```nix
pkgs.buildEmscriptenPackage rec { pkgs.buildEmscriptenPackage {
name = "xmlmirror"; pname = "xmlmirror";
version = "1.2.3";
buildInputs = [ buildInputs = [
pkg-config pkg-config
@ -116,8 +134,10 @@ pkgs.buildEmscriptenPackage rec {
openjdk openjdk
json_c json_c
]; ];
nativeBuildInputs = [ nativeBuildInputs = [
pkg-config pkg-config
writableTmpDirAsHomeHook
zlib zlib
]; ];
@ -128,6 +148,8 @@ pkgs.buildEmscriptenPackage rec {
}; };
configurePhase = '' configurePhase = ''
runHook preConfigure
rm -f fastXmlLint.js* rm -f fastXmlLint.js*
# a fix for ERROR:root:For asm.js, TOTAL_MEMORY must be a multiple of 16MB, was 234217728 # a fix for ERROR:root:For asm.js, TOTAL_MEMORY must be a multiple of 16MB, was 234217728
# https://gitlab.com/odfplugfest/xmlmirror/issues/8 # https://gitlab.com/odfplugfest/xmlmirror/issues/8
@ -137,11 +159,16 @@ pkgs.buildEmscriptenPackage rec {
sed -e "s/\$(JSONC_LDFLAGS) \$(ZLIB_LDFLAGS) \$(LIBXML20_LDFLAGS)/\$(JSONC_LDFLAGS) \$(LIBXML20_LDFLAGS) \$(ZLIB_LDFLAGS) /g" -i Makefile.emEnv sed -e "s/\$(JSONC_LDFLAGS) \$(ZLIB_LDFLAGS) \$(LIBXML20_LDFLAGS)/\$(JSONC_LDFLAGS) \$(LIBXML20_LDFLAGS) \$(ZLIB_LDFLAGS) /g" -i Makefile.emEnv
# https://gitlab.com/odfplugfest/xmlmirror/issues/11 # https://gitlab.com/odfplugfest/xmlmirror/issues/11
sed -e "s/-o fastXmlLint.js/-s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]' -o fastXmlLint.js/g" -i Makefile.emEnv sed -e "s/-o fastXmlLint.js/-s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]' -o fastXmlLint.js/g" -i Makefile.emEnv
runHook postConfigure
''; '';
buildPhase = '' buildPhase = ''
HOME=$TMPDIR runHook preBuild
make -f Makefile.emEnv make -f Makefile.emEnv
runHook postBuild
''; '';
outputs = [ outputs = [
@ -150,6 +177,8 @@ pkgs.buildEmscriptenPackage rec {
]; ];
installPhase = '' installPhase = ''
runHook preInstall
mkdir -p $out/share mkdir -p $out/share
mkdir -p $doc/share/${name} mkdir -p $doc/share/${name}
@ -163,9 +192,13 @@ pkgs.buildEmscriptenPackage rec {
cp *.json $out/share cp *.json $out/share
cp *.rng $out/share cp *.rng $out/share
cp README.md $doc/share/${name} cp README.md $doc/share/${name}
runHook postInstall
''; '';
checkPhase = ''
checkPhase = ''
runHook preCheck
runHook postCheck
''; '';
} }
``` ```

View File

@ -13,14 +13,14 @@ The following is an example expression using `buildGoModule`:
```nix ```nix
{ {
pet = buildGoModule rec { pet = buildGoModule (finalAttrs: {
pname = "pet"; pname = "pet";
version = "0.3.4"; version = "0.3.4";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "knqyf263"; owner = "knqyf263";
repo = "pet"; repo = "pet";
rev = "v${version}"; tag = "v${finalAttrs.version}";
hash = "sha256-Gjw1dRrgM8D3G7v6WIM2+50r4HmTXvx0Xxme2fH9TlQ="; hash = "sha256-Gjw1dRrgM8D3G7v6WIM2+50r4HmTXvx0Xxme2fH9TlQ=";
}; };
@ -32,7 +32,7 @@ The following is an example expression using `buildGoModule`:
license = lib.licenses.mit; license = lib.licenses.mit;
maintainers = with lib.maintainers; [ kalbasit ]; maintainers = with lib.maintainers; [ kalbasit ];
}; };
}; });
} }
``` ```

View File

@ -198,14 +198,14 @@ Here's an example:
fetchFromGitHub, fetchFromGitHub,
}: }:
buildNpmPackage rec { buildNpmPackage (finalAttrs: {
pname = "flood"; pname = "flood";
version = "4.7.0"; version = "4.7.0";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "jesec"; owner = "jesec";
repo = pname; repo = "flood";
rev = "v${version}"; tag = "v${finalAttrs.version}";
hash = "sha256-BR+ZGkBBfd0dSQqAvujsbgsEPFYw/ThrylxUbOksYxM="; hash = "sha256-BR+ZGkBBfd0dSQqAvujsbgsEPFYw/ThrylxUbOksYxM=";
}; };
@ -222,7 +222,7 @@ buildNpmPackage rec {
license = lib.licenses.gpl3Only; license = lib.licenses.gpl3Only;
maintainers = with lib.maintainers; [ winter ]; maintainers = with lib.maintainers; [ winter ];
}; };
} })
``` ```
In the default `installPhase` set by `buildNpmPackage`, it uses `npm pack --json --dry-run` to decide what files to install in `$out/lib/node_modules/$name/`, where `$name` is the `name` string defined in the package's `package.json`. In the default `installPhase` set by `buildNpmPackage`, it uses `npm pack --json --dry-run` to decide what files to install in `$out/lib/node_modules/$name/`, where `$name` is the `name` string defined in the package's `package.json`.
@ -646,9 +646,16 @@ It's important to use the `--offline` flag. For example if you script is `"build
```nix ```nix
{ {
nativeBuildInputs = [
writableTmpDirAsHomeHook
];
buildPhase = '' buildPhase = ''
export HOME=$(mktemp -d) runHook preBuild
yarn --offline build yarn --offline build
runHook postBuild
''; '';
} }
``` ```

View File

@ -135,7 +135,6 @@ During Quicklisp import:
- names starting with a number have a `_` prepended (`3d-vectors`->`_3d-vectors`) - names starting with a number have a `_` prepended (`3d-vectors`->`_3d-vectors`)
- `_` in names is converted to `__` for reversibility - `_` in names is converted to `__` for reversibility
## Defining packages manually inside Nixpkgs {#lisp-defining-packages-inside} ## Defining packages manually inside Nixpkgs {#lisp-defining-packages-inside}
Packages that for some reason are not in Quicklisp, and so cannot be Packages that for some reason are not in Quicklisp, and so cannot be
@ -185,7 +184,7 @@ let
domain = "gitlab.common-lisp.net"; domain = "gitlab.common-lisp.net";
owner = "alexandria"; owner = "alexandria";
repo = "alexandria"; repo = "alexandria";
rev = "v${version}"; tag = "v${version}";
hash = "sha256-1Hzxt65dZvgOFIljjjlSGgKYkj+YBLwJCACi5DZsKmQ="; hash = "sha256-1Hzxt65dZvgOFIljjjlSGgKYkj+YBLwJCACi5DZsKmQ=";
}; };
}; };
@ -212,7 +211,7 @@ sbcl.pkgs.alexandria.overrideLispAttrs (oldAttrs: rec {
domain = "gitlab.common-lisp.net"; domain = "gitlab.common-lisp.net";
owner = "alexandria"; owner = "alexandria";
repo = "alexandria"; repo = "alexandria";
rev = "v${version}"; tag = "v${version}";
hash = "sha256-1Hzxt65dZvgOFIljjjlSGgKYkj+YBLwJCACi5DZsKmQ="; hash = "sha256-1Hzxt65dZvgOFIljjjlSGgKYkj+YBLwJCACi5DZsKmQ=";
}; };
}) })

View File

@ -23,8 +23,8 @@ maven.buildMavenPackage rec {
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "intoolswetrust"; owner = "intoolswetrust";
repo = pname; repo = "jd-cli";
rev = "${pname}-${version}"; tag = "jd-cli-${version}";
hash = "sha256-rRttA5H0A0c44loBzbKH7Waoted3IsOgxGCD2VM0U/Q="; hash = "sha256-rRttA5H0A0c44loBzbKH7Waoted3IsOgxGCD2VM0U/Q=";
}; };
@ -33,11 +33,15 @@ maven.buildMavenPackage rec {
nativeBuildInputs = [ makeWrapper ]; nativeBuildInputs = [ makeWrapper ];
installPhase = '' installPhase = ''
runHook preInstall
mkdir -p $out/bin $out/share/jd-cli mkdir -p $out/bin $out/share/jd-cli
install -Dm644 jd-cli/target/jd-cli.jar $out/share/jd-cli install -Dm644 jd-cli/target/jd-cli.jar $out/share/jd-cli
makeWrapper ${jre}/bin/java $out/bin/jd-cli \ makeWrapper ${jre}/bin/java $out/bin/jd-cli \
--add-flags "-jar $out/share/jd-cli/jd-cli.jar" --add-flags "-jar $out/share/jd-cli/jd-cli.jar"
runHook postInstall
''; '';
meta = { meta = {
@ -301,16 +305,24 @@ stdenv.mkDerivation {
buildInputs = [ maven ]; buildInputs = [ maven ];
src = ./.; # or fetchFromGitHub, cleanSourceWith, etc src = ./.; # or fetchFromGitHub, cleanSourceWith, etc
buildPhase = '' buildPhase = ''
runHook preBuild
mvn package -Dmaven.repo.local=$out mvn package -Dmaven.repo.local=$out
runHook postBuild
''; '';
# keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside # keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside
installPhase = '' installPhase = ''
runHook preInstall
find $out -type f \ find $out -type f \
-name \*.lastUpdated -or \ -name \*.lastUpdated -or \
-name resolver-status.properties -or \ -name resolver-status.properties -or \
-name _remote.repositories \ -name _remote.repositories \
-delete -delete
runHook postInstall
''; '';
# don't do any fixup # don't do any fixup
@ -354,11 +366,11 @@ Regardless of which strategy is chosen above, the step to build the derivation i
maven, maven,
callPackage, callPackage,
}: }:
# pick a repository derivation, here we will use buildMaven
let let
# pick a repository derivation, here we will use buildMaven
repository = callPackage ./build-maven-repository.nix { }; repository = callPackage ./build-maven-repository.nix { };
in in
stdenv.mkDerivation rec { stdenv.mkDerivation (finalAttrs: {
pname = "maven-demo"; pname = "maven-demo";
version = "1.0"; version = "1.0";
@ -366,14 +378,22 @@ stdenv.mkDerivation rec {
buildInputs = [ maven ]; buildInputs = [ maven ];
buildPhase = '' buildPhase = ''
runHook preBuild
echo "Using repository ${repository}" echo "Using repository ${repository}"
mvn --offline -Dmaven.repo.local=${repository} package; mvn --offline -Dmaven.repo.local=${repository} package;
runHook postBuild
''; '';
installPhase = '' installPhase = ''
install -Dm644 target/${pname}-${version}.jar $out/share/java runHook preInstall
install -Dm644 target/${finalAttrs.pname}-${finalAttrs.version}.jar $out/share/java
runHook postInstall
''; '';
} })
``` ```
::: {.tip} ::: {.tip}
@ -421,7 +441,7 @@ We make sure to provide this classpath to the `makeWrapper`.
let let
repository = callPackage ./build-maven-repository.nix { }; repository = callPackage ./build-maven-repository.nix { };
in in
stdenv.mkDerivation rec { stdenv.mkDerivation (finalAttrs: {
pname = "maven-demo"; pname = "maven-demo";
version = "1.0"; version = "1.0";
@ -430,22 +450,30 @@ stdenv.mkDerivation rec {
buildInputs = [ maven ]; buildInputs = [ maven ];
buildPhase = '' buildPhase = ''
runHook preBuild
echo "Using repository ${repository}" echo "Using repository ${repository}"
mvn --offline -Dmaven.repo.local=${repository} package; mvn --offline -Dmaven.repo.local=${repository} package;
runHook postBuild
''; '';
installPhase = '' installPhase = ''
runHook preInstall
mkdir -p $out/bin mkdir -p $out/bin
classpath=$(find ${repository} -name "*.jar" -printf ':%h/%f'); classpath=$(find ${repository} -name "*.jar" -printf ':%h/%f');
install -Dm644 target/${pname}-${version}.jar $out/share/java install -Dm644 target/maven-demo-${finalAttrs.version}.jar $out/share/java
# create a wrapper that will automatically set the classpath # create a wrapper that will automatically set the classpath
# this should be the paths from the dependency derivation # this should be the paths from the dependency derivation
makeWrapper ${jre}/bin/java $out/bin/${pname} \ makeWrapper ${jre}/bin/java $out/bin/maven-demo \
--add-flags "-classpath $out/share/java/${pname}-${version}.jar:''${classpath#:}" \ --add-flags "-classpath $out/share/java/maven-demo-${finalAttrs.version}.jar:''${classpath#:}" \
--add-flags "Main" --add-flags "Main"
runHook postInstall
''; '';
} })
``` ```
#### MANIFEST file via Maven Plugin {#manifest-file-via-maven-plugin} #### MANIFEST file via Maven Plugin {#manifest-file-via-maven-plugin}
@ -502,11 +530,11 @@ We will modify the derivation above to add a symlink to our repository so that i
makeWrapper, makeWrapper,
jre, jre,
}: }:
# pick a repository derivation, here we will use buildMaven
let let
# pick a repository derivation, here we will use buildMaven
repository = callPackage ./build-maven-repository.nix { }; repository = callPackage ./build-maven-repository.nix { };
in in
stdenv.mkDerivation rec { stdenv.mkDerivation (finalAttrs: {
pname = "maven-demo"; pname = "maven-demo";
version = "1.0"; version = "1.0";
@ -515,23 +543,31 @@ stdenv.mkDerivation rec {
buildInputs = [ maven ]; buildInputs = [ maven ];
buildPhase = '' buildPhase = ''
runHook preBuild
echo "Using repository ${repository}" echo "Using repository ${repository}"
mvn --offline -Dmaven.repo.local=${repository} package; mvn --offline -Dmaven.repo.local=${repository} package;
runHook postBuild
''; '';
installPhase = '' installPhase = ''
runHook preInstall
mkdir -p $out/bin mkdir -p $out/bin
# create a symbolic link for the repository directory # create a symbolic link for the repository directory
ln -s ${repository} $out/repository ln -s ${repository} $out/repository
install -Dm644 target/${pname}-${version}.jar $out/share/java install -Dm644 target/maven-demo-${finalAttrs.version}.jar $out/share/java
# create a wrapper that will automatically set the classpath # create a wrapper that will automatically set the classpath
# this should be the paths from the dependency derivation # this should be the paths from the dependency derivation
makeWrapper ${jre}/bin/java $out/bin/${pname} \ makeWrapper ${jre}/bin/java $out/bin/maven-demo \
--add-flags "-jar $out/share/java/${pname}-${version}.jar" --add-flags "-jar $out/share/java/maven-demo-${finalAttrs.version}.jar"
runHook postInstall
''; '';
} })
``` ```
::: {.note} ::: {.note}
Our script produces a dependency on `jre` rather than `jdk` to restrict the runtime closure necessary to run the application. Our script produces a dependency on `jre` rather than `jdk` to restrict the runtime closure necessary to run the application.

View File

@ -83,8 +83,8 @@ buildDunePackage rec {
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "inhabitedtype"; owner = "inhabitedtype";
repo = pname; repo = "angstrom";
rev = version; tag = version;
hash = "sha256-MK8o+iPGANEhrrTc1Kz9LBilx2bDPQt7Pp5P2libucI="; hash = "sha256-MK8o+iPGANEhrrTc1Kz9LBilx2bDPQt7Pp5P2libucI=";
}; };
@ -124,7 +124,7 @@ buildDunePackage rec {
minimalOCamlVersion = "4.02"; minimalOCamlVersion = "4.02";
src = fetchurl { src = fetchurl {
url = "https://github.com/flowtype/ocaml-${pname}/releases/download/v${version}/${pname}-v${version}.tbz"; url = "https://github.com/flowtype/ocaml-wtf8/releases/download/v${version}/wtf8-v${version}.tbz";
hash = "sha256-d5/3KUBAWRj8tntr4RkJ74KWW7wvn/B/m1nx0npnzyc="; hash = "sha256-d5/3KUBAWRj8tntr4RkJ74KWW7wvn/B/m1nx0npnzyc=";
}; };

View File

@ -39,7 +39,7 @@ Perl packages from CPAN are defined in [pkgs/top-level/perl-packages.nix](https:
pname = "Class-C3"; pname = "Class-C3";
version = "0.21"; version = "0.21";
src = fetchurl { src = fetchurl {
url = "mirror://cpan/authors/id/F/FL/FLORA/${pname}-${version}.tar.gz"; url = "mirror://cpan/authors/id/F/FL/FLORA/Class-C3-${version}.tar.gz";
hash = "sha256-/5GE5xHT0uYGOQxroqj6LMU7CtKn2s6vMVoSXxL4iK4="; hash = "sha256-/5GE5xHT0uYGOQxroqj6LMU7CtKn2s6vMVoSXxL4iK4=";
}; };
}; };
@ -88,7 +88,7 @@ buildPerlPackage rec {
version = "0.36"; version = "0.36";
src = fetchurl { src = fetchurl {
url = "mirror://cpan/authors/id/P/PM/PMQS/${pname}-${version}.tar.gz"; url = "mirror://cpan/authors/id/P/PM/PMQS/BerkeleyDB-${version}.tar.gz";
hash = "sha256-4Y+HGgGQqcOfdiKcFIyMrWBEccVNVAMDBWZlFTMorh8="; hash = "sha256-4Y+HGgGQqcOfdiKcFIyMrWBEccVNVAMDBWZlFTMorh8=";
}; };
@ -107,7 +107,7 @@ Dependencies on other Perl packages can be specified in the `buildInputs` and `p
pname = "Class-C3-Componentised"; pname = "Class-C3-Componentised";
version = "1.0004"; version = "1.0004";
src = fetchurl { src = fetchurl {
url = "mirror://cpan/authors/id/A/AS/ASH/${pname}-${version}.tar.gz"; url = "mirror://cpan/authors/id/A/AS/ASH/Class-C3-Componentised-${version}.tar.gz";
hash = "sha256-ASO9rV/FzJYZ0BH572Fxm2ZrFLMZLFATJng1NuU4FHc="; hash = "sha256-ASO9rV/FzJYZ0BH572Fxm2ZrFLMZLFATJng1NuU4FHc=";
}; };
propagatedBuildInputs = [ propagatedBuildInputs = [
@ -137,7 +137,7 @@ On Darwin, if a script has too many `-Idir` flags in its first line (its “sheb
version = "12.50"; version = "12.50";
src = fetchurl { src = fetchurl {
url = "https://exiftool.org/${pname}-${version}.tar.gz"; url = "https://exiftool.org/Image-ExifTool-${version}.tar.gz";
hash = "sha256-vOhB/FwQMC8PPvdnjDvxRpU6jAZcC6GMQfc0AH4uwKg="; hash = "sha256-vOhB/FwQMC8PPvdnjDvxRpU6jAZcC6GMQfc0AH4uwKg=";
}; };

View File

@ -2135,8 +2135,9 @@ Occasionally packages don't make use of a common test framework, which may then
#### Common issues {#common-issues} #### Common issues {#common-issues}
* Tests that attempt to access `$HOME` can be fixed by using the following * Tests that attempt to access `$HOME` can be fixed by using `writableTmpDirAsHomeHook` in
work-around before running tests (e.g. `preCheck`): `export HOME=$(mktemp -d)` `nativeCheckInputs`, which sets up a writable temporary directory as the home directory. Alternatively,
you can achieve the same effect manually (e.g. in `preCheck`) with: `export HOME=$(mktemp -d)`.
* Compiling with Cython causes tests to fail with a `ModuleNotLoadedError`. * Compiling with Cython causes tests to fail with a `ModuleNotLoadedError`.
This can be fixed with two changes in the derivation: 1) replacing `pytest` with This can be fixed with two changes in the derivation: 1) replacing `pytest` with
`pytestCheckHook` and 2) adding a `preCheck` containing `cd $out` to run `pytestCheckHook` and 2) adding a `preCheck` containing `cd $out` to run

View File

@ -28,14 +28,14 @@ Rust applications are packaged by using the `buildRustPackage` helper from `rust
rustPlatform, rustPlatform,
}: }:
rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage (finalAttrs: {
pname = "ripgrep"; pname = "ripgrep";
version = "14.1.1"; version = "14.1.1";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "BurntSushi"; owner = "BurntSushi";
repo = pname; repo = "ripgrep";
rev = version; tag = finalAttrs.version;
hash = "sha256-gyWnahj1A+iXUQlQ1O1H1u7K5euYQOld9qWm99Vjaeg="; hash = "sha256-gyWnahj1A+iXUQlQ1O1H1u7K5euYQOld9qWm99Vjaeg=";
}; };
@ -48,7 +48,7 @@ rustPlatform.buildRustPackage rec {
license = lib.licenses.unlicense; license = lib.licenses.unlicense;
maintainers = [ ]; maintainers = [ ];
}; };
} })
``` ```
`buildRustPackage` requires a `cargoHash` attribute, computed over all crate sources of this package. `buildRustPackage` requires a `cargoHash` attribute, computed over all crate sources of this package.
@ -104,21 +104,21 @@ be made invariant to the version by setting `cargoDepsName` to
`pname`: `pname`:
```nix ```nix
rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage (finalAttrs: {
pname = "broot"; pname = "broot";
version = "1.2.0"; version = "1.2.0";
src = fetchCrate { src = fetchCrate {
inherit pname version; inherit (finalAttrs) pname version;
hash = "sha256-aDQA4A5mScX9or3Lyiv/5GyAehidnpKKE0grhbP1Ctc="; hash = "sha256-aDQA4A5mScX9or3Lyiv/5GyAehidnpKKE0grhbP1Ctc=";
}; };
useFetchCargoVendor = true; useFetchCargoVendor = true;
cargoHash = "sha256-iDYh52rj1M5Uupvbx2WeDd/jvQZ+2A50V5rp5e2t7q4="; cargoHash = "sha256-iDYh52rj1M5Uupvbx2WeDd/jvQZ+2A50V5rp5e2t7q4=";
cargoDepsName = pname; cargoDepsName = finalAttrs.pname;
# ... # ...
} })
``` ```
### Importing a `Cargo.lock` file {#importing-a-cargo.lock-file} ### Importing a `Cargo.lock` file {#importing-a-cargo.lock-file}
@ -184,7 +184,7 @@ The output hash of each dependency that uses a git source must be
specified in the `outputHashes` attribute. For example: specified in the `outputHashes` attribute. For example:
```nix ```nix
rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage {
pname = "myproject"; pname = "myproject";
version = "1.0.0"; version = "1.0.0";
@ -209,7 +209,7 @@ For usage outside nixpkgs, `allowBuiltinFetchGit` could be used to
avoid having to specify `outputHashes`. For example: avoid having to specify `outputHashes`. For example:
```nix ```nix
rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage {
pname = "myproject"; pname = "myproject";
version = "1.0.0"; version = "1.0.0";
@ -235,7 +235,7 @@ If you want to use different features for check phase, you can use
For example: For example:
```nix ```nix
rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage {
pname = "myproject"; pname = "myproject";
version = "1.0.0"; version = "1.0.0";
@ -427,7 +427,7 @@ 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. the `cargoPatches` attribute to update or add it.
```nix ```nix
rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage {
# ... # ...
cargoPatches = [ cargoPatches = [
# a patch file to add/update Cargo.lock in the source code # a patch file to add/update Cargo.lock in the source code
@ -575,8 +575,8 @@ buildPythonPackage rec {
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "huggingface"; owner = "huggingface";
repo = pname; repo = "tokenizers";
rev = "python-v${version}"; tag = "python-v${version}";
hash = "sha256-rQ2hRV52naEf6PvRsWVCTN7B1oXAQGmnpJw4iIdhamw="; hash = "sha256-rQ2hRV52naEf6PvRsWVCTN7B1oXAQGmnpJw4iIdhamw=";
}; };
@ -665,7 +665,7 @@ buildPythonPackage rec {
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "Qiskit"; owner = "Qiskit";
repo = "retworkx"; repo = "retworkx";
rev = version; tag = version;
hash = "sha256-11n30ldg3y3y6qxg3hbj837pnbwjkqw3nxq6frds647mmmprrd20="; hash = "sha256-11n30ldg3y3y6qxg3hbj837pnbwjkqw3nxq6frds647mmmprrd20=";
}; };
@ -705,7 +705,7 @@ Some projects, especially GNOME applications, are built with the Meson Build Sys
tinysparql, tinysparql,
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation (finalAttrs: {
pname = "health"; pname = "health";
version = "0.95.0"; version = "0.95.0";
@ -713,12 +713,12 @@ stdenv.mkDerivation rec {
domain = "gitlab.gnome.org"; domain = "gitlab.gnome.org";
owner = "World"; owner = "World";
repo = "health"; repo = "health";
rev = version; tag = finalAttrs.version;
hash = "sha256-PrNPprSS98yN8b8yw2G6hzTSaoE65VbsM3q7FVB4mds="; hash = "sha256-PrNPprSS98yN8b8yw2G6hzTSaoE65VbsM3q7FVB4mds=";
}; };
cargoDeps = rustPlatform.fetchCargoVendor { cargoDeps = rustPlatform.fetchCargoVendor {
inherit pname version src; inherit (finalAttrs) pname version src;
hash = "sha256-eR1ZGtTZQNhofFUEjI7IX16sMKPJmAl7aIFfPJukecg="; hash = "sha256-eR1ZGtTZQNhofFUEjI7IX16sMKPJmAl7aIFfPJukecg=";
}; };
@ -740,7 +740,7 @@ stdenv.mkDerivation rec {
]; ];
# ... # ...
} })
``` ```
## `buildRustCrate`: Compiling Rust crates using Nix instead of Cargo {#compiling-rust-crates-using-nix-instead-of-cargo} ## `buildRustCrate`: Compiling Rust crates using Nix instead of Cargo {#compiling-rust-crates-using-nix-instead-of-cargo}
@ -1000,20 +1000,21 @@ let
}; };
in in
rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage (finalAttrs: {
pname = "ripgrep"; pname = "ripgrep";
version = "14.1.1"; version = "14.1.1";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "BurntSushi"; owner = "BurntSushi";
repo = "ripgrep"; repo = "ripgrep";
rev = version; tag = finalAttrs.version;
hash = "sha256-gyWnahj1A+iXUQlQ1O1H1u7K5euYQOld9qWm99Vjaeg="; hash = "sha256-gyWnahj1A+iXUQlQ1O1H1u7K5euYQOld9qWm99Vjaeg=";
}; };
useFetchCargoVendor = true; useFetchCargoVendor = true;
cargoHash = "sha256-9atn5qyBDy4P6iUoHFhg+TV6Ur71fiah4oTJbBMeEy4="; cargoHash = "sha256-9atn5qyBDy4P6iUoHFhg+TV6Ur71fiah4oTJbBMeEy4=";
# Tests require network access. Skipping.
doCheck = false; doCheck = false;
meta = { meta = {
@ -1025,7 +1026,7 @@ rustPlatform.buildRustPackage rec {
]; ];
maintainers = with lib.maintainers; [ ]; maintainers = with lib.maintainers; [ ];
}; };
} })
``` ```
Follow the below steps to try that snippet. Follow the below steps to try that snippet.

View File

@ -82,15 +82,15 @@ let
generated = swiftpm2nix.helpers ./nix; generated = swiftpm2nix.helpers ./nix;
in in
stdenv.mkDerivation rec { stdenv.mkDerivation (finalAttrs: {
pname = "myproject"; pname = "myproject";
version = "0.0.0"; version = "0.0.0";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "nixos"; owner = "nixos";
repo = pname; repo = "myproject";
rev = version; tag = finalAttrs.version;
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; hash = "";
}; };
# Including SwiftPM as a nativeBuildInput provides a buildPhase for you. # Including SwiftPM as a nativeBuildInput provides a buildPhase for you.
@ -106,14 +106,18 @@ stdenv.mkDerivation rec {
configurePhase = generated.configure; configurePhase = generated.configure;
installPhase = '' installPhase = ''
runHook preInstall
# This is a special function that invokes swiftpm to find the location # This is a special function that invokes swiftpm to find the location
# of the binaries it produced. # of the binaries it produced.
binPath="$(swiftpmBinPath)" binPath="$(swiftpmBinPath)"
# Now perform any installation steps. # Now perform any installation steps.
mkdir -p $out/bin mkdir -p $out/bin
cp $binPath/myproject $out/bin/ cp $binPath/myproject $out/bin/
runHook postInstall
''; '';
} })
``` ```
### Custom build flags {#ssec-swiftpm-custom-build-flags} ### Custom build flags {#ssec-swiftpm-custom-build-flags}

View File

@ -94,18 +94,18 @@ Release 23.11 ships with a new interface that will eventually replace `texlive.c
- TeX Live packages are also available under `texlive.pkgs` as derivations with outputs `out`, `tex`, `texdoc`, `texsource`, `tlpkg`, `man`, `info`. They cannot be installed outside of `texlive.combine` but are available for other uses. To repackage a font, for instance, use - TeX Live packages are also available under `texlive.pkgs` as derivations with outputs `out`, `tex`, `texdoc`, `texsource`, `tlpkg`, `man`, `info`. They cannot be installed outside of `texlive.combine` but are available for other uses. To repackage a font, for instance, use
```nix ```nix
stdenvNoCC.mkDerivation rec { stdenvNoCC.mkDerivation (finalAttrs: {
src = texlive.pkgs.iwona; src = texlive.pkgs.iwona;
dontUnpack = true; dontUnpack = true;
inherit (src) pname version; inherit (finalAttrs.src) pname version;
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
install -Dm644 $src/fonts/opentype/nowacki/iwona/*.otf -t $out/share/fonts/opentype install -Dm644 $src/fonts/opentype/nowacki/iwona/*.otf -t $out/share/fonts/opentype
runHook postInstall runHook postInstall
''; '';
} })
``` ```
See `biber`, `iwona` for complete examples. See `biber`, `iwona` for complete examples.
@ -173,6 +173,7 @@ let
(writeShellScript "force-tex-output.sh" '' (writeShellScript "force-tex-output.sh" ''
out="''${tex-}" out="''${tex-}"
'') '')
writableTmpDirAsHomeHook # Need a writable $HOME for latexmk
]; ];
dontConfigure = true; dontConfigure = true;
@ -184,7 +185,6 @@ let
latex foiltex.ins latex foiltex.ins
# Generate the documentation # Generate the documentation
export HOME=.
latexmk -pdf foiltex.dtx latexmk -pdf foiltex.dtx
runHook postBuild runHook postBuild

View File

@ -28,80 +28,79 @@ You can install it like any other packages via `nix-env -iA myEmacs`. However, t
```nix ```nix
{ {
packageOverrides = packageOverrides = pkgs: {
pkgs: with pkgs; rec { myEmacsConfig = pkgs.writeText "default.el" ''
myEmacsConfig = writeText "default.el" '' (eval-when-compile
(eval-when-compile (require 'use-package))
(require 'use-package))
;; load some packages ;; load some packages
(use-package company (use-package company
:bind ("<C-tab>" . company-complete) :bind ("<C-tab>" . company-complete)
:diminish company-mode :diminish company-mode
:commands (company-mode global-company-mode) :commands (company-mode global-company-mode)
:defer 1 :defer 1
:config :config
(global-company-mode)) (global-company-mode))
(use-package counsel (use-package counsel
:commands (counsel-descbinds) :commands (counsel-descbinds)
:bind (([remap execute-extended-command] . counsel-M-x) :bind (([remap execute-extended-command] . counsel-M-x)
("C-x C-f" . counsel-find-file) ("C-x C-f" . counsel-find-file)
("C-c g" . counsel-git) ("C-c g" . counsel-git)
("C-c j" . counsel-git-grep) ("C-c j" . counsel-git-grep)
("C-c k" . counsel-ag) ("C-c k" . counsel-ag)
("C-x l" . counsel-locate) ("C-x l" . counsel-locate)
("M-y" . counsel-yank-pop))) ("M-y" . counsel-yank-pop)))
(use-package flycheck (use-package flycheck
:defer 2 :defer 2
:config (global-flycheck-mode)) :config (global-flycheck-mode))
(use-package ivy (use-package ivy
:defer 1 :defer 1
:bind (("C-c C-r" . ivy-resume) :bind (("C-c C-r" . ivy-resume)
("C-x C-b" . ivy-switch-buffer) ("C-x C-b" . ivy-switch-buffer)
:map ivy-minibuffer-map :map ivy-minibuffer-map
("C-j" . ivy-call)) ("C-j" . ivy-call))
:diminish ivy-mode :diminish ivy-mode
:commands ivy-mode :commands ivy-mode
:config :config
(ivy-mode 1)) (ivy-mode 1))
(use-package magit (use-package magit
:defer :defer
:if (executable-find "git") :if (executable-find "git")
:bind (("C-x g" . magit-status) :bind (("C-x g" . magit-status)
("C-x G" . magit-dispatch-popup)) ("C-x G" . magit-dispatch-popup))
:init :init
(setq magit-completing-read-function 'ivy-completing-read)) (setq magit-completing-read-function 'ivy-completing-read))
(use-package projectile (use-package projectile
:commands projectile-mode :commands projectile-mode
:bind-keymap ("C-c p" . projectile-command-map) :bind-keymap ("C-c p" . projectile-command-map)
:defer 5 :defer 5
:config :config
(projectile-global-mode)) (projectile-global-mode))
''; '';
myEmacs = emacs.pkgs.withPackages ( myEmacs = emacs.pkgs.withPackages (
epkgs: epkgs:
(with epkgs.melpaStablePackages; [ (with epkgs.melpaStablePackages; [
(runCommand "default.el" { } '' (runCommand "default.el" { } ''
mkdir -p $out/share/emacs/site-lisp mkdir -p $out/share/emacs/site-lisp
cp ${myEmacsConfig} $out/share/emacs/site-lisp/default.el cp ${myEmacsConfig} $out/share/emacs/site-lisp/default.el
'') '')
company company
counsel counsel
flycheck flycheck
ivy ivy
magit magit
projectile projectile
use-package use-package
]) ])
); );
}; };
} }
``` ```

View File

@ -20,14 +20,14 @@ stdenv.mkDerivation {
**Since [RFC 0035](https://github.com/NixOS/rfcs/pull/35), this is preferred for packages in Nixpkgs**, as it allows us to reuse the version easily: **Since [RFC 0035](https://github.com/NixOS/rfcs/pull/35), this is preferred for packages in Nixpkgs**, as it allows us to reuse the version easily:
```nix ```nix
stdenv.mkDerivation rec { stdenv.mkDerivation (finalAttrs: {
pname = "libfoo"; pname = "libfoo";
version = "1.2.3"; version = "1.2.3";
src = fetchurl { src = fetchurl {
url = "http://example.org/libfoo-source-${version}.tar.bz2"; url = "http://example.org/libfoo-source-${finalAttrs.version}.tar.bz2";
hash = "sha256-tWxU/LANbQE32my+9AXyt3nCT7NBVfJ45CX757EMT3Q="; hash = "sha256-tWxU/LANbQE32my+9AXyt3nCT7NBVfJ45CX757EMT3Q=";
}; };
} })
``` ```
Many packages have dependencies that are not provided in the standard environment. Its usually sufficient to specify those dependencies in the `buildInputs` attribute: Many packages have dependencies that are not provided in the standard environment. Its usually sufficient to specify those dependencies in the `buildInputs` attribute:
@ -53,13 +53,24 @@ Often it is necessary to override or modify some aspect of the build. To make th
stdenv.mkDerivation { stdenv.mkDerivation {
pname = "fnord"; pname = "fnord";
version = "4.5"; version = "4.5";
# ... # ...
buildPhase = '' buildPhase = ''
runHook preBuild
gcc foo.c -o foo gcc foo.c -o foo
runHook postBuild
''; '';
installPhase = '' installPhase = ''
runHook preInstall
mkdir -p $out/bin mkdir -p $out/bin
cp foo $out/bin cp foo $out/bin
runHook postInstall
''; '';
} }
``` ```
@ -212,12 +223,12 @@ These dependencies are only injected when [`doCheck`](#var-stdenv-doCheck) is se
Consider for example this simplified derivation for `solo5`, a sandboxing tool: Consider for example this simplified derivation for `solo5`, a sandboxing tool:
```nix ```nix
stdenv.mkDerivation rec { stdenv.mkDerivation (finalAttrs: {
pname = "solo5"; pname = "solo5";
version = "0.7.5"; version = "0.7.5";
src = fetchurl { src = fetchurl {
url = "https://github.com/Solo5/solo5/releases/download/v${version}/solo5-v${version}.tar.gz"; url = "https://github.com/Solo5/solo5/releases/download/v${finalAttrs.version}/solo5-v${finalAttrs.version}.tar.gz";
hash = "sha256-viwrS9lnaU8sTGuzK/+L/PlMM/xRRtgVuK5pixVeDEw="; hash = "sha256-viwrS9lnaU8sTGuzK/+L/PlMM/xRRtgVuK5pixVeDEw=";
}; };
@ -225,6 +236,7 @@ stdenv.mkDerivation rec {
makeWrapper makeWrapper
pkg-config pkg-config
]; ];
buildInputs = [ libseccomp ]; buildInputs = [ libseccomp ];
postInstall = '' postInstall = ''
@ -249,8 +261,8 @@ stdenv.mkDerivation rec {
util-linux util-linux
qemu qemu
]; ];
checkPhase = ''[elided] ''; checkPhase = ''[elided]'';
} })
``` ```
- `makeWrapper` is a setup hook, i.e., a shell script sourced by the generic builder of `stdenv`. - `makeWrapper` is a setup hook, i.e., a shell script sourced by the generic builder of `stdenv`.

View File

@ -300,42 +300,41 @@ This provides us with some useful documentation for using our packages. However
```nix ```nix
{ {
packageOverrides = packageOverrides = pkgs: {
pkgs: with pkgs; rec { myProfile = pkgs.writeText "my-profile" ''
myProfile = writeText "my-profile" '' export PATH=$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/sbin:/bin:/usr/sbin:/usr/bin
export PATH=$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/sbin:/bin:/usr/sbin:/usr/bin export MANPATH=$HOME/.nix-profile/share/man:/nix/var/nix/profiles/default/share/man:/usr/share/man
export MANPATH=$HOME/.nix-profile/share/man:/nix/var/nix/profiles/default/share/man:/usr/share/man '';
''; myPackages = pkgs.buildEnv {
myPackages = pkgs.buildEnv { name = "my-packages";
name = "my-packages"; paths = with pkgs; [
paths = [ (runCommand "profile" { } ''
(runCommand "profile" { } '' mkdir -p $out/etc/profile.d
mkdir -p $out/etc/profile.d cp ${myProfile} $out/etc/profile.d/my-profile.sh
cp ${myProfile} $out/etc/profile.d/my-profile.sh '')
'') aspell
aspell bc
bc coreutils
coreutils ffmpeg
ffmpeg man
man nix
nix emscripten
emscripten jq
jq nox
nox silver-searcher
silver-searcher ];
]; pathsToLink = [
pathsToLink = [ "/share/man"
"/share/man" "/share/doc"
"/share/doc" "/bin"
"/bin" "/etc"
"/etc" ];
]; extraOutputsToInstall = [
extraOutputsToInstall = [ "man"
"man" "doc"
"doc" ];
];
};
}; };
};
} }
``` ```
@ -360,54 +359,53 @@ Configuring GNU info is a little bit trickier than man pages. To work correctly,
```nix ```nix
{ {
packageOverrides = packageOverrides = pkgs: {
pkgs: with pkgs; rec { myProfile = pkgs.writeText "my-profile" ''
myProfile = writeText "my-profile" '' export PATH=$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/sbin:/bin:/usr/sbin:/usr/bin
export PATH=$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/sbin:/bin:/usr/sbin:/usr/bin export MANPATH=$HOME/.nix-profile/share/man:/nix/var/nix/profiles/default/share/man:/usr/share/man
export MANPATH=$HOME/.nix-profile/share/man:/nix/var/nix/profiles/default/share/man:/usr/share/man export INFOPATH=$HOME/.nix-profile/share/info:/nix/var/nix/profiles/default/share/info:/usr/share/info
export INFOPATH=$HOME/.nix-profile/share/info:/nix/var/nix/profiles/default/share/info:/usr/share/info '';
myPackages = pkgs.buildEnv {
name = "my-packages";
paths = with pkgs; [
(runCommand "profile" { } ''
mkdir -p $out/etc/profile.d
cp ${myProfile} $out/etc/profile.d/my-profile.sh
'')
aspell
bc
coreutils
ffmpeg
man
nix
emscripten
jq
nox
silver-searcher
texinfoInteractive
];
pathsToLink = [
"/share/man"
"/share/doc"
"/share/info"
"/bin"
"/etc"
];
extraOutputsToInstall = [
"man"
"doc"
"info"
];
postBuild = ''
if [ -x $out/bin/install-info -a -w $out/share/info ]; then
shopt -s nullglob
for i in $out/share/info/*.info $out/share/info/*.info.gz; do
$out/bin/install-info $i $out/share/info/dir
done
fi
''; '';
myPackages = pkgs.buildEnv {
name = "my-packages";
paths = [
(runCommand "profile" { } ''
mkdir -p $out/etc/profile.d
cp ${myProfile} $out/etc/profile.d/my-profile.sh
'')
aspell
bc
coreutils
ffmpeg
man
nix
emscripten
jq
nox
silver-searcher
texinfoInteractive
];
pathsToLink = [
"/share/man"
"/share/doc"
"/share/info"
"/bin"
"/etc"
];
extraOutputsToInstall = [
"man"
"doc"
"info"
];
postBuild = ''
if [ -x $out/bin/install-info -a -w $out/share/info ]; then
shopt -s nullglob
for i in $out/share/info/*.info $out/share/info/*.info.gz; do
$out/bin/install-info $i $out/share/info/dir
done
fi
'';
};
}; };
};
} }
``` ```