From 892fd83ec8ecbb0be1b4e2074f975a705e40d0b1 Mon Sep 17 00:00:00 2001 From: Tim Cuthbertson Date: Sat, 11 Feb 2017 22:37:53 +1100 Subject: [PATCH] nix-update-source: init at 0.4.0 --- .../nix-update-source/default.nix | 46 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 48 insertions(+) create mode 100644 pkgs/tools/package-management/nix-update-source/default.nix diff --git a/pkgs/tools/package-management/nix-update-source/default.nix b/pkgs/tools/package-management/nix-update-source/default.nix new file mode 100644 index 000000000000..a156c4f8a722 --- /dev/null +++ b/pkgs/tools/package-management/nix-update-source/default.nix @@ -0,0 +1,46 @@ +{ lib, pkgs, fetchFromGitHub, python3Packages, nix-prefetch-scripts }: +python3Packages.buildPythonApplication rec { + version = "0.4.0"; + name = "nix-update-source-${version}"; + src = fetchFromGitHub { + owner = "timbertson"; + repo = "nix-update-source"; + rev = "version-0.4.0"; + sha256 = "0gz0f7nx1q697s16ya7q84q1cj020n547k2ffb99ds2r40nckr2g"; + }; + propagatedBuildInputs = [ nix-prefetch-scripts ]; + passthru = { + # NOTE: `fetch` should not be used within nixpkgs because it + # uses a non-idiomatic structure. It is provided for use by + # out-of-tree nix derivations. + fetch = path: + let + fetchers = { + # whitelist of allowed fetchers + inherit (pkgs) fetchgit fetchurl fetchFromGitHub; + }; + json = lib.importJSON path; + fetchFn = builtins.getAttr json.fetch.fn fetchers; + src = fetchFn json.fetch.args; + in + json // json.fetch // { inherit src; }; + updateScript = '' + set -e + echo + cd ${toString ./.} + ${pkgs.nix-update-source}/bin/nix-update-source \ + --prompt version \ + --replace-attr version \ + --set owner timbertson \ + --set repo nix-update-source \ + --set type fetchFromGitHub \ + --set rev 'version-{version}' \ + --modify-nix default.nix + ''; + }; + meta = { + description = "Utility to automate updating of nix derivation sources"; + maintainers = with lib.maintainers; [ timbertson ]; + license = lib.licenses.mit; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6b7b5cd5599b..f77cde6c0cee 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -17635,6 +17635,8 @@ with pkgs; nix-prefetch-zip nix-prefetch-scripts; + nix-update-source = callPackage ../tools/package-management/nix-update-source {}; + nix-template-rpm = callPackage ../build-support/templaterpm { inherit (pythonPackages) python toposort; }; nix-repl = callPackage ../tools/package-management/nix-repl { };