2023-05-08 09:48:11 +00:00
|
|
|
{
|
|
|
|
description = "GitHub Actions-powered Nix binary cache";
|
|
|
|
|
|
|
|
inputs = {
|
2025-03-24 23:21:34 +00:00
|
|
|
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1";
|
2023-05-08 09:48:11 +00:00
|
|
|
|
2025-02-19 20:08:44 +00:00
|
|
|
# Pinned to `master` until a release containing
|
|
|
|
# <https://github.com/ipetkov/crane/pull/792> is cut.
|
|
|
|
crane.url = "github:ipetkov/crane";
|
2023-05-08 09:48:11 +00:00
|
|
|
|
2025-03-24 23:21:34 +00:00
|
|
|
nix.url = "https://flakehub.com/f/NixOS/nix/2";
|
2023-05-08 09:48:11 +00:00
|
|
|
};
|
|
|
|
|
2025-02-19 20:12:22 +00:00
|
|
|
outputs = { self, nixpkgs, crane, ... }@inputs:
|
2023-06-22 18:19:49 +00:00
|
|
|
let
|
|
|
|
supportedSystems = [
|
|
|
|
"aarch64-linux"
|
|
|
|
"x86_64-linux"
|
|
|
|
"aarch64-darwin"
|
|
|
|
"x86_64-darwin"
|
2023-05-08 09:48:11 +00:00
|
|
|
];
|
2024-08-09 17:34:28 +00:00
|
|
|
|
2024-08-09 17:17:16 +00:00
|
|
|
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f rec {
|
2024-08-09 17:34:28 +00:00
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
overlays = [
|
|
|
|
self.overlays.default
|
|
|
|
];
|
2024-08-09 17:17:16 +00:00
|
|
|
};
|
|
|
|
inherit (pkgs) lib;
|
2024-08-09 17:34:28 +00:00
|
|
|
inherit system;
|
2024-08-09 17:17:16 +00:00
|
|
|
});
|
2023-06-22 18:19:49 +00:00
|
|
|
in
|
|
|
|
{
|
2024-08-09 17:34:28 +00:00
|
|
|
|
|
|
|
overlays.default = final: prev:
|
|
|
|
let
|
2025-02-19 20:12:22 +00:00
|
|
|
craneLib = crane.mkLib final;
|
2024-08-09 17:34:28 +00:00
|
|
|
crateName = craneLib.crateNameFromCargoToml {
|
|
|
|
cargoToml = ./magic-nix-cache/Cargo.toml;
|
|
|
|
};
|
|
|
|
|
|
|
|
commonArgs = {
|
|
|
|
inherit (crateName) pname version;
|
|
|
|
src = self;
|
|
|
|
|
|
|
|
nativeBuildInputs = with final; [
|
|
|
|
pkg-config
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
2025-02-19 18:32:14 +00:00
|
|
|
inputs.nix.packages.${final.stdenv.system}.default
|
2024-08-09 17:34:28 +00:00
|
|
|
final.boost
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
|
|
|
in
|
2025-02-19 20:07:04 +00:00
|
|
|
{
|
2024-08-09 17:34:28 +00:00
|
|
|
magic-nix-cache = craneLib.buildPackage (commonArgs // {
|
|
|
|
inherit cargoArtifacts;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
packages = forEachSupportedSystem ({ pkgs, ... }: rec {
|
|
|
|
magic-nix-cache = pkgs.magic-nix-cache;
|
2024-08-09 17:17:16 +00:00
|
|
|
default = magic-nix-cache;
|
2024-06-12 21:55:39 +00:00
|
|
|
|
|
|
|
veryLongChain =
|
|
|
|
let
|
2024-06-13 01:20:43 +00:00
|
|
|
ctx = ./README.md;
|
|
|
|
|
2024-06-12 21:55:39 +00:00
|
|
|
# Function to write the current date to a file
|
|
|
|
startFile =
|
|
|
|
pkgs.stdenv.mkDerivation {
|
|
|
|
name = "start-file";
|
|
|
|
buildCommand = ''
|
2024-06-13 01:20:43 +00:00
|
|
|
cat ${ctx} > $out
|
2024-06-12 21:55:39 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
# Recursive function to create a chain of derivations
|
|
|
|
createChain = n: startFile:
|
|
|
|
pkgs.stdenv.mkDerivation {
|
|
|
|
name = "chain-${toString n}";
|
|
|
|
src =
|
|
|
|
if n == 0 then
|
|
|
|
startFile
|
|
|
|
else createChain (n - 1) startFile;
|
|
|
|
buildCommand = ''
|
|
|
|
echo $src > $out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
# Starting point of the chain
|
2024-06-13 01:20:43 +00:00
|
|
|
createChain 200 startFile;
|
2023-06-22 18:19:49 +00:00
|
|
|
});
|
2024-08-09 17:17:16 +00:00
|
|
|
|
2025-02-19 20:12:22 +00:00
|
|
|
devShells = forEachSupportedSystem ({ system, pkgs, lib }: {
|
2024-01-18 19:06:00 +00:00
|
|
|
default = pkgs.mkShell {
|
2024-08-09 17:17:16 +00:00
|
|
|
packages = with pkgs; [
|
2025-02-19 20:12:22 +00:00
|
|
|
rustc
|
|
|
|
cargo
|
|
|
|
clippy
|
|
|
|
rustfmt
|
|
|
|
rust-analyzer
|
2024-08-09 17:34:28 +00:00
|
|
|
|
2025-02-21 18:42:17 +00:00
|
|
|
inputs.nix.packages.${stdenv.system}.default # for linking attic
|
2024-08-09 17:34:28 +00:00
|
|
|
boost # for linking attic
|
2024-08-09 17:17:16 +00:00
|
|
|
bashInteractive
|
|
|
|
pkg-config
|
|
|
|
|
|
|
|
cargo-bloat
|
|
|
|
cargo-edit
|
|
|
|
cargo-udeps
|
|
|
|
cargo-watch
|
|
|
|
bacon
|
|
|
|
|
|
|
|
age
|
2024-08-09 17:34:28 +00:00
|
|
|
];
|
2024-08-09 17:17:16 +00:00
|
|
|
|
2025-02-19 20:12:22 +00:00
|
|
|
RUST_SRC_PATH = "${pkgs.rustPlatform.rustcSrc}/library";
|
2024-08-09 17:17:16 +00:00
|
|
|
};
|
|
|
|
});
|
2023-05-08 09:48:11 +00:00
|
|
|
};
|
|
|
|
}
|