Merge pull request #8 from DeterminateSystems/export-closure

Upload Nix closure to S3
This commit is contained in:
Eelco Dolstra 2024-01-09 17:18:14 +01:00 committed by GitHub
commit a5caffb2e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 33 additions and 46 deletions

View file

@ -20,14 +20,14 @@ jobs:
- uses: DeterminateSystems/magic-nix-cache-action@main - uses: DeterminateSystems/magic-nix-cache-action@main
- name: Build package - name: Build package
run: "nix build .# -L --fallback" run: "nix build .# -L --fallback && nix-store --export $(nix-store -qR ./result) | xz -9 > magic-nix-cache.closure.xz"
- name: Upload a Build Artifact - name: Upload a Build Artifact
uses: actions/upload-artifact@v3.1.2 uses: actions/upload-artifact@v3.1.2
with: with:
# Artifact name # Artifact name
name: magic-nix-cache-ARM64-macOS name: magic-nix-cache-ARM64-macOS
path: result/bin/magic-nix-cache path: magic-nix-cache.closure.xz
retention-days: 1 retention-days: 1
build-artifacts-X64-macOS: build-artifacts-X64-macOS:
@ -47,14 +47,14 @@ jobs:
- uses: DeterminateSystems/magic-nix-cache-action@main - uses: DeterminateSystems/magic-nix-cache-action@main
- name: Build package - name: Build package
run: "nix build .# -L --fallback" run: "nix build .# -L --fallback && nix-store --export $(nix-store -qR ./result) | xz -9 > magic-nix-cache.closure.xz"
- name: Upload a Build Artifact - name: Upload a Build Artifact
uses: actions/upload-artifact@v3.1.2 uses: actions/upload-artifact@v3.1.2
with: with:
# Artifact name # Artifact name
name: magic-nix-cache-X64-macOS name: magic-nix-cache-X64-macOS
path: result/bin/magic-nix-cache path: magic-nix-cache.closure.xz
retention-days: 1 retention-days: 1
build-artifacts-X64-Linux: build-artifacts-X64-Linux:
@ -71,15 +71,15 @@ jobs:
- uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action-priv@main - uses: DeterminateSystems/magic-nix-cache-action@main
- name: Build package - name: Build package
run: "nix build .# -L --fallback" run: "nix build .# -L --fallback && nix-store --export $(nix-store -qR ./result) | xz -9 > magic-nix-cache.closure.xz"
- name: Upload a Build Artifact - name: Upload a Build Artifact
uses: actions/upload-artifact@v3.1.2 uses: actions/upload-artifact@v3.1.2
with: with:
# Artifact name # Artifact name
name: magic-nix-cache-X64-Linux name: magic-nix-cache-X64-Linux
path: result/bin/magic-nix-cache path: magic-nix-cache.closure.xz
retention-days: 1 retention-days: 1

View file

@ -37,21 +37,21 @@ jobs:
name: magic-nix-cache-ARM64-macOS name: magic-nix-cache-ARM64-macOS
path: cache-binary-ARM64-macOS path: cache-binary-ARM64-macOS
- name: Persist the cache binary - name: Persist the cache binary
run: cp ./cache-binary-ARM64-macOS/magic-nix-cache ./artifacts/magic-nix-cache-ARM64-macOS run: cp ./cache-binary-ARM64-macOS/magic-nix-cache.closure.xz ./artifacts/magic-nix-cache-ARM64-macOS
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v3
with: with:
name: magic-nix-cache-X64-macOS name: magic-nix-cache-X64-macOS
path: cache-binary-X64-macOS path: cache-binary-X64-macOS
- name: Persist the cache binary - name: Persist the cache binary
run: cp ./cache-binary-X64-macOS/magic-nix-cache ./artifacts/magic-nix-cache-X64-macOS run: cp ./cache-binary-X64-macOS/magic-nix-cache.closure.xz ./artifacts/magic-nix-cache-X64-macOS
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v3
with: with:
name: magic-nix-cache-X64-Linux name: magic-nix-cache-X64-Linux
path: cache-binary-X64-Linux path: cache-binary-X64-Linux
- name: Persist the cache binary - name: Persist the cache binary
run: cp ./cache-binary-X64-Linux/magic-nix-cache ./artifacts/magic-nix-cache-X64-Linux run: cp ./cache-binary-X64-Linux/magic-nix-cache.closure.xz ./artifacts/magic-nix-cache-X64-Linux
- name: Publish Release (Branch) - name: Publish Release (Branch)
env: env:

