From 3ebcbacfc5d139f3783dbcff9114b6d7c4a0f562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Mon, 16 Oct 2023 01:46:36 +0200 Subject: [PATCH] packages: cleanup --- packages.nix | 55 ++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/packages.nix b/packages.nix index 49c01558..8cdb3fe8 100644 --- a/packages.nix +++ b/packages.nix @@ -22,25 +22,23 @@ lib.attrsets.mapAttrs in overlayPkgs // { - host-registry = pkgs.runCommand "host-registry" - { - src = builtins.toFile "host-registry.nix" ( - lib.generators.toPretty { } hostRegistry - ); - } - '' - ln -s $src $out - ''; + host-registry = pkgs.runCommand "host-registry" { + src = builtins.toFile "host-registry.nix" ( + lib.generators.toPretty { } hostRegistry + ); + } '' + ln -s $src $out + ''; list-upgradable = pkgs.writeScriptBin "list-upgradable" '' - #! ${pkgs.runtimeShell} + set -eou pipefail NORMAL="\033[0m" RED="\033[0;31m" YELLOW="\033[0;33m" GREEN="\033[0;32m" - ${pkgs.lib.concatMapStringsSep "\n" (name: + ${lib.concatMapStringsSep "\n" (name: let addr = getHostAddr name; in lib.optionalString (addr != null) '' @@ -69,25 +67,23 @@ lib.attrsets.mapAttrs '') (builtins.attrNames self.nixosConfigurations)} ''; - prebuild-all = pkgs.runCommand "prebuild-all" - { - preferLocalBuild = true; - } - '' - mkdir $out + prebuild-all = pkgs.runCommand "prebuild-all" { + preferLocalBuild = true; + } '' + mkdir $out - ${pkgs.lib.concatMapStrings (name: '' - ln -s ${self.nixosConfigurations."${name}".config.system.build.toplevel} name - '') (builtins.attrNames self.nixosConfigurations)} - ''; + ${pkgs.lib.concatMapStrings (name: '' + ln -s ${self.nixosConfigurations."${name}".config.system.build.toplevel} name + '') (builtins.attrNames self.nixosConfigurations)} + ''; prebuild-all-remote = pkgs.writeScriptBin "prebuild-all" '' - #!${pkgs.runtimeShell} -e + set -eou pipefail nix copy --no-check-sigs --to ssh-ng://$1 ${inputPaths} ssh $1 -- nix build -L --no-link ${ - pkgs.lib.concatMapStringsSep " " (name: + lib.concatMapStringsSep " " (name: "${self}#nixosConfigurations.${name}.config.system.build.toplevel" ) (builtins.attrNames self.nixosConfigurations) } @@ -110,7 +106,7 @@ lib.attrsets.mapAttrs # remote machine and bulding and switching there. # Can be run with `nix run c3d2#…-nixos-rebuild switch` "${name}-nixos-rebuild" = pkgs.writeScriptBin "${name}-nixos-rebuild" '' - #!${pkgs.runtimeShell} -e + set -eou pipefail if nix eval .#nixosConfigurations.${name}.config.c3d2.deployment.server &>/dev/null; then echo "microvms cannot be updated with nixos-rebuild. Use nix run .#microvm-update-${name}" @@ -126,9 +122,11 @@ lib.attrsets.mapAttrs ''; "${name}-nixos-rebuild-hydra" = pkgs.writeScriptBin "${name}-nixos-rebuild" '' - #!${pkgs.runtimeShell} -e + set -eou pipefail + echo Copying Flakes nix copy --no-check-sigs --to ssh-ng://root@hydra.serv.zentralwerk.org ${inputPaths} + echo Building on Hydra ssh root@hydra.serv.zentralwerk.org -- \ nix build -L -o /tmp/nixos-system-${name} \ @@ -136,12 +134,14 @@ lib.attrsets.mapAttrs echo Built. Obtaining link to data TOPLEVEL=$(ssh root@hydra.serv.zentralwerk.org \ readlink /tmp/nixos-system-${name}) + echo Checking target ${name} ssh ${target} -- bash -e <