From d8972aae6cd9eb67c8f8f36b6a9faa271142982f Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Wed, 24 Jan 2024 13:33:48 -0600 Subject: [PATCH] styx will do the heavy lifting --- .github/workflows/build.yml | 17 ++++++----------- modules/styx/styx | 30 ++++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4b15255..13eb41a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,7 +38,7 @@ jobs: https://hyprland.cachix.org https://nixpkgs-wayland.cachix.org https://daylin.cachix.org - cache.nixos.org + https://cache.nixos.org - uses: DeterminateSystems/magic-nix-cache-action@v2 - uses: cachix/cachix-action@v14 @@ -48,16 +48,11 @@ jobs: - name: Build shell: bash run: | - # for host in algiz othalan mannaz for host in ${HOSTS[@]} do - cachix watch-exec daylin \ - -- \ - nix build \ - ".#nixosConfigurations.$host.config.system.build.toplevel" \ - --print-build-logs + ./modules/styx/styx cache --host $host --flake . done - - name: Push - env: - CACHIX_ACTIVATE_TOKEN: "${{ secrets.CACHIX_ACTIVATE_TOKEN }}" - run: cachix push daylin ./result + # - name: Push + # env: + # CACHIX_ACTIVATE_TOKEN: "${{ secrets.CACHIX_ACTIVATE_TOKEN }}" + # run: cachix push daylin ./result diff --git a/modules/styx/styx b/modules/styx/styx index 9e95771..849fcb8 100755 --- a/modules/styx/styx +++ b/modules/styx/styx @@ -4,7 +4,8 @@ set -e # rewrite as python script? -FLAKE_PATH=$HOME/nixcfg +HOSTNAME=${HOSTNAME:-$(hostname)} +FLAKE_PATH=${FLAKE_PATH-:$HOME/nixcfg} DIM="$(tput dim)" BOLD="$(tput bold)" @@ -69,6 +70,14 @@ dry() { nix build "$FLAKE_PATH#nixosConfigurations.$(hostname).config.system.build.toplevel" --dry-run } +cache() { + cachix watch-exec daylin \ + -- \ + nix build "$FLAKE_PATH#nixosConfigurations.${HOSTNAME}.config.system.build.toplevel" \ + --print-build-logs +} + + if [[ $# -eq 0 ]]; then log no command specified see below for help help @@ -76,17 +85,20 @@ fi while [[ $# -gt 0 ]]; do case $1 in - fmt | boot | switch | store | build | dry) + fmt | boot | switch | store | build | dry | cache) cmd=$1 shift ;; - -h | --help) - help + -f | --flake) + FLAKE_PATH="$2" + shift; shift; ;; - --) - # stop parsing and foward the rest of the args - shift - break + -h | --host) + HOSTNAME="$2" + shift; shift; + ;; + --help) + help ;; -*,--*) error "unknown flag: ${BOLD}$1${RESET}" @@ -103,4 +115,6 @@ if [[ $# -gt 0 ]]; then echo "forwarding args: ${BOLD}$*${RESET}" fi + + $cmd "$@"