dev.fron.io rc / ccbd1d8
flake(shell): forecast command Tony Olagbaiye 6 months ago
1 changed file(s) with 28 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
787787 { name = "machines"; path = /etc/nix/machines; }
788788 ] );
789789
790 commands.forecast = ''
791 REPO=$(nix build --impure --json --no-link '.#lib.forecast' | jq '.[] | .outputs.out' -r)
792 git fetch $REPO substrate:substrate
793 git branch -f substrate FETCH_HEAD
794 '';
795
790796 motd = "";
791797 }
792798 );
803809
804810 forecast = let
805811 inherit (channels.pkgs.legacyPackages.${builtins.currentSystem}) pkgs;
806 date = builtins.readFile (pkgs.runCommand "forecast-name" {
812 date = builtins.readFile (pkgs.runCommandLocal "forecast-name" {
813 nonce = builtins.currentTime;
807814 } "date -Iminutes | tr 'T\\-:' '---' | cut -d+ -f1 | tr -d '\n' > $out");
808 in pkgs.runCommandLocal "forecast-${date}" {
815 in pkgs.runCommandLocal "forecast-${date}" rec {
816 repo = builtins.getEnv "PWD";
809817 buildInputs = [ pkgs.git pkgs.nixUnstable pkgs.cacert ];
818 PAGER = "cat";
819 GIT_AUTHOR_NAME = "ci";
820 GIT_AUTHOR_EMAIL = "nix@system";
821 GIT_COMMITTER_NAME = "systemd";
822 GIT_COMMITTER_EMAIL = "timer@service";
823 INPUTS = (with builtins.mapAttrs lib.const inputs; [
824 master
825 small
826 ]);
810827 __noChroot = true;
811828 } ''
812 git clone ${./.} $out
829 git clone $repo $out
813830 export NIX_REMOTE=local?real=$PWD/nix/store\&store=/nix/store
814831 export NIX_STATE_DIR=$PWD/nix/var NIX_LOG_DIR=$PWD/nix/var/log
815832 export HOME=$PWD
816833 cd $out
817 nix flake update \
818 --experimental-features "nix-command flakes ca-references"
834 git switch -c substrate live
835 git commit-tree -m "merge: live" -p HEAD -p origin/live origin/live:
836 git reset --hard origin/live
837 for INP in $INPUTS; do
838 nix flake update --update-input $INP \
839 --experimental-features "nix-command flakes ca-references"
840 git commit -m "flake(lock): autoupdate $INP" flake.lock
841 done
819842 '';
820843 };
821844