diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ed6d911..6c86115 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -10,7 +10,9 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: DeterminateSystems/nix-installer-action-cache@main + - uses: DeterminateSystems/flake-checker-action@v4 + + - uses: DeterminateSystems/nix-installer-action@v4 - name: Build package run: "nix build .# -L" @@ -19,8 +21,8 @@ jobs: uses: actions/upload-artifact@v3.1.2 with: # Artifact name - name: nix-actions-cache-X64-macOS - path: result/bin/nix-actions-cache + name: magic-nix-cache-X64-macOS + path: result/bin/magic-nix-cache retention-days: 1 build-artifacts-X64-Linux: @@ -28,7 +30,9 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: DeterminateSystems/nix-installer-action-cache@main + - uses: DeterminateSystems/flake-checker-action@v4 + + - uses: DeterminateSystems/nix-installer-action@v4 - name: Build package run: "nix build .# -L" @@ -37,6 +41,6 @@ jobs: uses: actions/upload-artifact@v3.1.2 with: # Artifact name - name: nix-actions-cache-X64-Linux - path: result/bin/nix-actions-cache + name: magic-nix-cache-X64-Linux + path: result/bin/magic-nix-cache retention-days: 1 diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml deleted file mode 100644 index 32989a8..0000000 --- a/.github/workflows/check.yaml +++ /dev/null @@ -1,16 +0,0 @@ -name: Run checks - -on: - pull_request: - push: - branches: [main] - -jobs: - checks: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - - name: Check health of flake.lock - uses: DeterminateSystems/flake-checker-action@v4 - with: - fail-mode: true diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index d05cfe4..7dc7fea 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -11,7 +11,13 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: DeterminateSystems/nix-installer-action-cache@main + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@v4 + + - name: Check health of flake.lock + uses: DeterminateSystems/flake-checker-action@v4 + with: + fail-mode: true - name: Check Rust formatting run: nix develop --command cargo fmt --check diff --git a/.github/workflows/keygen.yaml b/.github/workflows/keygen.yaml index 3073417..09f30a7 100644 --- a/.github/workflows/keygen.yaml +++ b/.github/workflows/keygen.yaml @@ -6,7 +6,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: DeterminateSystems/nix-installer-action-cache@main + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@main - name: Expose GitHub Runtime uses: crazy-max/ghaction-github-runtime@v2 - name: Dump credentials diff --git a/.github/workflows/release-branches.yml b/.github/workflows/release-branches.yml index 2c336bc..93557a6 100644 --- a/.github/workflows/release-branches.yml +++ b/.github/workflows/release-branches.yml @@ -33,17 +33,17 @@ jobs: - uses: actions/download-artifact@v3 with: - name: nix-actions-cache-X64-macOS + name: magic-nix-cache-X64-macOS path: cache-binary-X64-macOS - name: Persist the cache binary - run: cp ./cache-binary-X64-macOS/nix-actions-cache ./artifacts/nix-actions-cache-X64-macOS + run: cp ./cache-binary-X64-macOS/magic-nix-cache ./artifacts/magic-nix-cache-X64-macOS - uses: actions/download-artifact@v3 with: - name: nix-actions-cache-X64-Linux + name: magic-nix-cache-X64-Linux path: cache-binary-X64-Linux - name: Persist the cache binary - run: cp ./cache-binary-X64-Linux/nix-actions-cache ./artifacts/nix-actions-cache-X64-Linux + run: cp ./cache-binary-X64-Linux/magic-nix-cache ./artifacts/magic-nix-cache-X64-Linux - name: Publish Release (Branch) env: diff --git a/.github/workflows/release-prs.yml b/.github/workflows/release-prs.yml index f17205d..9b036ed 100644 --- a/.github/workflows/release-prs.yml +++ b/.github/workflows/release-prs.yml @@ -19,7 +19,7 @@ jobs: # Only intra-repo PRs are allowed to have PR artifacts uploaded # We only want to trigger once the upload once in the case the upload label is added, not when any label is added if: | - github.event.pull_request.head.repo.full_name == 'DeterminateSystems/nix-actions-cache' + github.event.pull_request.head.repo.full_name == 'DeterminateSystems/magic-nix-cache' && ( (github.event.action == 'labeled' && github.event.label.name == 'upload to s3') || (github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, 'upload to s3')) @@ -37,17 +37,17 @@ jobs: - uses: actions/download-artifact@v3 with: - name: nix-actions-cache-X64-macOS + name: magic-nix-cache-X64-macOS path: cache-binary-X64-macOS - name: Persist the cache binary - run: cp ./cache-binary-X64-macOS/nix-actions-cache ./artifacts/nix-actions-cache-X64-macOS + run: cp ./cache-binary-X64-macOS/magic-nix-cache ./artifacts/magic-nix-cache-X64-macOS - uses: actions/download-artifact@v3 with: - name: nix-actions-cache-X64-Linux + name: magic-nix-cache-X64-Linux path: cache-binary-X64-Linux - name: Persist the cache binary - run: cp ./cache-binary-X64-Linux/nix-actions-cache ./artifacts/nix-actions-cache-X64-Linux + run: cp ./cache-binary-X64-Linux/magic-nix-cache ./artifacts/magic-nix-cache-X64-Linux - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v2 diff --git a/.github/workflows/release-tags.yml b/.github/workflows/release-tags.yml index a9dbd24..3852ae4 100644 --- a/.github/workflows/release-tags.yml +++ b/.github/workflows/release-tags.yml @@ -26,17 +26,17 @@ jobs: - uses: actions/download-artifact@v3 with: - name: nix-actions-cache-X64-macOS + name: magic-nix-cache-X64-macOS path: cache-binary-X64-macOS - name: Persist the cache binary - run: cp ./cache-binary-X64-macOS/nix-actions-cache ./artifacts/nix-actions-cache-X64-macOS + run: cp ./cache-binary-X64-macOS/magic-nix-cache ./artifacts/magic-nix-cache-X64-macOS - uses: actions/download-artifact@v3 with: - name: nix-actions-cache-X64-Linux + name: magic-nix-cache-X64-Linux path: cache-binary-X64-Linux - name: Persist the cache binary - run: cp ./cache-binary-X64-Linux/nix-actions-cache ./artifacts/nix-actions-cache-X64-Linux + run: cp ./cache-binary-X64-Linux/magic-nix-cache ./artifacts/magic-nix-cache-X64-Linux - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v2 diff --git a/.github/workflows/upload_s3.sh b/.github/workflows/upload_s3.sh index 37358d0..5be1c0c 100755 --- a/.github/workflows/upload_s3.sh +++ b/.github/workflows/upload_s3.sh @@ -66,18 +66,18 @@ fi cat <<-EOF >> $GITHUB_STEP_SUMMARY -This commit's nix-actions-cache binaries can be fetched from: +This commit's magic-nix-cache binaries can be fetched from: Intel macOS: \`\`\` -curl --output nix-actions-cache --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix-actions-cache/rev/$GIT_ISH/X64-macOS +curl --output magic-nix-cache --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/magic-nix-cache/rev/$GIT_ISH/X64-macOS \`\`\` x86_64 Linux: \`\`\` -curl --output nix-actions-cache --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix-actions-cache/rev/$GIT_ISH/X64-Linux +curl --output magic-nix-cache --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/magic-nix-cache/rev/$GIT_ISH/X64-Linux \`\`\` Or generally from this ${TYPE}: @@ -85,12 +85,12 @@ Or generally from this ${TYPE}: Intel macOS: \`\`\` -curl --output nix-actions-cache --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix-actions-cache/${TYPE}/${TYPE_ID}/X64-macOS +curl --output magic-nix-cache --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/magic-nix-cache/${TYPE}/${TYPE_ID}/X64-macOS \`\`\` x86_64 Linux: \`\`\` -curl --output nix-actions-cache --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix-actions-cache/${TYPE}/${TYPE_ID}/X64-Linux +curl --output magic-nix-cache --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/magic-nix-cache/${TYPE}/${TYPE_ID}/X64-Linux \`\`\` EOF diff --git a/Cargo.lock b/Cargo.lock index 9e81085..e7026a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -645,6 +645,26 @@ dependencies = [ "linked-hash-map", ] +[[package]] +name = "magic-nix-cache" +version = "0.1.0" +dependencies = [ + "axum", + "axum-macros", + "clap", + "daemonize", + "gha-cache", + "serde", + "serde_json", + "thiserror", + "tokio", + "tokio-stream", + "tokio-util", + "tower-http", + "tracing", + "tracing-subscriber", +] + [[package]] name = "match_cfg" version = "0.1.0" @@ -696,26 +716,6 @@ dependencies = [ "windows-sys 0.45.0", ] -[[package]] -name = "nix-actions-cache" -version = "0.1.0" -dependencies = [ - "axum", - "axum-macros", - "clap", - "daemonize", - "gha-cache", - "serde", - "serde_json", - "thiserror", - "tokio", - "tokio-stream", - "tokio-util", - "tower-http", - "tracing", - "tracing-subscriber", -] - [[package]] name = "nu-ansi-term" version = "0.46.0" diff --git a/Cargo.toml b/Cargo.toml index 5f34918..6e655e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,7 @@ [workspace] - members = [ "gha-cache", - "nix-actions-cache", + "magic-nix-cache", ] [profile.release] diff --git a/README.md b/README.md index 033997a..4a7b305 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# nix-actions-cache +# The Magic Nix Cache -`nix-actions-cache` is a minimal Nix Binary Cache server backed by [the GitHub Actions Cache](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows). +`magic-nix-cache` is a minimal Nix Binary Cache server backed by [the GitHub Actions Cache](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows). It can be compiled into a ~3.5MB static binary for distribution, allowing it to start prefetching NARs used in a previous run even _before_ Nix is installed (not implemented yet). ## Development diff --git a/crane.nix b/crane.nix index d8c5cec..399f55f 100644 --- a/crane.nix +++ b/crane.nix @@ -78,7 +78,7 @@ let inherit (crossPlatform) pkgs; craneLib = (crane.mkLib pkgs).overrideToolchain rustNightly; crateName = craneLib.crateNameFromCargoToml { - cargoToml = ./nix-actions-cache/Cargo.toml; + cargoToml = ./magic-nix-cache/Cargo.toml; }; src = nix-gitignore.gitignoreSource [ ] ./.; @@ -112,5 +112,5 @@ in { inherit crossPlatforms cargoTargets cargoCrossEnvs rustNightly; - nix-actions-cache = buildFor system; + magic-nix-cache = buildFor system; } diff --git a/flake.nix b/flake.nix index d766efb..a2c3822 100644 --- a/flake.nix +++ b/flake.nix @@ -41,13 +41,13 @@ in { packages = forEachSupportedSystem ({ pkgs, cranePkgs, ... }: rec { - inherit (cranePkgs) nix-actions-cache; - default = nix-actions-cache; + inherit (cranePkgs) magic-nix-cache; + default = magic-nix-cache; }); devShells = forEachSupportedSystem ({ pkgs, cranePkgs, lib }: { default = pkgs.mkShell ({ - inputsFrom = [ cranePkgs.nix-actions-cache ]; + inputsFrom = [ cranePkgs.magic-nix-cache ]; packages = with pkgs; [ bashInteractive cranePkgs.rustNightly diff --git a/nix-actions-cache/Cargo.toml b/magic-nix-cache/Cargo.toml similarity index 88% rename from nix-actions-cache/Cargo.toml rename to magic-nix-cache/Cargo.toml index 3e19174..d472572 100644 --- a/nix-actions-cache/Cargo.toml +++ b/magic-nix-cache/Cargo.toml @@ -1,10 +1,8 @@ [package] -name = "nix-actions-cache" +name = "magic-nix-cache" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] gha-cache = { path = "../gha-cache" } diff --git a/nix-actions-cache/src/api.rs b/magic-nix-cache/src/api.rs similarity index 100% rename from nix-actions-cache/src/api.rs rename to magic-nix-cache/src/api.rs diff --git a/nix-actions-cache/src/binary_cache.rs b/magic-nix-cache/src/binary_cache.rs similarity index 100% rename from nix-actions-cache/src/binary_cache.rs rename to magic-nix-cache/src/binary_cache.rs diff --git a/nix-actions-cache/src/error.rs b/magic-nix-cache/src/error.rs similarity index 100% rename from nix-actions-cache/src/error.rs rename to magic-nix-cache/src/error.rs diff --git a/nix-actions-cache/src/main.rs b/magic-nix-cache/src/main.rs similarity index 98% rename from nix-actions-cache/src/main.rs rename to magic-nix-cache/src/main.rs index de32c78..eeca136 100644 --- a/nix-actions-cache/src/main.rs +++ b/magic-nix-cache/src/main.rs @@ -174,7 +174,7 @@ fn init_logging() { let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| { #[cfg(debug_assertions)] return EnvFilter::new("info") - .add_directive("nix_actions_cache=debug".parse().unwrap()) + .add_directive("magic_nix_cache=debug".parse().unwrap()) .add_directive("gha_cache=debug".parse().unwrap()); #[cfg(not(debug_assertions))] diff --git a/nix-actions-cache/src/util.rs b/magic-nix-cache/src/util.rs similarity index 100% rename from nix-actions-cache/src/util.rs rename to magic-nix-cache/src/util.rs