diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml new file mode 100644 index 0000000..f41e303 --- /dev/null +++ b/.github/workflows/update.yml @@ -0,0 +1,32 @@ +name: Update +run-name: ${{github.actor}} is updating capkgs +on: + workflow_dispatch: + push: + branches: + - main + pull_request: +permissions: + contents: read + pull-requests: read +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true +jobs: + update: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Nix + uses: cachix/install-nix-action@v23 + with: + extra_nix_config: | + trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= + substituters = https://cache.iog.io https://cache.nixos.org/ + - run: echo "${{secrets.NIX_SIGNING_KEY}}" > hydra_key + - run: nix develop --ignore-environment --keep AWS_ACCESS_KEY_ID --keep AWS_SECRET_ACCESS_KEY --command just packages + env: + AWS_ACCESS_KEY_ID: "${{secrets.AWS_ACCESS_KEY_ID}}" + AWS_SECRET_ACCESS_KEY: "${{secrets.AWS_SECRET_ACCESS_KEY}}" + - run: nix develop --ignore-environment --command just check diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..58683eb --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/evals +/closures +/builds diff --git a/Justfile b/Justfile index ce82081..5a6725c 100644 --- a/Justfile +++ b/Justfile @@ -7,6 +7,7 @@ packages *ARGS: ./packages.rb \ --from "s3://devx?profile=r2&secret-key=hydra_key&endpoint=fc0e8a9d61fc1f44f378bdc5fdc0f638.r2.cloudflarestorage.com®ion=auto&compression=zstd" \ --to "s3://devx?profile=r2&secret-key=hydra_key&endpoint=fc0e8a9d61fc1f44f378bdc5fdc0f638.r2.cloudflarestorage.com®ion=auto&compression=zstd" \ + --gc \ --systems x86_64-linux {{ARGS}} # Attempt to build all packages from this flake diff --git a/flake.nix b/flake.nix index 297b93b..8b82375 100644 --- a/flake.nix +++ b/flake.nix @@ -29,7 +29,7 @@ # These inputs are purely used for the devShell and hydra to avoid any # evaluation and download of nixpkgs for just building a package. - inherit (flakes.nixpkgs.legacyPackages.${system}) mkShell nushell just ruby solargraph treefmt curl; + inherit (flakes.nixpkgs.legacyPackages.${system}) mkShell nushell just ruby solargraph treefmt curl gitMinimal; # At least 2.17 is required for this fix: https://github.com/NixOS/nix/pull/4282 inherit (flakes.nix.packages.${system}) nix; @@ -49,6 +49,7 @@ nix treefmt curl + gitMinimal ]; }; } diff --git a/packages.rb b/packages.rb index da9b955..b45244b 100755 --- a/packages.rb +++ b/packages.rb @@ -6,7 +6,7 @@ require 'optparse' require 'fileutils' -OPTIONS = {systems: "x86-64_linux"} +OPTIONS = {systems: "x86-64_linux", gc: false} op = OptionParser.new do |parser| parser.banner = "Usage: capkgs [options]" @@ -27,6 +27,10 @@ OPTIONS[:systems] = v end + parser.on '--gc', "garbage collect after every package" do |v| + OPTIONS[:gc] = true + end + parser.on '-h', '--help' do puts parser exit @@ -59,28 +63,6 @@ def to_json(options) end end -def process(pkg, flake_url, org, repo, tag, rev) - pkg.merge!('org' => org, 'repo' => repo, 'tag' => tag, 'rev' => rev) - - return if pkg['fail'] - - puts "Processing #{flake_url}" - - (merge(pkg) { process_eval(flake_url) }) && - (set(pkg, 'closure') { process_closure(flake_url) }) - - puts "Marked #{flake_url} as failed" if pkg['fail'] -end - -def nix_make_content_addressed(out_path) - content_addressed, status = - sh 'nix', 'store', 'make-content-addressed', out_path.fetch('outputs').fetch('out'), - '--json', - '--from', OPTIONS.fetch(:from), - '--to', OPTIONS.fetch(:to) - content_addressed if status.success? -end - def fetch_git_branches(org_name, repo_name, branches, dest) url = "https://github.com/#{org_name}/#{repo_name}" @@ -280,6 +262,7 @@ def process(path, cmd) pkg.nix_eval && pkg.nix_build && pkg.nix_store_make_content_addressed + sh('nix-collect-garbage') if OPTIONS[:gc] valid[pkg.flake_url] = pkg.to_h if pkg.closure.any? end