feeds: fix to work with scripts/update
This commit is contained in:
@@ -3,19 +3,41 @@
|
|||||||
, python3
|
, python3
|
||||||
, sane-data
|
, sane-data
|
||||||
, static-nix-shell
|
, static-nix-shell
|
||||||
|
, symlinkJoin
|
||||||
, writeShellScript
|
, writeShellScript
|
||||||
}:
|
}:
|
||||||
|
|
||||||
lib.makeScope newScope (self: with self; {
|
lib.makeScope newScope (self: with self; {
|
||||||
mkFeed = callPackage ./template.nix {};
|
mkFeed = callPackage ./template.nix {};
|
||||||
feed-pkgs = lib.recurseIntoAttrs (lib.mapAttrs
|
feed-pkgs = let
|
||||||
(name: feed-details: mkFeed {
|
byName = lib.mapAttrs
|
||||||
feedName = name;
|
(name: feed-details: mkFeed {
|
||||||
jsonPath = "modules/data/feeds/sources/${name}/default.json";
|
feedName = name;
|
||||||
inherit (feed-details) url;
|
jsonPath = "modules/data/feeds/sources/${name}/default.json";
|
||||||
})
|
inherit (feed-details) url;
|
||||||
sane-data.feeds
|
})
|
||||||
);
|
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 {
|
update-feed = static-nix-shell.mkPython3Bin {
|
||||||
pname = "update";
|
pname = "update";
|
||||||
srcRoot = ./.;
|
srcRoot = ./.;
|
||||||
|
@@ -13,10 +13,9 @@ stdenv.mkDerivation {
|
|||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
inherit url;
|
inherit url;
|
||||||
};
|
};
|
||||||
passthru.updateScript = {
|
passthru.updateScript = [
|
||||||
name = "feed-update-script";
|
"${update-feed}/bin/update.py" url jsonPath
|
||||||
command = [ "${update-feed}/bin/update.py" url jsonPath ];
|
];
|
||||||
};
|
|
||||||
meta = {
|
meta = {
|
||||||
description = "metadata about any feeds available at ${feedName}";
|
description = "metadata about any feeds available at ${feedName}";
|
||||||
homepage = feedName;
|
homepage = feedName;
|
||||||
|
@@ -3,12 +3,16 @@
|
|||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "update: update rev/hash for one or more packages"
|
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 ""
|
||||||
echo "examples:"
|
echo "examples:"
|
||||||
echo "update nixpkgs: update only the nixpkgs input"
|
echo "- update nixpkgs: update only the nixpkgs input"
|
||||||
echo "update sane: update every package under the 'sane' attribute"
|
echo "- update sane: update every package under the 'sane' attribute"
|
||||||
echo "update: update everything i know how to update"
|
echo "- update: update everything i know how to update"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,6 +22,11 @@ warn() {
|
|||||||
info() {
|
info() {
|
||||||
echo "$@"
|
echo "$@"
|
||||||
}
|
}
|
||||||
|
debug() {
|
||||||
|
if [ -n "$verbose" ]; then
|
||||||
|
echo "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
hasEffect() {
|
hasEffect() {
|
||||||
if [ -n "$dryRun" ]; then
|
if [ -n "$dryRun" ]; then
|
||||||
@@ -46,16 +55,22 @@ updateOnePkg() {
|
|||||||
warn "don't know how to update '$attrPath'"
|
warn "don't know how to update '$attrPath'"
|
||||||
return
|
return
|
||||||
fi
|
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_NAME="$(nix eval --raw -f . $attrPath.name)"
|
||||||
local UPDATE_NIX_PNAME="$(nix eval --raw -f . $attrPath.pname)"
|
local UPDATE_NIX_PNAME="$(nix eval --raw -f . $attrPath.pname)"
|
||||||
local UPDATE_NIX_OLD_VERSION="$(nix eval --raw -f . $attrPath.version)"
|
local UPDATE_NIX_OLD_VERSION="$(nix eval --raw -f . $attrPath.version)"
|
||||||
info "updating: '$attrPath'"
|
info "updating: '$attrPath'"
|
||||||
|
debug "$updateScript"
|
||||||
# we lose spaces inside the exec args... could `nix eval` without `--raw` to fix that.
|
# 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
|
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=
|
dryRun=
|
||||||
toplevelsToUpdate=()
|
toplevelsToUpdate=()
|
||||||
|
verbose=
|
||||||
parseArgs() {
|
parseArgs() {
|
||||||
while [ "$#" -ne 0 ]; do
|
while [ "$#" -ne 0 ]; do
|
||||||
local arg=$1
|
local arg=$1
|
||||||
@@ -67,6 +82,9 @@ parseArgs() {
|
|||||||
(--dry-run)
|
(--dry-run)
|
||||||
dryRun=1
|
dryRun=1
|
||||||
;;
|
;;
|
||||||
|
(--verbose)
|
||||||
|
verbose=1
|
||||||
|
;;
|
||||||
(*)
|
(*)
|
||||||
toplevelsToUpdate+=("$arg")
|
toplevelsToUpdate+=("$arg")
|
||||||
;;
|
;;
|
||||||
|
Reference in New Issue
Block a user