View file

@ -41,21 +41,21 @@ jobs:
name: magic-nix-cache-ARM64-macOS name: magic-nix-cache-ARM64-macOS
path: cache-binary-ARM64-macOS path: cache-binary-ARM64-macOS
- name: Persist the cache binary - name: Persist the cache binary
run: cp ./cache-binary-ARM64-macOS/magic-nix-cache ./artifacts/magic-nix-cache-ARM64-macOS run: cp ./cache-binary-ARM64-macOS/magic-nix-cache.closure.xz ./artifacts/magic-nix-cache-ARM64-macOS
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v3
with: with:
name: magic-nix-cache-X64-macOS name: magic-nix-cache-X64-macOS
path: cache-binary-X64-macOS path: cache-binary-X64-macOS
- name: Persist the cache binary - name: Persist the cache binary
run: cp ./cache-binary-X64-macOS/magic-nix-cache ./artifacts/magic-nix-cache-X64-macOS run: cp ./cache-binary-X64-macOS/magic-nix-cache.closure.xz ./artifacts/magic-nix-cache-X64-macOS
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v3
with: with:
name: magic-nix-cache-X64-Linux name: magic-nix-cache-X64-Linux
path: cache-binary-X64-Linux path: cache-binary-X64-Linux
- name: Persist the cache binary - name: Persist the cache binary
run: cp ./cache-binary-X64-Linux/magic-nix-cache ./artifacts/magic-nix-cache-X64-Linux run: cp ./cache-binary-X64-Linux/magic-nix-cache.closure.xz ./artifacts/magic-nix-cache-X64-Linux
- name: Configure AWS Credentials - name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2 uses: aws-actions/configure-aws-credentials@v2

View file

@ -29,21 +29,21 @@ jobs:
name: magic-nix-cache-ARM64-macOS name: magic-nix-cache-ARM64-macOS
path: cache-binary-ARM64-macOS path: cache-binary-ARM64-macOS
- name: Persist the cache binary - name: Persist the cache binary
run: cp ./cache-binary-ARM64-macOS/magic-nix-cache ./artifacts/magic-nix-cache-ARM64-macOS run: cp ./cache-binary-ARM64-macOS/magic-nix-cache.closure.xz ./artifacts/magic-nix-cache-ARM64-macOS
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v3
with: with:
name: magic-nix-cache-X64-macOS name: magic-nix-cache-X64-macOS
path: cache-binary-X64-macOS path: cache-binary-X64-macOS
- name: Persist the cache binary - name: Persist the cache binary
run: cp ./cache-binary-X64-macOS/magic-nix-cache ./artifacts/magic-nix-cache-X64-macOS run: cp ./cache-binary-X64-macOS/magic-nix-cache.closure.xz ./artifacts/magic-nix-cache-X64-macOS
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v3
with: with:
name: magic-nix-cache-X64-Linux name: magic-nix-cache-X64-Linux
path: cache-binary-X64-Linux path: cache-binary-X64-Linux
- name: Persist the cache binary - name: Persist the cache binary
run: cp ./cache-binary-X64-Linux/magic-nix-cache ./artifacts/magic-nix-cache-X64-Linux run: cp ./cache-binary-X64-Linux/magic-nix-cache.closure.xz ./artifacts/magic-nix-cache-X64-Linux
- name: Configure AWS Credentials - name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2 uses: aws-actions/configure-aws-credentials@v2

4
Cargo.lock generated
View file

