### Install Kodi Addons (Previous Release Style) Source: https://github.com/nixos/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2105.section.md Example of how Kodi addons were installed in previous NixOS releases. For current releases, refer to the updated documentation. ```nix kodi = pkgs.kodi.overrideAttrs (oldAttrs: { addons = oldAttrs.addons ++ [ pkgs.kodi-addon-inputstream-adaptive pkgs.kodi-addon-vfs-sftp ]; }); ``` -------------------------------- ### pnpmBuildHook Example Source: https://github.com/nixos/nixpkgs/blob/master/doc/hooks/pnpm.section.md Demonstrates how to use pnpmBuildHook in a Nix derivation. This setup includes fetching dependencies with fetchPnpmDeps and configuring build scripts and workspaces. ```nix { lib, stdenv, fetchFromGitHub, fetchPnpmDeps, pnpmConfigHook, pnpmBuildHook, makeBinaryWrapper, pnpm_10, }: let pnpm = pnpm_10; in stdenv.mkDerivation (finalAttrs: { pname = "coolPackages"; version = "1.0"; src = fetchFromGitHub { owner = "JaneCool"; repo = "coolpackage"; tag = finalAttrs.version; hash = lib.fakeHash; }; __structuredAttrs = true; strictDeps = true; pnpmDeps = fetchPnpmDeps { inherit (finalAttrs) pname version src; inherit pnpm; fetcherversion = 4; hash = lib.fakeHash; }; nativeBuildInputs = [ pnpmConfigHook pnpmBuildHook makeBinaryWrapper ]; pnpmBuildScript = "build"; pnpmBuildFlags = [ "--mode" "production" ]; pnpmWorkspaces = [ "test" ]; installPhase = '' runHook preInstall mkdir "$out" cp -r dist/. "$out" runHook postInstall ''; meta = { description = "very cool package that does cool things"; mainProgram = "cool"; }; }) ``` -------------------------------- ### Nix REPL Input/Output Example Source: https://github.com/nixos/nixpkgs/blob/master/doc/README.md Illustrates the formatting for Nix REPL interactions, using 'nix-repl>' to prefix input and showing the output as it would appear in the REPL. This example demonstrates getting attribute names from a set. ```shell nix-repl> builtins.attrNames { a = 1; b = 2; } [ "a" "b" ] ``` -------------------------------- ### Enter New NixOS Installation Source: https://github.com/nixos/nixpkgs/blob/master/nixos/doc/manual/development/testing-installer.chapter.md After installation, use this command to start a login shell within the new NixOS environment located at `/mnt`. ```Shell Session $ nix-build '' -A nixos-enter # ./result/bin/nixos-enter ``` -------------------------------- ### CallPackage-Compatible Example Structure Source: https://github.com/nixos/nixpkgs/blob/master/doc/README.md Shows how to write function examples that are compatible with `pkgs.callPackage`. This format ensures that examples can be directly used in Nix package definitions. ```nix { dockerTools, hello }: dockerTools.buildLayeredImage { name = "hello"; contents = [ hello ]; } ``` -------------------------------- ### Example of lib.toUpper Function Documentation Source: https://github.com/nixos/nixpkgs/blob/master/doc/README.md Demonstrates the recommended structure for documenting functions, including a title, abstract, example, and detailed explanation. This example shows how to convert a string to uppercase using `lib.toUpper`. ```nix ## `lib.toUpper` Converts all characters in a string to uppercase. :::{.example #ex-lib-toUpper} # Converting a string to uppercase ```nix lib.toUpper "hello" => "HELLO" ``` ::: Only acts on ASCII characters. Unicode characters are passed through unchanged. ``` -------------------------------- ### Start Elm Development Environment with Nix Source: https://github.com/nixos/nixpkgs/blob/master/doc/packages/elm.section.md This command uses Nix to create a temporary shell with the Elm compiler and formatter installed. It's useful for quickly starting development without globally installing Elm. ```ShellSession nix-shell -p elmPackages.elm elmPackages.elm-format ``` -------------------------------- ### Enter Nix Shell and Set Up Output Directory Source: https://github.com/nixos/nixpkgs/blob/master/doc/stdenv/stdenv.chapter.md Navigate to a temporary directory, enter a nix-shell with a specified package, and set an environment variable for the build output. ```bash cd "$(mktemp -d)" nix-shell '' -A some_package export out=$(pwd)/out ``` -------------------------------- ### Installing Emacs using Nix Package Manager Source: https://github.com/nixos/nixpkgs/blob/master/nixos/doc/manual/installation/installing.chapter.md Command to install the Emacs editor using the Nix package manager (`nix-env`). This is an example of how to install additional software during the installation process if network access is available. ```ShellSession nix-env -f '' -iA emacs ``` -------------------------------- ### Advanced pkgs.makeSetupHook with Dependencies and Substitutions in Nix Source: https://github.com/nixos/nixpkgs/blob/master/doc/build-helpers/special/makesetuphook.section.md An advanced example of pkgs.makeSetupHook in Nix, showing how to define runtime dependencies like 'hello' and 'cowsay' using 'propagatedBuildInputs'. It also demonstrates how to use 'substitutions' to map variables like '@shell@' and '@cowsay@' to their respective paths, and includes a script that defines a hook to run 'hello'. ```nix pkgs.makeSetupHook { name = "run-hello-hook"; propagatedBuildInputs = [ pkgs.hello pkgs.cowsay ]; substitutions = { shell = "${pkgs.bash}/bin/bash"; cowsay = "${pkgs.cowsay}/bin/cowsay"; }; } ( writeScript "run-hello-hook.sh" '' #!@shell@ @cowsay@ cow _printHelloHook() { hello } preConfigureHooks+=(_printHelloHook) '' ) ``` -------------------------------- ### Enable Livebook Service with Environment Variables (Nix) Source: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/development/livebook.md Enables the Livebook service by creating a systemd user unit. It demonstrates setting environment variables for the Livebook port and password, and specifies an environment file for secure password management. This is a basic setup for getting started with Livebook. ```nix { services.livebook = { enableUserService = true; environment = { LIVEBOOK_PORT = 20123; LIVEBOOK_PASSWORD = "mypassword"; }; # See note below about security environmentFile = "/var/lib/livebook.env"; }; } ``` -------------------------------- ### Configure prefer-remote-fetch Overlay via Shell Source: https://github.com/nixos/nixpkgs/blob/master/doc/functions/prefer-remote-fetch.section.md This example shows how to set up the prefer-remote-fetch overlay using shell commands. It creates the necessary directory and then uses `cat` to write the overlay configuration to a file. ```shell mkdir ~/.config/nixpkgs/overlays/ cat > ~/.config/nixpkgs/overlays/prefer-remote-fetch.nix < bash# ssh -o User=root -o ProxyCommand="socat - UNIX-CLIENT:/run/systemd/nspawn/unix-export/machine/ssh" bash [root@machine:~]# hostname machine ``` -------------------------------- ### Add GRUB Entry for Existing Linux Source: https://github.com/nixos/nixpkgs/blob/master/nixos/doc/manual/installation/installing-from-other-distro.section.md Example of adding a GRUB boot entry for an existing Ubuntu installation within the NixOS configuration. Replace the UUID with your partition's UUID. ```Nix { boot.loader.grub.extraEntries = '' menuentry "Ubuntu" { search --set=ubuntu --fs-uuid 3cc3e652-0c1f-4800-8451-033754f68e6e configfile "($ubuntu)/boot/grub/grub.cfg" } ''; } ``` -------------------------------- ### Nix Derivation Example for solo5 Source: https://github.com/nixos/nixpkgs/blob/master/doc/stdenv/stdenv.chapter.md This example demonstrates how to define dependencies for a Nix derivation. It includes nativeBuildInputs for build-time tools, buildInputs for runtime libraries, and nativeCheckInputs for testing tools. The postInstall phase shows how to wrap executables with additional runtime dependencies. ```nix stdenv.mkDerivation (finalAttrs: { pname = "solo5"; version = "0.7.5"; src = fetchurl { url = "https://github.com/Solo5/solo5/releases/download/v${finalAttrs.version}/solo5-v${finalAttrs.version}.tar.gz"; hash = "sha256-viwrS9lnaU8sTGuzK/+L/PlMM/xRRtgVuK5pixVeDEw="; }; nativeBuildInputs = [ makeWrapper pkg-config ]; buildInputs = [ libseccomp ]; postInstall = '' substituteInPlace $out/bin/solo5-virtio-mkimage \ --replace-fail "/usr/lib/syslinux" "${syslinux}/share/syslinux" \ --replace-fail "/usr/share/syslinux" "${syslinux}/share/syslinux" \ --replace-fail "cp " "cp --no-preserve=mode " wrapProgram $out/bin/solo5-virtio-mkimage \ --prefix PATH : ${ lib.makeBinPath [ dosfstools mtools parted syslinux ] } ''; doCheck = true; nativeCheckInputs = [ util-linux qemu ]; # `checkPhase` elided }) ``` -------------------------------- ### Repackage a TeX Live Font Source: https://github.com/nixos/nixpkgs/blob/master/doc/languages-frameworks/texlive.section.md Example of repackaging a TeX Live font package, such as 'iwona', into a custom derivation. It demonstrates how to use `stdenvNoCC.mkDerivation` and specify installation paths for font files. ```nix stdenvNoCC.mkDerivation (finalAttrs: { src = texlive.pkgs.iwona; dontUnpack = true; inherit (finalAttrs.src) pname version; installPhase = '' runHook preInstall install -Dm644 $src/fonts/opentype/nowacki/iwona/*.otf -t $out/share/fonts/opentype runHook postInstall ''; }) ``` -------------------------------- ### Use shadowSetup with buildImage for User/Group Management Source: https://github.com/nixos/nixpkgs/blob/master/doc/build-helpers/images/dockertools.section.md Demonstrates using dockerTools.shadowSetup with dockerTools.buildImage. It includes adding users and groups using binaries from the shadow package, which are temporarily available in the PATH during the runAsRoot script execution. ```nix { dockerTools, hello }: dockerTools.buildImage { name = "shadow-basic"; tag = "latest"; copyToRoot = [ hello ]; runAsRoot = '' ${dockerTools.shadowSetup} groupadd -r hello useradd -r -g hello hello mkdir /data chown hello:hello /data ''; config = { Cmd = [ "/bin/hello" ]; WorkingDir = "/data"; }; } ``` -------------------------------- ### Search, Install, and Run Flatpak Applications Source: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/desktops/flatpak.md Demonstrates the command-line usage for interacting with Flatpak applications. It includes searching for an application, installing it from a repository, and running it. ```shell $ flatpak search bustle $ flatpak install flathub org.freedesktop.Bustle $ flatpak run org.freedesktop.Bustle ``` -------------------------------- ### Disable Pantheon Default Applications Source: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/desktop-managers/pantheon.md Disables the installation of Pantheon's default applications. This allows for a more minimal Pantheon setup, excluding applications like elementary-mail. ```nix { services.pantheon.apps.enable = false; } ``` -------------------------------- ### Create NixOS Installation Disk Image with make-disk-image.nix Source: https://github.com/nixos/nixpkgs/blob/master/doc/build-helpers/images/makediskimage.section.md This Nix code snippet illustrates how to generate a full NixOS installation disk image using the `make-disk-image` function. It configures the image to include a bootloader and EFI variables, suitable for testing bootloaders or full system lifecycles. The example utilizes `eval-config` to define the NixOS configuration for the image. ```nix let pkgs = import { }; lib = pkgs.lib; make-disk-image = import ; evalConfig = import ; in make-disk-image { inherit pkgs lib; inherit (evalConfig { modules = [ { fileSystems."/" = { device = "/dev/vda"; fsType = "ext4"; autoFormat = true; }; boot.grub.device = "/dev/vda"; } ]; }) config ; format = "qcow2"; onlyNixStore = false; partitionTableType = "legacy+gpt"; installBootLoader = true; touchEFIVars = true; diskSize = "auto"; additionalSpace = "0M"; # Defaults to 512M. copyChannel = false; memSize = 2048; # Qemu VM memory size in MiB (1024*1024 bytes). Defaults to 1024M. } ``` -------------------------------- ### Configure NixOS with system.nix without Nix Channels Source: https://github.com/nixos/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2605.section.md Use system.nix as an alternative entry point to NixOS configuration, allowing management without nix-channels. This example shows how to fetch a specific Nixpkgs archive and import it for configuration. ```nix let # Pinned Nixpkgs archive # # Use `curl -I https://channels.nixos.org/nixos-26.05` to get the # latest commit of the stable channel and `nix-prefetch-url --unpack` # to compute its sha256 hash. nixpkgs = builtins.fetchTarball { url = "https://github.com/NixOS/nixpkgs/archive/c217913993d6.tar.gz"; sha256 = "026mprs324330pfazlgbw987qmsa8ligglarvqbcxzig2kgw0lqg"; }; in import "${nixpkgs}/nixos" { # Build NixOS using an external configuration.nix file, # or directly set your options here configuration = ./configuration.nix; } ``` -------------------------------- ### Prepare and Mount Filesystems Source: https://github.com/nixos/nixpkgs/blob/master/nixos/doc/manual/installation/installing.chapter.md Commands to format partitions and mount them to the NixOS installation directory (`/mnt`). Includes creating filesystems for NixOS root and boot (for UEFI), and enabling swap. ```ShellSession # mkfs.ext4 -L nixos /dev/sda1 # mkswap -L swap /dev/sda2 # swapon /dev/sda2 # mkfs.fat -F 32 -n boot /dev/sda3 # (for UEFI systems only) # mount /dev/disk/by-label/nixos /mnt # mkdir -p /mnt/boot # (for UEFI systems only) # mount -o umask=077 /dev/disk/by-label/boot /mnt/boot # (for UEFI systems only) ``` -------------------------------- ### NixOS Configuration: Initial User Password Source: https://github.com/nixos/nixpkgs/blob/master/nixos/doc/manual/installation/changing-config.chapter.md An example of how to temporarily add an initial hashed password for a user within the NixOS configuration. This is often used for testing virtual machine setups. ```Nix { users.users.your-user.initialHashedPassword = "test"; } ``` -------------------------------- ### Basic resholve.mkDerivation Example Source: https://github.com/nixos/nixpkgs/blob/master/pkgs/development/misc/resholve/README.md Example demonstrating how to use `resholve.mkDerivation` to package a script with its dependencies. Configure scripts, interpreters, inputs, and special `keep` directives. ```nix { bash, coreutils, gnused, goss, lib, resholve, which, }: resholve.mkDerivation rec { pname = "dgoss"; version = goss.version; src = goss.src; dontConfigure = true; dontBuild = true; installPhase = '' sed -i '2i GOSS_PATH=${goss}/bin/goss' extras/dgoss/dgoss install -D extras/dgoss/dgoss $out/bin/dgoss ''; solutions = { default = { scripts = [ "bin/dgoss" ]; interpreter = "${bash}/bin/bash"; inputs = [ coreutils gnused which ]; keep = { "$CONTAINER_RUNTIME" = true; }; }; }; meta = { homepage = "https://github.com/goss-org/goss/blob/v${version}/extras/dgoss/README.md"; changelog = "https://github.com/goss-org/goss/releases/tag/v${version}"; description = "Convenience wrapper around goss that aims to bring the simplicity of goss to docker containers"; license = lib.licenses.asl20; platforms = lib.platforms.linux; maintainers = with lib.maintainers; [ hyzual anthonyroussel ]; mainProgram = "dgoss"; }; } ``` -------------------------------- ### Customizing checkPhase with runHook in Nixpkgs Source: https://github.com/nixos/nixpkgs/blob/master/doc/hooks/postgresql-test-hook.section.md This example shows how to integrate the postgresqlTestHook into a custom checkPhase by explicitly calling `runHook` before and after your test commands. This ensures that the hook's setup and teardown logic is executed. ```nix checkPhase '' runHook preCheck # ... your tests runHook postCheck '' ``` -------------------------------- ### Basic pkgs.mkShell Usage Example Source: https://github.com/nixos/nixpkgs/blob/master/doc/build-helpers/special/mkshell.section.md Demonstrates a common way to use pkgs.mkShell to define a development environment. It specifies packages to include, derivations to inherit inputs from, and a custom shell hook for environment setup. ```nix { pkgs ? import { } }: pkgs.mkShell { packages = [ pkgs.gnumake ]; inputsFrom = [ pkgs.hello pkgs.gnutar ]; shellHook = '' export DEBUG=1 ''; } ``` -------------------------------- ### Build Docker Image with buildNixShellImage for hello package Source: https://github.com/nixos/nixpkgs/blob/master/doc/build-helpers/images/dockertools.section.md Builds a Docker image environment for the 'hello' package using `buildNixShellImage`. The resulting image is a tarball that can be loaded into Docker. This is suitable for standard derivations but may not work for fixed-output or impure derivations. ```nix { dockerTools, hello }: dockerTools.buildNixShellImage { drv = hello; tag = "latest"; } ``` -------------------------------- ### Build Nixpkgs Documentation Source: https://github.com/nixos/nixpkgs/blob/master/doc/README.md Build the Nixpkgs manual from the 'doc' directory. The output HTML will be located in './result/share/doc/nixpkgs/manual.html'. ```ShellSession $ cd /path/to/nixpkgs $ nix-build doc ``` -------------------------------- ### Build Emscripten Package with pkgs.zlib.override Source: https://github.com/nixos/nixpkgs/blob/master/doc/languages-frameworks/emscripten.section.md This example demonstrates overriding the standard `stdenv` with `pkgs.emscriptenStdenv` to compile C code to JavaScript. It includes custom build, install, and check phases, with specific Emscripten compiler flags and Node.js execution for tests. ```nix (pkgs.zlib.override { stdenv = pkgs.emscriptenStdenv; }).overrideAttrs (old: { buildInputs = old.buildInputs ++ [ pkg-config ]; # we need to reset this setting! env = (old.env or { }) // { NIX_CFLAGS_COMPILE = ""; }; configurePhase = '' # FIXME: Some tests require writing at $HOME HOME=$TMPDIR runHook preConfigure #export EMCC_DEBUG=2 emconfigure ./configure --prefix=$out --shared runHook postConfigure ''; dontStrip = true; outputs = [ "out" ]; buildPhase = '' runHook preBuild emmake make runHook postBuild ''; installPhase = '' runHook preInstall emmake make install runHook postInstall ''; checkPhase = '' runHook preCheck echo "================= testing zlib using node ================" echo "Compiling a custom test" set -x emcc -O2 -s EMULATE_FUNCTION_POINTER_CASTS=1 test/example.c -DZ_SOLO \ libz.so.${old.version} -I . -o example.js echo "Using node to execute the test" ${pkgs.nodejs}/bin/node ./example.js set +x if [ $? -ne 0 ]; then echo "test failed for some reason" exit 1; else echo "it seems to work! very good." fi echo "================= /testing zlib using node ================" runHook postCheck ''; postPatch = pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isDarwin '' substituteInPlace configure \ --replace-fail '/usr/bin/libtool' 'ar' \ --replace-fail 'AR="libtool"' 'AR="ar"' \ --replace-fail 'ARFLAGS="-o"' 'ARFLAGS="-r"' ''; }) ``` -------------------------------- ### Enable Timekpr-nExT Service in NixOS Source: https://github.com/nixos/nixpkgs/blob/master/nixos/doc/manual/configuration/user-mgmt.chapter.md This Nix code snippet enables the Timekpr-nExT service on a NixOS system. It installs the 'timekpr' package and starts the associated service, allowing for subsequent configuration of time limits using the 'timekpra' application. ```nix { services.timekpr.enable = true; } ``` -------------------------------- ### Libconfig Array and List Example Source: https://github.com/nixos/nixpkgs/blob/master/nixos/doc/manual/development/settings-options.section.md Demonstrates the use of `mkList` and `mkArray` to differentiate between libconfig lists and arrays when converting Nix lists. ```nix let format = pkgs.formats.libconfig { }; in { myList = format.lib.mkList [ "foo" 1 true ]; myArray = format.lib.mkArray [ 1 2 3 ]; } ``` -------------------------------- ### Create Reusable Haskell Override Function Source: https://github.com/nixos/nixpkgs/blob/master/doc/languages-frameworks/haskell.section.md Shows how to create a reusable helper function using `overrideCabal` to abstract common override patterns. The `installManPage` example demonstrates encapsulating the logic for installing a man page, making it easy to apply to different Haskell packages. ```nix let installManPage = haskell.lib.compose.overrideCabal (drv: { postInstall = '' ${drv.postInstall or ""} install -Dm644 man/${drv.pname}.1 -t "$out/share/man/man1" ''; }); in installManPage haskellPackages.pnbackup ``` -------------------------------- ### Configure Caddy with Plugins in Nixpkgs Source: https://github.com/nixos/nixpkgs/blob/master/doc/release-notes/rl-2505.section.md Demonstrates how to build Caddy with custom plugins using the `caddy.withPlugins` function. This function takes a list of versioned plugins and an optional hash for vendored dependencies. If the hash is omitted, the build will fail and provide the correct hash value. ```nix let pkgs = import { }; in pkgs.caddy.withPlugins { plugins = [ # tagged upstream "github.com/caddy-dns/powerdns@v1.0.1" # pseudo-version number generated by Go "github.com/caddy-dns/cloudflare@v0.0.0-20240703190432-89f16b99c18e" "github.com/mholt/caddy-webdav@v0.0.0-20241008162340-42168ba04c9d" ]; hash = "sha256-wqXSd1Ep9TVpQi570TTb96LwzNYvWL5EBJXMJfYWCAk="; } ``` -------------------------------- ### Enable Sway Wayland Compositor Source: https://github.com/nixos/nixpkgs/blob/master/nixos/doc/manual/configuration/wayland.chapter.md Enables the sway Wayland compositor on NixOS. This single option installs the sway compositor and its essential utilities, simplifying Wayland setup. No additional Wayland server configuration is needed as the compositor embeds server functionality. ```nix { programs.sway.enable = true; } ``` -------------------------------- ### Forcing Gradle Initialization Failure Source: https://github.com/nixos/nixpkgs/blob/master/doc/languages-frameworks/gradle.section.md This example demonstrates how to force disable the Gradle setup hook for the configure phase using `dontUseGradleConfigure`. This can be used to test or work around issues where the default initialization causes problems, such as native library loading failures. ```nix let packageWithForcedInitDisable = pkgs.stdenv.mkDerivation { name = "gradle-app-force-init-disable"; src = ./.; # Force disable the Gradle configure hook DONT_USE_GRADLE_CONFIGURE = "true"; buildInputs = [ pkgs.gradle ]; }; in packageWithForcedInitDisable ``` -------------------------------- ### Use shadowSetup with buildLayeredImage for User/Group Management Source: https://github.com/nixos/nixpkgs/blob/master/doc/build-helpers/images/dockertools.section.md Shows how to use dockerTools.shadowSetup with dockerTools.buildLayeredImage, achieving the same result as the buildImage example. User and group management commands are executed within the fakeRootCommands script. ```nix { dockerTools, hello }: dockerTools.buildLayeredImage { name = "shadow-basic"; tag = "latest"; contents = [ hello ]; fakeRootCommands = '' ${dockerTools.shadowSetup} groupadd -r hello useradd -r -g hello hello mkdir /data chown hello:hello /data ''; enableFakechroot = true; config = { Cmd = [ "/bin/hello" ]; WorkingDir = "/data"; }; } ``` -------------------------------- ### Minimal NixOS configuration example Source: https://github.com/nixos/nixpkgs/blob/master/doc/styleguide.md This example demonstrates a clean NixOS configuration snippet, omitting comments for clarity. It sets the hostname and enables SSH access. ```nix { networking.hostName = "webserver"; services.openssh.enable = true; } ``` -------------------------------- ### Get FoundationDB Cluster Status with Python Source: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/services/databases/foundationdb.md An example Python script to retrieve the FoundationDB cluster status. It utilizes the `nix-shell` shebang to automatically provide the necessary Python environment and FoundationDB client library. The script connects to the database and fetches status information. ```shell a@link> cat fdb-status.py #! /usr/bin/env nix-shell #! nix-shell -i python -p python pythonPackages.foundationdb73 import fdb import json def main(): fdb.api_version(520) db = fdb.open() @fdb.transactional def get_status(tr): return str(tr['\xff\xff/status/json']) obj = json.loads(get_status(db)) print('FoundationDB available: %s' % obj['client']['database_status']['available']) if __name__ == "__main__": main() a@link> chmod +x fdb-status.py a@link> ./fdb-status.py FoundationDB available: True a@link> ``` -------------------------------- ### Clone Nixpkgs Repository using Git Source: https://github.com/nixos/nixpkgs/blob/master/nixos/doc/manual/development/sources.chapter.md This snippet demonstrates how to clone the Nixpkgs repository from GitHub. It involves cloning the repository, changing into the directory, and updating the remote origin to fetch the latest changes. This is the initial step to start working with Nixpkgs sources. ```ShellSession $ git clone https://github.com/NixOS/nixpkgs $ cd nixpkgs $ git remote update origin ``` -------------------------------- ### Elaborate mkDerivation Example with Fixed-Point Arguments Source: https://github.com/nixos/nixpkgs/blob/master/doc/stdenv/stdenv.chapter.md A detailed example demonstrating the use of `finalAttrs` and `finalPackage` within `mkDerivation`, illustrating recursive attribute definitions and how they relate to original package bindings. ```nix # `pkg` is the _original_ definition (for illustration purposes) let pkg = mkDerivation (finalAttrs: { # ... # An example attribute packages = [ ]; # `passthru.tests` is a commonly defined attribute. passthru.tests.simple = f finalAttrs.finalPackage; # An example of an attribute containing a function passthru.appendPackages = packages': finalAttrs.finalPackage.overrideAttrs (newSelf: super: { packages = super.packages ++ packages'; }); # For illustration purposes; referenced as # `(pkg.overrideAttrs(x)).finalAttrs` etc in the text below. passthru.finalAttrs = finalAttrs; passthru.original = pkg; }); in pkg ```