diff --git a/nixos/roles/laminar/test-config.hs b/nixos/roles/laminar/test-config.hs index 2c42693f..63f6b67f 100644 --- a/nixos/roles/laminar/test-config.hs +++ b/nixos/roles/laminar/test-config.hs @@ -9,50 +9,31 @@ {-# LANGUAGE TupleSections #-} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE NoImplicitPrelude #-} -{-# OPTIONS_GHC -Wall -Werror -Wno-missing-signatures -Wno-type-defaults -Wno-orphans #-} +{-# OPTIONS_GHC -Wall -Werror -Wno-missing-signatures -Wno-type-defaults #-} -import Control.Concurrent.Async import Data.String.Interpolate import Data.Text (stripPrefix) import Language.Haskell.TH.Syntax import Relude import Say import Shh -import System.Environment (getEnv, setEnv) +import System.Environment (getEnv) load Absolute ["laminarc", "git", "nix"] repo = "git@hera.m-0.eu:nixos-config" -jobs :: [String] -jobs = - $$( bindCode - ( runIO $ do - homes <- getEnv "HOMES" - systems <- getEnv "SYSTEMS" - let ret = - ((\x -> [i|system-config-#{x}|]) <$> (words . toText) systems) - <> ((\x -> [i|home-config-#{x}|]) <$> (words . toText) homes) - say [i|Found jobs #{ret}|] - pure ret - ) - liftTyped - ) - deployCommand :: String deployCommand = $$(bindCode (runIO $ getEnv "DEPLOY") liftTyped) main = do let process = fromMaybe "main" . (stripPrefix "refs/heads/" . toText =<<) branch <- process <$> lookupEnv "BRANCH" - jobId <- getEnv "JOB" - runId <- getEnv "RUN" git "clone" repo "." git "checkout" (toString branch) - setEnv "LAMINAR_REASON" [i|Building config branch #{branch} for all systems in #{jobId}:#{runId}|] - say [i|Starting builds of branch #{branch} for all systems.|] - concurrently_ (mapConcurrently_ (\x -> laminarc ["run", x, [i|BRANCH=#{branch}|]]) jobs) $ nix "flake" "check" - say [i|Builds succeeded.|] + say "Running checks" + nix "flake" "check" + say "Checks succeeded" when (branch == "main") $ do say [i|Deploying new config to localhost.|] exe "/run/wrappers/bin/sudo" deployCommand diff --git a/nixos/roles/laminar/test-config.nix b/nixos/roles/laminar/test-config.nix index 2e7c12c8..cb90dd22 100644 --- a/nixos/roles/laminar/test-config.nix +++ b/nixos/roles/laminar/test-config.nix @@ -135,7 +135,7 @@ in { ]; systemd.services = { update-config = { - path = [pkgs.git pkgs.nix pkgs.openssh]; + path = [pkgs.git pkgs.nix pkgs.openssh pkgs.nixos-rebuild]; restartIfChanged = false; unitConfig.X-StopOnRemoval = false; serviceConfig = { @@ -146,8 +146,8 @@ in { in '' /run/wrappers/bin/sudo -u ${user} git -C /etc/nixos pull --ff-only /run/wrappers/bin/sudo -u ${user} git -C /etc/nixos submodule update --init - /var/cache/gc-links/system-config-hera/bin/switch-to-configuration switch - /run/wrappers/bin/sudo -u ${user} /var/cache/gc-links/home-config-hera/default/activate + nixos-rebuild switch + # /run/wrappers/bin/sudo -u ${user} /var/cache/gc-links/home-config-hera/default/activate ''; }; };