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" ''
|
maintenance = pkgs.writeShellScriptBin "maintenance" ''
|
||||||
set -e
|
set -e
|
||||||
${configGit} pull --ff-only
|
${configGit} pull --ff-only
|
||||||
${configGit} submodule update
|
|
||||||
echo "Running update-modes …"
|
echo "Running update-modes …"
|
||||||
${updateModes}/bin/update-modes
|
${updateModes}/bin/update-modes
|
||||||
echo "Updating system …"
|
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
|
/run/wrappers/bin/sudo -A /run/current-system/sw/bin/nixos-rebuild switch
|
||||||
echo "Maintenance finished."
|
echo "Maintenance finished."
|
||||||
'';
|
'';
|
||||||
|
@ -38,18 +38,19 @@ in {
|
||||||
pkgs.writeHaskellScript
|
pkgs.writeHaskellScript
|
||||||
{
|
{
|
||||||
name = "update-modes";
|
name = "update-modes";
|
||||||
bins = [activateMode pkgs.git pkgs.nix-output-monitor];
|
bins = [activateMode pkgs.git pkgs.nix-output-monitor pkgs.builders-configurator];
|
||||||
} ''
|
} ''
|
||||||
main = do
|
main = do
|
||||||
say "Building ~/.modes for ${hostName}"
|
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
|
activate_mode
|
||||||
'';
|
'';
|
||||||
quickUpdateMode =
|
quickUpdateMode =
|
||||||
pkgs.writeHaskellScript
|
pkgs.writeHaskellScript
|
||||||
{
|
{
|
||||||
name = "quick-update-mode";
|
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 :: IO Text
|
||||||
getMode = decodeUtf8 <$> (cat "${modeFile}" |> captureTrim)
|
getMode = decodeUtf8 <$> (cat "${modeFile}" |> captureTrim)
|
||||||
|
@ -57,7 +58,8 @@ in {
|
||||||
main = do
|
main = do
|
||||||
mode <- getMode
|
mode <- getMode
|
||||||
say [i|Quick switching to mode #{mode} ...|]
|
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)
|
exe ([i|#{path}/activate|] :: String)
|
||||||
update_modes
|
update_modes
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -33,10 +33,11 @@ function title {
|
||||||
setopt prompt_subst
|
setopt prompt_subst
|
||||||
autoload -U colors && colors # Enable colors in prompt
|
autoload -U colors && colors # Enable colors in prompt
|
||||||
|
|
||||||
alias nom-build-remote='nom build --builders $(builders-configurator)'
|
alias nom-build-remote='nom build --builders @$(builders-configurator --force)'
|
||||||
alias nix-build-remote='nix build --builders $(builders-configurator)'
|
alias nix-build-remote='nix build --builders @$(builders-configurator --force)'
|
||||||
alias nixpkgs-review-pr-remote='nixpkgs-review pr --build-args "--builders $(builders-configurator)'
|
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-rev-remote='nixpkgs-review rev --build-args "--builders $(builders-configurator)'
|
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 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 o=xdg-open
|
||||||
alias sudo='sudo -A'
|
alias sudo='sudo -A'
|
||||||
|
|
|
@ -95,14 +95,15 @@ main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
args <- getArgs
|
args <- getArgs
|
||||||
env_host <- readFileBS "/etc/hostname" `Exception.catch` \(e :: Exception.IOException) -> pure (error (show e))
|
env_host <- readFileBS "/etc/hostname" `Exception.catch` \(e :: Exception.IOException) -> pure (error (show e))
|
||||||
let (host, withoutConnection) = case args of
|
let (host, withoutConnection, allow_empty) = case args of
|
||||||
[] -> (Text.strip (decodeUtf8 env_host), False)
|
[] -> (Text.strip (decodeUtf8 env_host), False, True)
|
||||||
[host'] -> (into host', False)
|
[host'] -> (into host', False, True)
|
||||||
[host', "--without-connection"] -> (into host', True)
|
[host', "--force"] -> (into host', False, False)
|
||||||
|
[host', "--without-connection"] -> (into host', True, False)
|
||||||
_ -> error [i|Unknown arguments: #{args}|]
|
_ -> error [i|Unknown arguments: #{args}|]
|
||||||
builder_tries :: Ping :> es => Eff es [Text]
|
builder_tries :: Ping :> es => Eff es [Text]
|
||||||
builder_tries = testBuilders $ fromMaybe (error [i|#{host} not found in builderConfigs.|]) $ Map.lookup (into host) builderConfigs
|
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"
|
(path, handle) <- IO.openTempFile "/tmp" "machines"
|
||||||
TextIO.hPutStr handle (printBuilders builders)
|
TextIO.hPutStr handle (printBuilders builders)
|
||||||
IO.hClose handle
|
IO.hClose handle
|
||||||
|
|
Loading…
Reference in a new issue