From fa7b11c557b33edab480f170c1f8ab9fcda99663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 29 Jun 2018 17:38:21 +0100 Subject: [PATCH] README.md: repo example --- README.md | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 58 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7c86da09d..87b03f8a8 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ For NixOS add the following to your `/etc/nixos/configuration.nix`: nur = pkgs.callPackage (import (builtins.fetchGit { url = "https://github.com/nix-community/NUR"; })) {}; - } + }; } ``` @@ -79,23 +79,76 @@ DO NOT import packages for example `with import {};`. Instead take all dependency you want to import from nixpkgs by function arguments. Each repository should return a set of nix derivations: -``` +```nix { callPackage }: { inxi = callPackage ./inxi {}; } ``` -In this example `inxi` would be a directory +In this example `inxi` would be a directory containing a `default.nix`: + +```nix +{ stdenv, fetchFromGitHub +, makeWrapper, perl +, dmidecode, file, hddtemp, nettools, iproute, lm_sensors, usbutils, kmod, xlibs +}: + +let + path = [ + dmidecode file hddtemp nettools iproute lm_sensors usbutils kmod + xlibs.xdpyinfo xlibs.xprop xlibs.xrandr + ]; +in stdenv.mkDerivation rec { + name = "inxi-${version}"; + version = "3.0.14-1"; + + src = fetchFromGitHub { + owner = "smxi"; + repo = "inxi"; + rev = version; + sha256 = "0wyv8cqwy7jlv2r3j7w8ri73iywawnaihww39vlpnpjjcz1b37hw"; + }; + + installPhase = '' + install -D -m755 inxi $out/bin/inxi + install -D inxi.1 $out/man/man1/inxi.1 + wrapProgram $out/bin/inxi \ + --prefix PATH : ${ stdenv.lib.makeBinPath path } + ''; + + buildInputs = [ perl ]; + nativeBuildInputs = [ makeWrapper ]; + + meta = with stdenv.lib; { + description = "System information tool"; + homepage = https://github.com/smxi/inxi; + license = licenses.gpl3; + platforms = platforms.linux; + }; +} +``` + +You can use `nix-shell` or `nix-build` to build your packages: + +```console +$ nix-shell -E 'with import {}; (callPackage ./default.nix {}).inxi' +nix-shell> inxi +nix-shell> find $buildInputs +``` + +```console +$ nix-build -E 'with import {}; (callPackage ./default.nix {})' +``` Add your own repository to in the `repos.json` of NUR: -``` +```console $ git clone https://github.com/nix-community/NUR # open and modify repos.json in an editor ``` -``` +```json { "repos": { "mic92": {