@ -1782,9 +1782,9 @@ dependencies = [
[[package]] [[package]]
name = "rustls-webpki" name = "rustls-webpki"
version = "0.100.1" version = "0.100.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6207cd5ed3d8dca7816f8f3725513a34609c0c765bf652b8c3cb4cfd87db46b" checksum = "5f6a5fc258f1c1276dfe3016516945546e2d5383911efc0fc4f1cdc5df3a4ae3"
dependencies = [ dependencies = [
"ring 0.16.20", "ring 0.16.20",
"untrusted 0.7.1", "untrusted 0.7.1",

View file

@ -160,16 +160,16 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1701615100, "lastModified": 1704420045,
"narHash": "sha256-7VI84NGBvlCTduw2aHLVB62NvCiZUlALLqBe5v684Aw=", "narHash": "sha256-C36QmoJd5tdQ5R9MC1jM7fBkZW9zBUqbUCsgwS6j4QU=",
"rev": "e9f06adb793d1cca5384907b3b8a4071d5d7cb19", "rev": "c1be43e8e837b8dbee2b3665a007e761680f0c3d",
"revCount": 492472, "revCount": 553958,
"type": "tarball", "type": "tarball",
"url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2305.492472%2Brev-e9f06adb793d1cca5384907b3b8a4071d5d7cb19/018c3e8e-bc66-7f34-9054-4564bf44b6f8/source.tar.gz" "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2311.553958%2Brev-c1be43e8e837b8dbee2b3665a007e761680f0c3d/018cdf41-5b79-7317-9544-bd9c236b12d2/source.tar.gz"
}, },
"original": { "original": {
"type": "tarball", "type": "tarball",
"url": "https://flakehub.com/f/NixOS/nixpkgs/0.2305.tar.gz" "url": "https://flakehub.com/f/NixOS/nixpkgs/0.2311.tar.gz"
} }
}, },
"root": { "root": {

View file

@ -2,7 +2,7 @@
description = "GitHub Actions-powered Nix binary cache"; description = "GitHub Actions-powered Nix binary cache";
inputs = { inputs = {
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2305.tar.gz"; nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2311.tar.gz";
rust-overlay = { rust-overlay = {
url = "github:oxalica/rust-overlay"; url = "github:oxalica/rust-overlay";
@ -41,27 +41,7 @@
in in
{ {
packages = forEachSupportedSystem ({ pkgs, cranePkgs, ... }: rec { packages = forEachSupportedSystem ({ pkgs, cranePkgs, ... }: rec {
magic-nix-cache = (pkgs.pkgsStatic.callPackage ./package.nix { magic-nix-cache = pkgs.callPackage ./package.nix { };
rustPlatform = pkgs.pkgsStatic.rustPackages_1_70.rustPlatform;
nix = pkgs.pkgsStatic.nix.overrideAttrs (old: {
patches = (old.patches or []) ++ [ ./nix.patch ];
});
}).overrideAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or []) ++ [
pkgs.nukeReferences
];
# Read by pkg_config crate (do some autodetection in build.rs?)
PKG_CONFIG_ALL_STATIC = "1";
"NIX_CFLAGS_LINK_${pkgs.pkgsStatic.stdenv.cc.suffixSalt}" = "-lc";
RUSTFLAGS = "-C relocation-model=static";
postFixup = (old.postFixup or "") + ''
rm -f $out/nix-support/propagated-build-inputs
nuke-refs $out/bin/magic-nix-cache
'';
});
#inherit (cranePkgs) magic-nix-cache; #inherit (cranePkgs) magic-nix-cache;
default = magic-nix-cache; default = magic-nix-cache;
}); });

View file

@ -36,6 +36,13 @@ in rustPlatform.buildRustPackage rec {
ATTIC_DISTRIBUTOR = "attic"; ATTIC_DISTRIBUTOR = "attic";
# Hack to fix linking on macOS.
NIX_CFLAGS_LINK = lib.optionalString stdenv.isDarwin "-lc++abi";
# Recursive Nix is not stable yet # Recursive Nix is not stable yet
doCheck = false; doCheck = false;
postFixup = ''
rm -f $out/nix-support/propagated-build-inputs
'';
} }