feeds: fix to work with scripts/update
This commit is contained in:
parent
8f634d9bb0
commit
88d462764f
|
@ -3,19 +3,41 @@
|
|||
, python3
|
||||
, sane-data
|
||||
, static-nix-shell
|
||||
, symlinkJoin
|
||||
, writeShellScript
|
||||
}:
|
||||
|
||||
lib.makeScope newScope (self: with self; {
|
||||
mkFeed = callPackage ./template.nix {};
|
||||
feed-pkgs = lib.recurseIntoAttrs (lib.mapAttrs
|
||||
(name: feed-details: mkFeed {
|
||||
feedName = name;
|
||||
jsonPath = "modules/data/feeds/sources/${name}/default.json";
|
||||
inherit (feed-details) url;
|
||||
})
|
||||
sane-data.feeds
|
||||
);
|
||||
feed-pkgs = let
|
||||
byName = lib.mapAttrs
|
||||
(name: feed-details: mkFeed {
|
||||
feedName = name;
|
||||
jsonPath = "modules/data/feeds/sources/${name}/default.json";
|
||||
inherit (feed-details) url;
|
||||
})
|
||||
sane-data.feeds
|
||||
;
|
||||
in
|
||||
symlinkJoin {
|
||||
# this meta package exists primarily to link all the feed updaters
|
||||
# into a single package which can *actually* be updated.
|
||||
# it's not critical whether the actual package itself builds.
|
||||
name = "feed-pkgs";
|
||||
pname = "feed-pkgs";
|
||||
version = "20230112";
|
||||
paths = builtins.attrValues byName;
|
||||
passthru = byName // {
|
||||
updateScript = let
|
||||
update-all-feeds = writeShellScript "update-all-feeds" (
|
||||
lib.concatStringsSep "\n" (
|
||||
builtins.map (p: lib.concatStringsSep " " p.updateScript) (lib.attrValues byName)
|
||||
)
|
||||
);
|
||||
in
|
||||
[ update-all-feeds ];
|
||||
};
|
||||
};
|
||||
update-feed = static-nix-shell.mkPython3Bin {
|
||||
pname = "update";
|
||||
srcRoot = ./.;
|
||||
|
|
|
@ -13,10 +13,9 @@ stdenv.mkDerivation {
|
|||
src = fetchurl {
|
||||
inherit url;
|
||||
};
|
||||
passthru.updateScript = {
|
||||
name = "feed-update-script";
|
||||
command = [ "${update-feed}/bin/update.py" url jsonPath ];
|
||||
};
|
||||
passthru.updateScript = [
|
||||
"${update-feed}/bin/update.py" url jsonPath
|
||||
];
|
||||
meta = {
|
||||
description = "metadata about any feeds available at ${feedName}";
|
||||
homepage = feedName;
|
||||
|
|
|
@ -3,12 +3,16 @@
|
|||
|
||||
usage() {
|
||||
echo "update: update rev/hash for one or more packages"
|
||||
echo "usage: update [attr-path]"
|
||||
echo "usage: update [options] [attr-path]"
|
||||
echo ""
|
||||
echo "options:"
|
||||
echo "- --dry-run"
|
||||
echo "- --verbose"
|
||||
echo ""
|
||||
echo "examples:"
|
||||
echo "update nixpkgs: update only the nixpkgs input"
|
||||
echo "update sane: update every package under the 'sane' attribute"
|
||||
echo "update: update everything i know how to update"
|
||||
echo "- update nixpkgs: update only the nixpkgs input"
|
||||
echo "- update sane: update every package under the 'sane' attribute"
|
||||
echo "- update: update everything i know how to update"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -18,6 +22,11 @@ warn() {
|
|||
info() {
|
||||
echo "$@"
|
||||
}
|
||||
debug() {
|
||||
if [ -n "$verbose" ]; then
|
||||
echo "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
hasEffect() {
|
||||
if [ -n "$dryRun" ]; then
|
||||
|
@ -46,16 +55,22 @@ updateOnePkg() {
|
|||
warn "don't know how to update '$attrPath'"
|
||||
return
|
||||
fi
|
||||
|
||||
# make sure everything needed to invoke the script actually exists on disk
|
||||
nix-build -A "$attrPath.passthru.updateScript" || true
|
||||
|
||||
local UPDATE_NIX_NAME="$(nix eval --raw -f . $attrPath.name)"
|
||||
local UPDATE_NIX_PNAME="$(nix eval --raw -f . $attrPath.pname)"
|
||||
local UPDATE_NIX_OLD_VERSION="$(nix eval --raw -f . $attrPath.version)"
|
||||
info "updating: '$attrPath'"
|
||||
debug "$updateScript"
|
||||
# we lose spaces inside the exec args... could `nix eval` without `--raw` to fix that.
|
||||
UPDATE_NIX_NAME="$UPDATE_NIX_NAME" UPDATE_NIX_PNAME="$UPDATE_NIX_PNAME" UPDATE_NIX_OLD_VERSION="$UPDATE_NIX_OLD_VERSION" UPDATE_NIX_ATTR_PATH="$attrPath" eval $updateScript
|
||||
}
|
||||
|
||||
dryRun=
|
||||
toplevelsToUpdate=()
|
||||
verbose=
|
||||
parseArgs() {
|
||||
while [ "$#" -ne 0 ]; do
|
||||
local arg=$1
|
||||
|
@ -67,6 +82,9 @@ parseArgs() {
|
|||
(--dry-run)
|
||||
dryRun=1
|
||||
;;
|
||||
(--verbose)
|
||||
verbose=1
|
||||
;;
|
||||
(*)
|
||||
toplevelsToUpdate+=("$arg")
|
||||
;;
|
||||
|
|
Loading…
Reference in New Issue
Block a user