From 34a41a64ba7dc419af61a4daaec89cd8e70445c0 Mon Sep 17 00:00:00 2001 From: arcnmx Date: Wed, 19 May 2021 08:13:45 -0700 Subject: [PATCH] use ci channels --- ci/hosts.nix | 7 +++---- ci/niv-cron.nix | 24 +++++++++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/ci/hosts.nix b/ci/hosts.nix index 829d0ddf..e197458e 100644 --- a/ci/hosts.nix +++ b/ci/hosts.nix @@ -1,13 +1,12 @@ -{ lib, channels, env, ... }: with lib; let - nixfiles = import ../.; -in { +{ lib, channels, env, ... }: with lib; { name = "hosts"; ci.gh-actions.enable = true; ci.gh-actions.export = true; + channels.nixfiles.path = ../.; jobs = let hostnames = [ "samhain" "yule" "athame" ]; in mapAttrs' (k: nameValuePair "host-${k}") (genAttrs hostnames (host: { - tasks.${host}.inputs = nixfiles.hosts.${host}.config.system.build.toplevel; + tasks.${host}.inputs = channels.nixfiles.hosts.${host}.config.system.build.toplevel; })); ci.gh-actions.checkoutOptions.submodules = false; diff --git a/ci/niv-cron.nix b/ci/niv-cron.nix index 888d2ba1..4ec832f4 100644 --- a/ci/niv-cron.nix +++ b/ci/niv-cron.nix @@ -23,26 +23,36 @@ with lib; { }; }; + channels = { + nixfiles.path = ../.; + nixpkgs.path = "${channels.nixfiles.sources.nixpkgs}"; + }; + + environment.test = { + inherit (channels.cipkgs) cachix; + inherit (channels.nixpkgs) niv; + }; + jobs.niv-update = { tasks.niv-build.inputs = with channels.cipkgs; ci.command { name = "niv-update-build"; displayName = "niv update build"; - nativeBuildInputs = [ nix cachix ]; environment = [ "OPENSSH_PRIVATE_KEY" "CACHIX_SIGNING_KEY" ]; - command = let sources = (import ../.).sources; in - '' + command = '' mkdir ~/.ssh echo "$OPENSSH_PRIVATE_KEY" > ~/.ssh/id_rsa chmod 0600 ~/.ssh/id_rsa - for source in ${toString (attrNames sources)}; do - nix run -f . pkgs.niv -c niv update $source || true + + for source in ${toString (attrNames channels.nixfiles.sources)}; do + niv update $source || true done + if git status --porcelain | grep -qF nix/sources.json; then if nix build -Lf . hosts.{athame,yule,samhain}.config.system.build.toplevel; then nix build -f ../. sourceCache - ${cachix}/bin/cachix push kittywitch $(nix eval '(toString (import ../.).sourceCache)') - nix-build $(echo "-A hosts."{athame,yule,samhain}.config.system.build.toplevel) | ${cachix}/bin/cachix push kittywitch + cachix push kittywitch $(nix eval '(toString (import ../.).sourceCache)') + nix-build $(echo "-A hosts."{athame,yule,samhain}.config.system.build.toplevel) | cachix push kittywitch git add nix/sources.json export GIT_{COMMITTER,AUTHOR}_EMAIL=kat@kittywit.ch export GIT_{COMMITTER,AUTHOR}_NAME=kat witch