Compare commits

..

13 commits

Author SHA1 Message Date
dependabot[bot]
76961c1ee8
Bump DeterminateSystems/nix-installer-action from 15 to 16
Bumps [DeterminateSystems/nix-installer-action](https://github.com/determinatesystems/nix-installer-action) from 15 to 16.
- [Release notes](https://github.com/determinatesystems/nix-installer-action/releases)
- [Commits](https://github.com/determinatesystems/nix-installer-action/compare/v15...v16)

---
updated-dependencies:
- dependency-name: DeterminateSystems/nix-installer-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-18 18:48:32 +00:00
fd02d7a3e3
try cleaning 2024-11-18 12:47:10 -06:00
774f35bfec
workaround determinate installer 2024-11-18 12:20:29 -06:00
734c5b0f8f
+x 2024-11-18 12:15:33 -06:00
ec0c58792d
add bash 2024-11-18 12:14:43 -06:00
daeb99d4e9
add token to action 2024-11-18 12:11:04 -06:00
6a76620437
generalized nix ci action 2024-11-18 12:07:29 -06:00
95123022bb
fix overlay 2024-11-18 11:50:38 -06:00
4e30ceffb9
increase ci timeout 2024-11-18 11:39:58 -06:00
afa347e80e
fix build 2024-11-18 11:39:52 -06:00
e49988ab35
overlay style fix 2024-11-18 11:34:27 -06:00
9352e82219
modernize build ci 2024-11-18 11:34:15 -06:00
b851d4ae01
get crazy and use nixpkgs 2024-11-18 11:14:23 -06:00
8 changed files with 214 additions and 45 deletions

88
.github/actions/nix/action.yml vendored Normal file
View file

@ -0,0 +1,88 @@
# adapted from https://github.com/azuwis/actions/tree/7236424fa0fdc8d82df7cd4bff831a9d2338ce9e/nix
name: Install Nix and setup cache
inputs:
nix_conf:
description: Extra nix.conf config
default: |
accept-flake-config = true
build-dir = /nix/var
experimental-features = pipe-operator
keep-derivations = true
keep-outputs = true
# key:
# description: Key to actions/cache
# default: nix
# install_action:
# description: Set `nixbuild` to use nixbuild/nix-quick-install-action, otherwide use cachix/install-nix-action
# default: nixbuild
# use_nixpkgs_in_flake:
# description: Use nixpkgs defined in flake.nix
# default: true
# nixpkgs_url:
# description: Nixpkgs URL
# default: https://nixos.org/channels/nixos-24.05
clean:
description: Clean up disk space
default: false
btrfs:
description: Use BTRFS to setup RAID0
default: false
attic_token:
description: token to access attic cache
# debug:
# description: Enable debug
# default: false
# debug_token:
# default: ${{ github.token }}
# description: Set github token for gh cli
runs:
using: composite
steps:
- shell: bash
env:
CLEAN: ${{ inputs.clean }}
BTRFS: ${{ inputs.btrfs }}
run: exec ${{ github.action_path }}/prepare.sh
- uses: DeterminateSystems/nix-installer-action@v15
with:
source-url: https://install.lix.systems/lix/lix-installer-x86_64-linux
extra-conf: ${{ inputs.nix_conf }}
- name: Install and login to attic cache
shell: bash
run: |
nix profile install "nixpkgs#attic-client"
attic login oizys https://attic.dayl.in "${{ inputs.attic_token}}"
# - name: Nix restore pre
# shell: bash
# env:
# CACHE_KEY: ${{ inputs.key }}
# run: exec ${{ github.action_path }}/restore.sh pre
# - uses: actions/cache/restore@v4
# with:
# key: ${{ env.CACHE_KEY }}-${{ runner.os }}-${{ runner.arch }}-${{ env.CACHE_TIMESTAMP }}
# restore-keys: |
# ${{ env.CACHE_KEY }}-${{ runner.os }}-${{ runner.arch }}
# path: |
# /nix/store
# /nix/var/nix/db
# /nix/var/nix/gcroots
# /nix/var/nix/profiles
# ~/.cache/nix
# ~/.local/state/nix
# ~/.nix-channels
# ~/.nix-defexpr
# - name: Nix restore post
# shell: bash
# env:
# USE_NIXPKGS_IN_FLAKE: ${{ inputs.use_nixpkgs_in_flake }}
# NIXPKGS_URL: ${{ inputs.nixpkgs_url }}
# run: exec ${{ github.action_path }}/restore.sh post
# - name: Debug
# if: ${{ inputs.debug == true || inputs.debug == 'true' || inputs.debug == 'nopause' }}
# shell: bash
# env:
# GH_TOKEN: ${{ inputs.debug_token }}
# run: exec ${{ github.action_path }}/debug.sh "${{ inputs.debug }}"

83
.github/actions/nix/prepare.sh vendored Executable file
View file

@ -0,0 +1,83 @@
#!/usr/bin/env bash
case "$RUNNER_OS" in
Linux)
if [ "$CLEAN" = true ]; then
echo "Disk clean, before:"
df -h -x tmpfs
sudo rm -rf \
/etc/skel/.cargo \
/etc/skel/.dotnet \
/etc/skel/.rustup \
/home/runner/.cargo \
/home/runner/.dotnet \
/home/runner/.rustup \
/home/runneradmin/.cargo \
/home/runneradmin/.dotnet \
/home/runneradmin/.rustup \
/opt/az \
/opt/google \
/opt/hostedtoolcache \
/opt/microsoft \
/opt/pipx \
/root/.sbt \
/usr/lib/google-cloud-sdk \
/usr/lib/jvm \
/usr/local \
/usr/share/az_* \
/usr/share/dotnet \
/usr/share/miniconda \
/usr/share/swift
docker image prune --all --force >/dev/null
echo
echo "After:"
df -h -x tmpfs
echo
fi
if [ "$BTRFS" = true ]; then
echo "Make /nix BTRFS RAID0 from /btrfs and /mnt/btrfs"
sudo touch /btrfs /mnt/btrfs
sudo chmod 600 /btrfs /mnt/btrfs
sudo fallocate --zero-range --length "$(($(df --block-size=1 --output=avail / | sed -n 2p) - 2147483648))" /btrfs
sudo fallocate --zero-range --length "$(df --block-size=1 --output=avail /mnt | sed -n 2p)" /mnt/btrfs
sudo losetup /dev/loop6 /btrfs
sudo losetup /dev/loop7 /mnt/btrfs
sudo mkfs.btrfs --data raid0 /dev/loop6 /dev/loop7
sudo mkdir /nix
sudo mount -t btrfs -o compress=zstd /dev/loop6 /nix
sudo chown "${RUNNER_USER}:" /nix
elif [ "$(findmnt -bno size /mnt)" -gt 20000000000 ]; then
df -h -x tmpfs
echo "/mnt is large, bind mount /mnt/nix"
# sudo install -d -o "$RUNNER_USER" /mnt/nix /nix
# issue with determinate installer?
sudo install -d /mnt/nix /nix
sudo mount --bind /mnt/nix /nix
fi
;;
macOS)
if [ "$CLEAN" = true ]; then
echo "Disk clean, before:"
df -h /
sudo rm -rf \
/Applications/Xcode_* \
/Library/Developer/CoreSimulator \
/Library/Frameworks \
/Users/runner/.dotnet \
/Users/runner/.rustup \
/Users/runner/Library/Android \
/Users/runner/Library/Caches \
/Users/runner/Library/Developer/CoreSimulator \
/Users/runner/hostedtoolcache
echo
echo "After:"
df -h /
fi
# This save about 110G disk space, and take about 0.6s
sudo rm -rf \
/Library/Developer/CoreSimulator \
/Users/runner/Library/Developer/CoreSimulator
# Disable MDS service on macOS
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist || true
;;
esac

View file

@ -1,12 +1,14 @@
name: Build NixOS (on demand)
# TODO: accept , style sep in hwylcli
on:
workflow_dispatch:
inputs:
hosts:
description: 'list of hosts to build'
required: true
default: ',othalan,algiz'
default: 'othalan'
# default: ',othalan,algiz'
type: string
lockFile:
description: 'flake.lock file'
@ -16,7 +18,8 @@ on:
inputs:
hosts:
description: 'list of hosts to build'
default: ',othalan,algiz'
default: 'othalan'
# default: ',othalan,algiz'
type: string
# concurrency:
@ -37,28 +40,11 @@ jobs:
host: github.com
private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- uses: ./.github/actions/clean-disk
- uses: ./.github/actions/nix
with:
purge-packages: 'true'
- uses: DeterminateSystems/nix-installer-action@v16
with:
source-url: https://install.lix.systems/lix/lix-installer-x86_64-linux
extra-conf: |
experimental-features = pipe-operator
accept-flake-config = true
- uses: DeterminateSystems/magic-nix-cache-action@v8
# - name: Install and login to attic cache
# run: |
# nix profile install "nixpkgs#attic-client"
# attic login oizys https://attic.dayl.in "${{ secrets.ATTIC_TOKEN }}"
# - uses: cachix/cachix-action@v15
# with:
# name: daylin
# authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
attic_token: ${{ secrets.ATTIC_TOKEN }}
clean: true
btrfs: true
- name: write lock file
if: "${{ inputs.lockFile != '' }}"
@ -70,13 +56,12 @@ jobs:
run: nix build . --print-build-logs
- name: Build
run: |
nix run . \
-- \
build --minimal \
--host,="${{ inputs.hosts }}" \
--flake . \
--debug \
-- \
--keep-going \
--print-build-logs
run: >
nix run .
--
cache
--host "${{ inputs.hosts }}"
--flake .
--debug
--
--keep-going

View file

@ -69,8 +69,8 @@ jobs:
--host "othalan"
--flake .
--debug
--
--print-build-logs
# --
# --print-build-logs
- name: Commit Updates
uses: daylin-bot/actions/commit-and-push@main
@ -126,10 +126,9 @@ jobs:
--debug
--
--keep-going
--print-build-logs
# --print-build-logs
--out-link current
- run: git checkout flake-lock
- name: Pre-build oizys
@ -145,7 +144,7 @@ jobs:
--debug
--
--keep-going
--print-build-logs
# --print-build-logs
--out-link updated
- run: |

View file

@ -792,16 +792,16 @@
},
"nixpkgs_4": {
"locked": {
"lastModified": 1731319897,
"narHash": "sha256-PbABj4tnbWFMfBp6OcUK5iGy1QY+/Z96ZcLpooIbuEI=",
"lastModified": 1731890469,
"narHash": "sha256-D1FNZ70NmQEwNxpSSdTXCSklBH1z2isPR84J6DQrJGs=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "dc460ec76cbff0e66e269457d7b728432263166c",
"rev": "5083ec887760adfe12af64830a66807423a859a7",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}

View file

@ -4,7 +4,7 @@
outputs = inputs: (import ./lib inputs).oizysFlake;
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
stable.url = "github:nixos/nixpkgs/nixos-24.05";
my-nixpkgs.url = "github:daylinmorgan/nixpkgs/nixos-unstable";

View file

@ -2,10 +2,19 @@
(loadOverlays inputs ./.)
++ [
inputs.nim2nix.overlays.default # adds buildNimPackage
(final: _prev: {
(final: prev: {
stable = import inputs.stable {
system = final.system;
config.allowUnfree = true;
};
# nixd + lix = problem, or am I just pulling in nix2.24 now?
nixt = prev.nixt.override {
nix = final.nixVersions.nix_2_24;
};
nixd = prev.nixd.override {
nix = final.nixVersions.nix_2_24;
};
})
]

View file

@ -4,6 +4,7 @@ import ./[exec, context]
# localPassC is used by zippy but the additional
# module mangling on nixos somehow breaks localPassC
# https://github.com/NixOS/nixpkgs/issues/356524
when defined(amd64) and (defined(gcc) or defined(clang)):
{.passC: "-msse4.1 -mpclmul".}
@ -79,7 +80,11 @@ proc postGhApi(url: string, body: JsonNode) =
except:
errorQuit "failed to get response code"
proc getInProgressRun(workflow: string, timeout: int = 5000): (GhWorkflowRun, bool) =
proc getInProgressRun(
workflow: string,
timeout: int = 10000
): (GhWorkflowRun, bool) =
## wait up to 10 seconds to try to fetch ongoing run url
let
start = now()
timeoutDuration = initDuration(milliseconds = timeout)