From eac06ed0702638b7e9a058e5412940474ff872ca Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 3 Sep 2018 17:13:02 +0200 Subject: [PATCH] Manual: Random indentation fixes --- doc/configuration.xml | 42 ++++++------ doc/functions.xml | 150 ++++++++++++++++++++++-------------------- 2 files changed, 101 insertions(+), 91 deletions(-) diff --git a/doc/configuration.xml b/doc/configuration.xml index c91f38f3093..af74f3f9c01 100644 --- a/doc/configuration.xml +++ b/doc/configuration.xml @@ -325,7 +325,7 @@ }; }; } - + To install it into our environment, you can just run nix-env -iA @@ -347,7 +347,7 @@ }; }; } - + pathsToLink tells Nixpkgs to only link the paths listed @@ -383,7 +383,7 @@ }; }; } - + This provides us with some useful documentation for using our packages. @@ -395,15 +395,15 @@ { packageOverrides = pkgs: with pkgs; rec { myProfile = writeText "my-profile" '' -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 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 ''; myPackages = pkgs.buildEnv { name = "my-packages"; paths = [ (runCommand "profile" {} '' -mkdir -p $out/etc/profile.d -cp ${myProfile} $out/etc/profile.d/my-profile.sh + mkdir -p $out/etc/profile.d + cp ${myProfile} $out/etc/profile.d/my-profile.sh '') aspell bc @@ -421,7 +421,7 @@ cp ${myProfile} $out/etc/profile.d/my-profile.sh }; }; } - + For this to work fully, you must also have this script sourced when you are @@ -438,7 +438,7 @@ if [ -d $HOME/.nix-profile/etc/profile.d ]; then fi done fi - + Now just run source $HOME/.profile and you can starting @@ -459,16 +459,16 @@ fi { packageOverrides = pkgs: with pkgs; rec { myProfile = writeText "my-profile" '' -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 INFOPATH=$HOME/.nix-profile/share/info:/nix/var/nix/profiles/default/share/info:/usr/share/info + 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 INFOPATH=$HOME/.nix-profile/share/info:/nix/var/nix/profiles/default/share/info:/usr/share/info ''; myPackages = pkgs.buildEnv { name = "my-packages"; paths = [ (runCommand "profile" {} '' -mkdir -p $out/etc/profile.d -cp ${myProfile} $out/etc/profile.d/my-profile.sh + mkdir -p $out/etc/profile.d + cp ${myProfile} $out/etc/profile.d/my-profile.sh '') aspell bc @@ -485,17 +485,17 @@ cp ${myProfile} $out/etc/profile.d/my-profile.sh 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 + 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 ''; }; }; } - + postBuild tells Nixpkgs to run a command after building diff --git a/doc/functions.xml b/doc/functions.xml index ec188e23454..3cfc6884bd2 100644 --- a/doc/functions.xml +++ b/doc/functions.xml @@ -1,7 +1,7 @@ + xml:id="chap-functions"> Functions reference The nixpkgs repository has several utility functions to manipulate Nix @@ -31,12 +31,16 @@ Example usages: pkgs.foo.override { arg1 = val1; arg2 = val2; ... } -import pkgs.path { overlays = [ (self: super: { - foo = super.foo.override { barSupport = true ; }; - })]}; -mypkg = pkgs.callPackage ./mypkg.nix { - mydep = pkgs.mydep.override { ... }; - } + +import pkgs.path { overlays = [ (self: super: { + foo = super.foo.override { barSupport = true ; }; + })]}; + + +mypkg = pkgs.callPackage ./mypkg.nix { + mydep = pkgs.mydep.override { ... }; + } + @@ -61,9 +65,11 @@ Example usage: -helloWithDebug = pkgs.hello.overrideAttrs (oldAttrs: rec { - separateDebugInfo = true; - }); + +helloWithDebug = pkgs.hello.overrideAttrs (oldAttrs: rec { + separateDebugInfo = true; +}); + @@ -134,14 +140,16 @@ Example usage: -mySed = pkgs.gnused.overrideDerivation (oldAttrs: { - name = "sed-4.2.2-pre"; - src = fetchurl { - url = ftp://alpha.gnu.org/gnu/sed/sed-4.2.2-pre.tar.bz2; - sha256 = "11nq06d131y4wmf3drm0yk502d2xc6n5qy82cg88rb9nqd2lj41k"; - }; - patches = []; - }); + +mySed = pkgs.gnused.overrideDerivation (oldAttrs: { + name = "sed-4.2.2-pre"; + src = fetchurl { + url = ftp://alpha.gnu.org/gnu/sed/sed-4.2.2-pre.tar.bz2; + sha256 = "11nq06d131y4wmf3drm0yk502d2xc6n5qy82cg88rb9nqd2lj41k"; + }; + patches = []; +}); + @@ -181,8 +189,10 @@ Example usage: -f = { a, b }: { result = a+b; } - c = lib.makeOverridable f { a = 1; b = 2; } + +f = { a, b }: { result = a+b; }; +c = lib.makeOverridable f { a = 1; b = 2; }; + @@ -482,29 +492,29 @@ merge:"diff3" Docker build - buildImage { - name = "redis"; - tag = "latest"; +buildImage { + name = "redis"; + tag = "latest"; - fromImage = someBaseImage; - fromImageName = null; - fromImageTag = "latest"; + fromImage = someBaseImage; + fromImageName = null; + fromImageTag = "latest"; - contents = pkgs.redis; - runAsRoot = '' - #!${stdenv.shell} - mkdir -p /data - ''; + contents = pkgs.redis; + runAsRoot = '' + #!${stdenv.shell} + mkdir -p /data + ''; - config = { - Cmd = [ "/bin/redis-server" ]; - WorkingDir = "/data"; - Volumes = { - "/data" = {}; - }; + config = { + Cmd = [ "/bin/redis-server" ]; + WorkingDir = "/data"; + Volumes = { + "/data" = {}; }; - } - + }; +} + @@ -647,15 +657,15 @@ merge:"diff3" Docker pull - pullImage { - imageName = "nixos/nix"; - imageDigest = "sha256:20d9485b25ecfd89204e843a962c1bd70e9cc6858d65d7f5fadc340246e2116b"; - finalImageTag = "1.11"; - sha256 = "0mqjy3zq2v6rrhizgb9nvhczl87lcfphq9601wcprdika2jz7qh8"; - os = "linux"; - arch = "x86_64"; - } - +pullImage { + imageName = "nixos/nix"; + imageDigest = "sha256:20d9485b25ecfd89204e843a962c1bd70e9cc6858d65d7f5fadc340246e2116b"; + finalImageTag = "1.11"; + sha256 = "0mqjy3zq2v6rrhizgb9nvhczl87lcfphq9601wcprdika2jz7qh8"; + os = "linux"; + arch = "x86_64"; +} + @@ -677,9 +687,9 @@ merge:"diff3" exactly which image you want. By default it will match the OS and architecture of the host the command is run on. - $ nix-shell --packages skopeo jq --command "skopeo --override-os linux --override-arch x86_64 inspect docker://docker.io/nixos/nix:1.11 | jq -r '.Digest'" - sha256:20d9485b25ecfd89204e843a962c1bd70e9cc6858d65d7f5fadc340246e2116b - +$ nix-shell --packages skopeo jq --command "skopeo --override-os linux --override-arch x86_64 inspect docker://docker.io/nixos/nix:1.11 | jq -r '.Digest'" +sha256:20d9485b25ecfd89204e843a962c1bd70e9cc6858d65d7f5fadc340246e2116b + This argument is required. @@ -737,13 +747,13 @@ merge:"diff3" Docker export - exportImage { - fromImage = someLayeredImage; - fromImageName = null; - fromImageTag = null; +exportImage { + fromImage = someLayeredImage; + fromImageName = null; + fromImageTag = null; - name = someLayeredImage.name; - } + name = someLayeredImage.name; +} @@ -774,19 +784,19 @@ merge:"diff3" Shadow base files - buildImage { - name = "shadow-basic"; +buildImage { + name = "shadow-basic"; - runAsRoot = '' - #!${stdenv.shell} - ${shadowSetup} - groupadd -r redis - useradd -r -g redis redis - mkdir /data - chown redis:redis /data - ''; - } - + runAsRoot = '' + #!${stdenv.shell} + ${shadowSetup} + groupadd -r redis + useradd -r -g redis redis + mkdir /data + chown redis:redis /data + ''; +} +