scripts/update: fix that the script wasnt building the update scripts before trying to invoke them
This commit is contained in:
parent
0d1d56870f
commit
815ce6287f
5
integrations/nix-update/default.nix
Normal file
5
integrations/nix-update/default.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
# this is the entry point for `nix-update`, used when i update the packages in this repo.
|
||||
# nix-update needs to work on the actual out-of-store source,
|
||||
# which means it can't call through the hermetic `default.nix` at the top of this repo,
|
||||
# but rather needs the in-place `impure.nix` entry point.
|
||||
import ../../impure.nix
|
|
@ -1,6 +1,8 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p nix-update
|
||||
|
||||
NIX_FILES_TOP=/home/colin/nixos
|
||||
|
||||
usage() {
|
||||
echo "update: update rev/hash for one or more packages"
|
||||
echo "usage: update [options] [attr-path]"
|
||||
|
@ -44,8 +46,13 @@ getPkgs() {
|
|||
attrPrefix=sane
|
||||
fi
|
||||
|
||||
# nix-env doesn't seem to build anything when evaluating queries,
|
||||
# but since i use Import From Derivation along paths which i also want to query,
|
||||
# then i need to ensure those derivations are available for import.
|
||||
debug "creating requisite .drv store paths"
|
||||
nix-instantiate -A nixpkgs "$NIX_FILES_TOP"
|
||||
debug "querying attributes which match '$attrPrefix'"
|
||||
local attrs=$(nix-env -f . --query --available --attr-path --no-name -A "$attrPrefix" --show-trace)
|
||||
local attrs=$(nix-env -f "$NIX_FILES_TOP" --query --available --attr-path --no-name -A "$attrPrefix" --show-trace)
|
||||
debug "got: $attrs"
|
||||
attrsArr+=($attrs)
|
||||
}
|
||||
|
@ -53,27 +60,37 @@ getPkgs() {
|
|||
updateOnePkg() {
|
||||
local attrPath="$1"
|
||||
|
||||
if [[ "$attrPath" =~ ^"$ignore" ]]; then
|
||||
if [ -n "$ignore" ] && [[ "$attrPath" =~ ^"$ignore" ]]; then
|
||||
warn "ignoring $attrPath"
|
||||
return
|
||||
fi
|
||||
|
||||
local updateScript="$(nix eval --raw -f . $attrPath.passthru.updateScript --apply 'builtins.concatStringsSep "'" "'"')"
|
||||
local updateScript=$(nix eval --raw -f "$NIX_FILES_TOP" $attrPath.passthru.updateScript --apply 'builtins.concatStringsSep "'" "'"')
|
||||
if [ -z "$updateScript" ]; then
|
||||
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
|
||||
# make sure everything needed to invoke the update script exists in-store
|
||||
local context=$(nix eval --raw -f "$NIX_FILES_TOP" $attrPath.passthru.updateScript --apply 's: builtins.concatStringsSep " " (builtins.foldl'"'"' (acc: next: acc ++ next) [] (builtins.map builtins.attrNames (builtins.map builtins.getContext s)))')
|
||||
for c in $context; do
|
||||
debug "realizing updateScript requisite: $context"
|
||||
nix-store --realize "$c" || true
|
||||
done
|
||||
|
||||
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)"
|
||||
local UPDATE_NIX_NAME=$(nix eval --raw -f "$NIX_FILES_TOP" $attrPath.name)
|
||||
local UPDATE_NIX_PNAME=$(nix eval --raw -f "$NIX_FILES_TOP" $attrPath.pname)
|
||||
local UPDATE_NIX_OLD_VERSION=$(nix eval --raw -f "$NIX_FILES_TOP" $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
|
||||
(
|
||||
# update script assumes $PWD is an entry point to a writable copy of my nix config,
|
||||
# so provide that:
|
||||
pushd "$NIX_FILES_TOP/integrations/nix-update"
|
||||
# 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
|
||||
popd
|
||||
)
|
||||
}
|
||||
|
||||
dryRun=
|
||||
|
|
Loading…
Reference in New Issue
Block a user