fix pkgs.feeds update scripts
This commit is contained in:
54
flake.nix
54
flake.nix
@@ -256,17 +256,21 @@
|
|||||||
# let the user handle that edge case by re-running this whole command
|
# let the user handle that edge case by re-running this whole command
|
||||||
nixos-rebuild --flake '.#${host}' ${action} --target-host colin@${addr} --use-remote-sudo $@
|
nixos-rebuild --flake '.#${host}' ${action} --target-host colin@${addr} --use-remote-sudo $@
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
# pkg updating.
|
||||||
|
# a cleaner alternative lives here: <https://discourse.nixos.org/t/how-can-i-run-the-updatescript-of-personal-packages/25274/2>
|
||||||
mkUpdater = attrPath: {
|
mkUpdater = attrPath: {
|
||||||
type = "app";
|
type = "app";
|
||||||
program = let
|
program = let
|
||||||
pkg = pkgs.lib.getAttrFromPath attrPath sanePkgs;
|
pkg = pkgs.lib.getAttrFromPath attrPath sanePkgs;
|
||||||
strAttrPath = pkgs.lib.concatStringsSep "." attrPath;
|
strAttrPath = pkgs.lib.concatStringsSep "." attrPath;
|
||||||
in builtins.toString (pkgs.writeShellScript "update-${pkg.name}" ''
|
command = pkgs.lib.escapeShellArgs pkg.updateScript.command;
|
||||||
|
in builtins.toString (pkgs.writeShellScript "update-${strAttrPath}" ''
|
||||||
export UPDATE_NIX_NAME=${pkg.name}
|
export UPDATE_NIX_NAME=${pkg.name}
|
||||||
export UPDATE_NIX_PNAME=${pkg.pname}
|
export UPDATE_NIX_PNAME=${pkg.pname}
|
||||||
export UPDATE_NIX_OLD_VERSION=${pkg.version}
|
export UPDATE_NIX_OLD_VERSION=${pkg.version}
|
||||||
export UPDATE_NIX_ATTR_PATH=${strAttrPath}
|
export UPDATE_NIX_ATTR_PATH=${strAttrPath}
|
||||||
${pkgs.lib.escapeShellArgs pkg.updateScript.command}
|
${command}
|
||||||
'');
|
'');
|
||||||
};
|
};
|
||||||
mkUpdatersNoAliases = basePath: pkgs.lib.concatMapAttrs
|
mkUpdatersNoAliases = basePath: pkgs.lib.concatMapAttrs
|
||||||
@@ -283,30 +287,23 @@
|
|||||||
updaters = mkUpdatersNoAliases basePath;
|
updaters = mkUpdatersNoAliases basePath;
|
||||||
invokeUpdater = name: pkg:
|
invokeUpdater = name: pkg:
|
||||||
let
|
let
|
||||||
subUpdater =
|
# in case `name` has a `.` in it, we have to quote it
|
||||||
if pkg.type or "" == "app" then
|
escapedPath = builtins.map (p: ''"${p}"'') (basePath ++ [ name ]);
|
||||||
# simple package
|
updatePath = builtins.concatStringsSep "." ([ "update" "pkgs" ] ++ escapedPath);
|
||||||
basePath ++ [ name ]
|
in pkgs.lib.escapeShellArgs [
|
||||||
else if (pkg.all or {}).type or "" == "app" then
|
"nix" "run" ".#${updatePath}"
|
||||||
# package group
|
];
|
||||||
basePath ++ [ name "all" ]
|
|
||||||
else null; # possibly a collection which can't be updated as one.
|
|
||||||
updatePath = builtins.concatStringsSep "." ([ "update" "pkgs" ] ++ subUpdater);
|
|
||||||
in pkgs.lib.optionalString (subUpdater != null) (
|
|
||||||
"nix run '.#${updatePath}'"
|
|
||||||
);
|
|
||||||
in {
|
in {
|
||||||
all = {
|
#all = {
|
||||||
type = "app";
|
type = "app";
|
||||||
program = builtins.toString (pkgs.writeShellScript
|
program = builtins.toString (pkgs.writeShellScript
|
||||||
"update-${builtins.concatStringsSep "-" basePath}"
|
(builtins.concatStringsSep "-" (["update"] ++ basePath))
|
||||||
(
|
(builtins.concatStringsSep
|
||||||
builtins.concatStringsSep
|
"\n"
|
||||||
"\n"
|
(pkgs.lib.mapAttrsToList invokeUpdater updaters)
|
||||||
(pkgs.lib.mapAttrsToList invokeUpdater updaters)
|
)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
};
|
#};
|
||||||
} // updaters;
|
} // updaters;
|
||||||
in {
|
in {
|
||||||
help = {
|
help = {
|
||||||
@@ -316,10 +313,10 @@
|
|||||||
commands:
|
commands:
|
||||||
- `nix run '.#help'`
|
- `nix run '.#help'`
|
||||||
- show this message
|
- show this message
|
||||||
- `nix run '.#update.feeds'`
|
- `nix run '.#update.pkgs'`
|
||||||
|
- updates every package
|
||||||
|
- `nix run '.#update.pkgs.feeds'`
|
||||||
- updates metadata for all feeds
|
- updates metadata for all feeds
|
||||||
- `nix run '.#update.pkgs.firefox-extensions.unwrapped.bypass-paywalls-clean'`
|
|
||||||
- runs the `updateScript` for the corresponding pkg, if it has one
|
|
||||||
- `nix run '.#init-feed' <url>`
|
- `nix run '.#init-feed' <url>`
|
||||||
- `nix run '.#deploy-{lappy,moby,moby-test,servo}' [nixos-rebuild args ...]`
|
- `nix run '.#deploy-{lappy,moby,moby-test,servo}' [nixos-rebuild args ...]`
|
||||||
- `nix run '.#check-nur'`
|
- `nix run '.#check-nur'`
|
||||||
@@ -328,16 +325,11 @@
|
|||||||
cat ${helpMsg}
|
cat ${helpMsg}
|
||||||
'');
|
'');
|
||||||
};
|
};
|
||||||
update.feeds = {
|
|
||||||
type = "app";
|
|
||||||
program = "${pkgs.feeds.updateScript}";
|
|
||||||
};
|
|
||||||
|
|
||||||
update.pkgs = mkUpdaters [];
|
update.pkgs = mkUpdaters [];
|
||||||
|
|
||||||
init-feed = {
|
init-feed = {
|
||||||
type = "app";
|
type = "app";
|
||||||
program = "${pkgs.feeds.initFeedScript}";
|
program = "${pkgs.feeds.init-feed}";
|
||||||
};
|
};
|
||||||
|
|
||||||
deploy-lappy = {
|
deploy-lappy = {
|
||||||
|
@@ -1,27 +1,22 @@
|
|||||||
{ lib
|
{ lib
|
||||||
, callPackage
|
, newScope
|
||||||
, python3
|
, python3
|
||||||
, sane-data
|
, sane-data
|
||||||
, static-nix-shell
|
, static-nix-shell
|
||||||
, writeShellScript
|
, writeShellScript
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
lib.makeScope newScope (self: with self; {
|
||||||
# TODO: dependency-inject this.
|
mkFeed = callPackage ./template.nix {};
|
||||||
template = callPackage ./template.nix;
|
feed-pkgs = lib.recurseIntoAttrs (lib.mapAttrs
|
||||||
feed-pkgs' = lib.mapAttrs
|
(name: feed-details: mkFeed {
|
||||||
(name: feed-details: template {
|
|
||||||
feedName = name;
|
feedName = name;
|
||||||
jsonPath = "modules/data/feeds/sources/${name}/default.json";
|
jsonPath = "modules/data/feeds/sources/${name}/default.json";
|
||||||
inherit (feed-details) url;
|
inherit (feed-details) url;
|
||||||
})
|
})
|
||||||
sane-data.feeds;
|
sane-data.feeds
|
||||||
update-scripts = lib.mapAttrsToList
|
);
|
||||||
(name: feed: builtins.concatStringsSep " " feed.passthru.updateScript)
|
update-feed = static-nix-shell.mkPython3Bin {
|
||||||
feed-pkgs';
|
|
||||||
in rec { # TODO: make this a scope
|
|
||||||
feed-pkgs = lib.recurseIntoAttrs feed-pkgs';
|
|
||||||
update = static-nix-shell.mkPython3Bin {
|
|
||||||
pname = "update";
|
pname = "update";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
pyPkgs = [ "feedsearch-crawler" ];
|
pyPkgs = [ "feedsearch-crawler" ];
|
||||||
@@ -46,12 +41,7 @@ in rec { # TODO: make this a scope
|
|||||||
# but in a way where the least could go wrong.
|
# but in a way where the least could go wrong.
|
||||||
pushd "$sources_dir"; mkdir -p "$name"; popd
|
pushd "$sources_dir"; mkdir -p "$name"; popd
|
||||||
|
|
||||||
${update}/bin/update.py "$name" "$json_path"
|
${update-feed}/bin/update.py "$name" "$json_path"
|
||||||
cat "$json_path"
|
cat "$json_path"
|
||||||
'';
|
'';
|
||||||
|
})
|
||||||
updateScript = writeShellScript
|
|
||||||
"feeds-update"
|
|
||||||
(builtins.concatStringsSep "\n" update-scripts);
|
|
||||||
initFeedScript = init-feed;
|
|
||||||
}
|
|
||||||
|
@@ -1,20 +1,22 @@
|
|||||||
{ lib
|
{ lib
|
||||||
, stdenv
|
, stdenv
|
||||||
, callPackage
|
|
||||||
, fetchurl
|
, fetchurl
|
||||||
# feed-specific args
|
, update-feed
|
||||||
, feedName
|
|
||||||
, jsonPath
|
|
||||||
, url
|
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
# feed-specific args
|
||||||
|
{ feedName, jsonPath, url }:
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
pname = feedName;
|
pname = feedName;
|
||||||
version = "20230112";
|
version = "20230112";
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
inherit url;
|
inherit url;
|
||||||
};
|
};
|
||||||
passthru.updateScript = [ ./update.py url jsonPath ];
|
passthru.updateScript = {
|
||||||
|
name = "feed-update-script";
|
||||||
|
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;
|
||||||
|
Reference in New Issue
Block a user