wip!
Signed-off-by: Christoph Heiss <christoph@c8h4.io>
This commit is contained in:
parent
47fd05de5f
commit
e7778794fc
23
flake.nix
23
flake.nix
|
@ -125,11 +125,34 @@
|
|||
chmod +x .git/hooks/pre-commit
|
||||
'';
|
||||
};
|
||||
|
||||
updatePackages = pkgs.writeShellApplication {
|
||||
name = "update-packages";
|
||||
runtimeInputs = with pkgs; [ nix git jq ];
|
||||
text = ''
|
||||
update-and-commit() {
|
||||
local old_ver new_ver changes
|
||||
|
||||
# shellcheck disable=SC2046
|
||||
read -r old_ver new_ver <<<$(./pkgs/update.sh)
|
||||
|
||||
changes="$(git diff-index HEAD "pkgs/$1")"
|
||||
if [ -n "$changes" ]; then
|
||||
git add "pkgs/$1"
|
||||
git commit --verbose --signoff --message "pkgs: $1: $old_ver -> $new_ver"
|
||||
fi
|
||||
}
|
||||
|
||||
update-and-commit dashboard-icons
|
||||
update-and-commit homer
|
||||
'';
|
||||
};
|
||||
in {
|
||||
apps = (nixinate.nixinate.${system} self).nixinate // {
|
||||
maui = mkApp { drv = mkHomeManagerFlake "maui"; };
|
||||
check-git-history = mkApp { drv = checkGitHistory; };
|
||||
setup-git-hooks = mkApp { drv = setupGitHooks; };
|
||||
update-packages = mkApp { drv = updatePackages; };
|
||||
};
|
||||
|
||||
checks = {
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
{ stdenvNoCC, fetchFromGitHub }:
|
||||
|
||||
let upstreamCommit = "acf4a4ddd9354335bbb6995175179122f5845607";
|
||||
let rev = "acf4a4ddd9354335bbb6995175179122f5845607";
|
||||
in stdenvNoCC.mkDerivation rec {
|
||||
pname = "dashboard-icons";
|
||||
version = "unstable-2024-03-24-${upstreamCommit}";
|
||||
version = "unstable-2024-03-24-${rev}";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "walkxcode";
|
||||
repo = pname;
|
||||
rev = upstreamCommit;
|
||||
inherit rev;
|
||||
hash = "sha256-4D98y396Kbe3iWv3Xi/URHruPmDUxmxd2yPZ2gkxwow=";
|
||||
};
|
||||
|
|
@ -2,7 +2,7 @@ _: super:
|
|||
|
||||
{
|
||||
automation-shell = super.callPackage ./automation-shell.nix { };
|
||||
dashboard-icons = super.callPackage ./dashboard-icons.nix { };
|
||||
dashboard-icons = super.callPackage ./dashboard-icons { };
|
||||
deploy-sink = super.callPackage ./deploy-sink.nix { };
|
||||
git-multi-shortlog = super.callPackage ./git-multi-shortlog.nix { };
|
||||
homer = super.callPackage ./homer { };
|
||||
|
|
75
pkgs/update.sh
Executable file
75
pkgs/update.sh
Executable file
|
@ -0,0 +1,75 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p curl nix-prefetch-github jq gnused gnutar gzip nodejs prefetch-npm-deps nix
|
||||
# shellcheck shell=bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
|
||||
|
||||
get-pkg-attr() {
|
||||
local expr
|
||||
expr="let pkgs = import <nixpkgs> { }; in (import ./.. null pkgs).$1.$2"
|
||||
nix-instantiate --eval --strict --expr "$expr" | jq -r
|
||||
}
|
||||
|
||||
if ! grep -q fetchFromGitHub "$pkgdir/default.nix"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pkgdir=$PWD
|
||||
name="$(basename "$pkgdir")"
|
||||
|
||||
owner="$(get-pkg-attr .. "$name" src.owner)"
|
||||
repo="$(get-pkg-attr .. "$name" src.repo)"
|
||||
|
||||
update-version() {
|
||||
sed -i "s/version = \"[0-9.]*\";/version = \"$1\";/g" "$pkgdir/default.nix"
|
||||
}
|
||||
|
||||
update-hash() {
|
||||
local hash
|
||||
hash=$(nix-prefetch-github --fetch-submodules --rev "$1" "$owner" "$repo" | jq -r .hash)
|
||||
sed -i "s|hash = \"[a-zA-Z0-9\/+-=]*\";|hash = \"$hash\";|g" "$pkgdir/default.nix"
|
||||
}
|
||||
|
||||
update-package-lock() {
|
||||
local tarball
|
||||
tarball="$(get-pkg-attr .. "$name" src.url)"
|
||||
|
||||
pushd "$(mktemp -d)" || exit 1
|
||||
curl -L -O "$tarball"
|
||||
tar -xvf "$(basename "$tarball")"
|
||||
|
||||
cd "$name-$1"
|
||||
npm install --package-lock-only
|
||||
cp -v ./package-lock.json "$pkgdir/package-lock.json"
|
||||
cat ./package-lock.json
|
||||
|
||||
popd
|
||||
}
|
||||
|
||||
update-npm-deps-hash() {
|
||||
local hash
|
||||
hash=$(prefetch-npm-deps ./package-lock.json)
|
||||
sed -i "s|npmDepsHash = \"[a-zA-Z0-9\/+-=]*\";|npmDepsHash = \"$hash\";|g" "$pkgdir/default.nix"
|
||||
}
|
||||
|
||||
latest_tag="$(curl -s "https://api.github.com/repos/$owner/$repo/releases/latest" | jq -r ".tag_name")"
|
||||
latest_ver="$(expr "$latest_tag" : 'v\(.*\)')"
|
||||
current_ver="$(get-pkg-attr .. "$name" version)"
|
||||
|
||||
if [[ "$latest_ver" == "$current_ver" ]]; then
|
||||
echo "nothing to do"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
update-version "$latest_ver"
|
||||
update-hash "$latest_tag"
|
||||
|
||||
if [[ -f "$pkgdir/package-lock.json" ]]; then
|
||||
latest_ver="$(get-pkg-attr .. "$name" version)"
|
||||
update-package-lock "$latest_ver"
|
||||
update-npm-deps-hash
|
||||
fi
|
Loading…
Reference in a new issue