From 026f63eb88baef0c36a2388ac57d1c30c647801d Mon Sep 17 00:00:00 2001 From: maralorn Date: Sun, 5 Feb 2023 11:55:17 +0100 Subject: [PATCH] Improve flake updates --- nixos/roles/laminar/bump-config.hs | 16 ++++++++-------- nixos/roles/laminar/test-config.hs | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/nixos/roles/laminar/bump-config.hs b/nixos/roles/laminar/bump-config.hs index 0dc7d0d7..16650058 100644 --- a/nixos/roles/laminar/bump-config.hs +++ b/nixos/roles/laminar/bump-config.hs @@ -10,6 +10,7 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall -Werror -Wno-missing-signatures -Wno-type-defaults -Wno-orphans #-} +import Data.ByteString.Lazy qualified as LBS import Data.String.Interpolate import Data.Text qualified as Text import Language.Haskell.TH @@ -30,13 +31,12 @@ paths = repo = "git@hera.m-0.eu:nixos-config" main = do + git "config" "user.email" "maralorn@maralorn.de" + git "config" "user.name" "maralorn (nix-auto-updater)" git "clone" repo "." setEnv "PATH" . toString $ Text.intercalate ":" paths - ignoreFailure $ nix "flake" "update" - changed <- (mempty /=) <$> (git "status" "--porcelain" |> captureTrim) - when changed $ do - git "config" "user.email" "maralorn@maralorn.de" - git "config" "user.name" "maralorn (nix-auto-updater)" - git "commit" "-am" "Update flake dependencies" - git "push" "-f" "origin" "HEAD:niv-bump" - unless changed $ say "No flake updates. Doing nothing." + ignoreFailure $ nix "flake" "update" "--commit-lock-file" "--commit-lockfile-summary" + changed <- LBS.null <$> (git "branch" "-r" "--contains" "HEAD" |> captureTrim) + if changed + then git "push" "-f" "origin" "HEAD:flake-lock-update" + else say "No flake updates. Doing nothing." diff --git a/nixos/roles/laminar/test-config.hs b/nixos/roles/laminar/test-config.hs index cada5fa0..efdb1e40 100644 --- a/nixos/roles/laminar/test-config.hs +++ b/nixos/roles/laminar/test-config.hs @@ -38,8 +38,8 @@ main = do when (branch == "main") $ do say [i|Deploying new config to localhost.|] exe "/run/wrappers/bin/sudo" deployCommand - when (branch == "niv-bump") $ do - say [i|Merging branch niv-bump into main.|] + when (branch == "flake-lock-update") $ do + say [i|Merging branch flake-lock-update into main.|] git "checkout" "main" - git "merge" "origin/niv-bump" + git "merge" "origin/flake-lock-update" git "push"