Better nom integration and more remote building
This commit is contained in:
parent
51155a70be
commit
698deb0613
|
@ -15,10 +15,10 @@ in {
|
|||
maintenance = pkgs.writeShellScriptBin "maintenance" ''
|
||||
set -e
|
||||
${configGit} pull --ff-only
|
||||
${configGit} submodule update
|
||||
echo "Running update-modes …"
|
||||
${updateModes}/bin/update-modes
|
||||
echo "Updating system …"
|
||||
${pkgs.nix-output-monitor}/bin/nom build --builders @$(builders-configurator) $(readlink -f /etc/nixos)#nixosConfigurations.$(hostname).config.system.build.toplevel --allow-import-from-derivation
|
||||
/run/wrappers/bin/sudo -A /run/current-system/sw/bin/nixos-rebuild switch
|
||||
echo "Maintenance finished."
|
||||
'';
|
||||
|
@ -38,18 +38,19 @@ in {
|
|||
pkgs.writeHaskellScript
|
||||
{
|
||||
name = "update-modes";
|
||||
bins = [activateMode pkgs.git pkgs.nix-output-monitor];
|
||||
bins = [activateMode pkgs.git pkgs.nix-output-monitor pkgs.builders-configurator];
|
||||
} ''
|
||||
main = do
|
||||
say "Building ~/.modes for ${hostName}"
|
||||
nom ["build", "/home/maralorn/git/config#homeModes.${hostName}", "-o", "${modeDir}"]
|
||||
builders <- builders_configurator |> captureTrim
|
||||
nom ["build", "--builders", [i|@#{builders}|], "/home/maralorn/git/config#homeModes.${hostName}", "-o", "${modeDir}", "--allow-import-from-derivation"]
|
||||
activate_mode
|
||||
'';
|
||||
quickUpdateMode =
|
||||
pkgs.writeHaskellScript
|
||||
{
|
||||
name = "quick-update-mode";
|
||||
bins = [updateModes pkgs.git pkgs.home-manager pkgs.nix-output-monitor];
|
||||
bins = [updateModes pkgs.git pkgs.home-manager pkgs.nix-output-monitor pkgs.builders-configurator];
|
||||
} ''
|
||||
getMode :: IO Text
|
||||
getMode = decodeUtf8 <$> (cat "${modeFile}" |> captureTrim)
|
||||
|
@ -57,7 +58,8 @@ in {
|
|||
main = do
|
||||
mode <- getMode
|
||||
say [i|Quick switching to mode #{mode} ...|]
|
||||
path :: Text <- decodeUtf8 <$> (nix ["build", "--print-out-paths", [i|/home/maralorn/git/config\#homeConfigurations.${hostName}-#{mode}.activationPackage|]] |> captureTrim)
|
||||
builders <- builders_configurator |> captureTrim
|
||||
path :: Text <- decodeUtf8 <$> (nom ["build", "--builders", [i|@#{builders}|], "--allow-import-from-derivation", "--print-out-paths", "--no-link", [i|/home/maralorn/git/config\#homeConfigurations.${hostName}-#{mode}.activationPackage|]] |> captureTrim)
|
||||
exe ([i|#{path}/activate|] :: String)
|
||||
update_modes
|
||||
'';
|
||||
|
|
|
@ -33,10 +33,11 @@ function title {
|
|||
setopt prompt_subst
|
||||
autoload -U colors && colors # Enable colors in prompt
|
||||
|
||||
alias nom-build-remote='nom build --builders $(builders-configurator)'
|
||||
alias nix-build-remote='nix build --builders $(builders-configurator)'
|
||||
alias nixpkgs-review-pr-remote='nixpkgs-review pr --build-args "--builders $(builders-configurator)'
|
||||
alias nixpkgs-review-rev-remote='nixpkgs-review rev --build-args "--builders $(builders-configurator)'
|
||||
alias nom-build-remote='nom build --builders @$(builders-configurator --force)'
|
||||
alias nix-build-remote='nix build --builders @$(builders-configurator --force)'
|
||||
alias update-system='nom build --builders @$(builders-configurator)'" $(readlink -f /etc/nixos)#nixosConfigurations.$(hostname).config.system.build.toplevel && sudo -A nixos-rebuild switch"
|
||||
alias nixpkgs-review-pr-remote='nixpkgs-review pr --build-args "--builders @$(builders-configurator --force)"'
|
||||
alias nixpkgs-review-rev-remote='nixpkgs-review rev --build-args "--builders @$(builders-configurator --force)"'
|
||||
alias accounting='f() { if [[ "$1" == "" ]]; then year="buchhaltung" else year="$1" fi; hledger -f ~/git/buchhaltung/$year.journal ui -- --watch --theme=terminal -X€ -t -E}; f'
|
||||
alias o=xdg-open
|
||||
alias sudo='sudo -A'
|
||||
|
|
|
@ -95,14 +95,15 @@ main :: IO ()
|
|||
main = do
|
||||
args <- getArgs
|
||||
env_host <- readFileBS "/etc/hostname" `Exception.catch` \(e :: Exception.IOException) -> pure (error (show e))
|
||||
let (host, withoutConnection) = case args of
|
||||
[] -> (Text.strip (decodeUtf8 env_host), False)
|
||||
[host'] -> (into host', False)
|
||||
[host', "--without-connection"] -> (into host', True)
|
||||
let (host, withoutConnection, allow_empty) = case args of
|
||||
[] -> (Text.strip (decodeUtf8 env_host), False, True)
|
||||
[host'] -> (into host', False, True)
|
||||
[host', "--force"] -> (into host', False, False)
|
||||
[host', "--without-connection"] -> (into host', True, False)
|
||||
_ -> error [i|Unknown arguments: #{args}|]
|
||||
builder_tries :: Ping :> es => Eff es [Text]
|
||||
builder_tries = testBuilders $ fromMaybe (error [i|#{host} not found in builderConfigs.|]) $ Map.lookup (into host) builderConfigs
|
||||
builders <- Eff.runEff $ (if withoutConnection then runWithoutConnectivity else runWithPing) builder_tries
|
||||
builders <- if allow_empty && host == "zeus" then pure [] else Eff.runEff $ (if withoutConnection then runWithoutConnectivity else runWithPing) builder_tries
|
||||
(path, handle) <- IO.openTempFile "/tmp" "machines"
|
||||
TextIO.hPutStr handle (printBuilders builders)
|
||||
IO.hClose handle
|
||||
|
|
Loading…
Reference in a new issue