Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 pkgs, 4 fetchFromGitHub, 5 python3Packages, 6 nix-prefetch-scripts, 7 runtimeShell, 8}: 9 10python3Packages.buildPythonApplication rec { 11 pname = "nix-update-source"; 12 version = "0.7.0"; 13 format = "setuptools"; 14 15 src = fetchFromGitHub { 16 hash = "sha256-+49Yb+rZ3CzFnwEpwj5xrcMUVBiYOJtCk9YeZ15IM/U="; 17 owner = "timbertson"; 18 repo = "nix-update-source"; 19 rev = "version-${version}"; 20 }; 21 22 propagatedBuildInputs = [ nix-prefetch-scripts ]; 23 24 doCheck = false; 25 26 passthru = { 27 # NOTE: `fetch` should not be used within nixpkgs because it 28 # uses a non-idiomatic structure. It is provided for use by 29 # out-of-tree nix derivations. 30 fetch = 31 path: 32 let 33 fetchers = { 34 # whitelist of allowed fetchers 35 inherit (pkgs) fetchgit fetchurl fetchFromGitHub; 36 }; 37 json = lib.importJSON path; 38 fetchFn = builtins.getAttr json.fetch.fn fetchers; 39 src = fetchFn json.fetch.args; 40 in 41 json 42 // json.fetch 43 // { 44 inherit src; 45 overrideSrc = 46 drv: 47 lib.overrideDerivation drv (orig: { 48 inherit src; 49 }); 50 }; 51 52 updateScript = [ 53 runtimeShell 54 "-c" 55 '' 56 set -e 57 echo 58 cd ${toString ./.} 59 ${pkgs.nix-update-source}/bin/nix-update-source \ 60 --prompt version \ 61 --replace-attr version \ 62 --set owner timbertson \ 63 --set repo nix-update-source \ 64 --set type fetchFromGitHub \ 65 --set rev 'version-{version}' \ 66 --nix-literal rev 'version-''${version}'\ 67 --modify-nix default.nix 68 '' 69 ]; 70 }; 71 72 meta = { 73 homepage = "https://github.com/timbertson/nix-update-source"; 74 description = "Utility to automate updating of nix derivation sources"; 75 maintainers = with lib.maintainers; [ timbertson ]; 76 license = lib.licenses.mit; 77 mainProgram = "nix-update-source"; 78 }; 79}