2023-01-01 00:01:07 +00:00
|
|
|
{
|
|
|
|
description = "A Nix binary cache server";
|
|
|
|
|
|
|
|
inputs = {
|
2023-03-05 18:05:11 +00:00
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
2023-01-16 21:14:14 +00:00
|
|
|
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-22.11";
|
2023-01-02 04:33:08 +00:00
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
2023-01-01 00:01:07 +00:00
|
|
|
|
2023-01-02 14:46:12 +00:00
|
|
|
crane = {
|
2023-03-05 18:05:11 +00:00
|
|
|
url = "github:ipetkov/crane";
|
2023-01-02 14:46:12 +00:00
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
inputs.flake-compat.follows = "flake-compat";
|
|
|
|
inputs.flake-utils.follows = "flake-utils";
|
|
|
|
};
|
|
|
|
|
2023-01-01 00:01:07 +00:00
|
|
|
flake-compat = {
|
|
|
|
url = "github:edolstra/flake-compat";
|
|
|
|
flake = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-01-16 21:14:14 +00:00
|
|
|
outputs = { self, nixpkgs, nixpkgs-stable, flake-utils, crane, ... }: let
|
2023-01-02 04:33:08 +00:00
|
|
|
supportedSystems = flake-utils.lib.defaultSystems;
|
2023-01-06 07:59:35 +00:00
|
|
|
|
|
|
|
makeCranePkgs = pkgs: let
|
|
|
|
craneLib = crane.mkLib pkgs;
|
|
|
|
in pkgs.callPackage ./crane.nix { inherit craneLib; };
|
2023-01-02 04:33:08 +00:00
|
|
|
in flake-utils.lib.eachSystem supportedSystems (system: let
|
2023-01-06 07:59:38 +00:00
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
overlays = [];
|
|
|
|
};
|
2023-01-06 07:59:35 +00:00
|
|
|
cranePkgs = makeCranePkgs pkgs;
|
2023-01-02 14:46:12 +00:00
|
|
|
|
2023-01-16 21:14:14 +00:00
|
|
|
pkgsStable = import nixpkgs-stable {
|
|
|
|
inherit system;
|
|
|
|
overlays = [];
|
|
|
|
};
|
|
|
|
cranePkgsStable = makeCranePkgs pkgsStable;
|
|
|
|
|
2023-01-01 00:01:07 +00:00
|
|
|
inherit (pkgs) lib;
|
|
|
|
in rec {
|
|
|
|
packages = {
|
|
|
|
default = packages.attic;
|
|
|
|
|
2023-01-03 05:12:56 +00:00
|
|
|
inherit (cranePkgs) attic attic-client attic-server;
|
2023-01-01 00:01:07 +00:00
|
|
|
|
2023-01-02 14:46:12 +00:00
|
|
|
attic-nixpkgs = pkgs.callPackage ./package.nix { };
|
2023-01-01 00:01:07 +00:00
|
|
|
|
2023-01-06 22:55:05 +00:00
|
|
|
# TODO: Make this work with Crane
|
|
|
|
attic-static = (pkgs.pkgsStatic.callPackage ./package.nix {
|
|
|
|
nix = pkgs.pkgsStatic.nix.overrideAttrs (old: {
|
|
|
|
patches = (old.patches or []) ++ [
|
|
|
|
# To be submitted
|
|
|
|
(pkgs.fetchpatch {
|
|
|
|
url = "https://github.com/NixOS/nix/compare/3172c51baff5c81362fcdafa2e28773c2949c660...6b09a02536d5946458b537dfc36b7d268c9ce823.diff";
|
|
|
|
hash = "sha256-LFLq++J2XitEWQ0o57ihuuUlYk2PgUr11h7mMMAEe3c=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}).overrideAttrs (old: {
|
|
|
|
# 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";
|
|
|
|
});
|
|
|
|
|
2023-03-22 00:45:34 +00:00
|
|
|
attic-client-static = packages.attic-static.override {
|
|
|
|
clientOnly = true;
|
|
|
|
};
|
|
|
|
|
2023-01-03 04:50:11 +00:00
|
|
|
attic-ci-installer = pkgs.callPackage ./ci-installer.nix {
|
|
|
|
inherit self;
|
|
|
|
};
|
|
|
|
|
2023-01-06 07:59:35 +00:00
|
|
|
book = pkgs.callPackage ./book {
|
|
|
|
attic = packages.attic;
|
|
|
|
};
|
|
|
|
} // (lib.optionalAttrs pkgs.stdenv.isLinux {
|
2023-01-01 00:01:07 +00:00
|
|
|
attic-server-image = pkgs.dockerTools.buildImage {
|
|
|
|
name = "attic-server";
|
|
|
|
tag = "main";
|
2023-01-02 03:59:02 +00:00
|
|
|
copyToRoot = [
|
2023-01-05 04:05:07 +00:00
|
|
|
# Debugging utilities for `fly ssh console`
|
|
|
|
pkgs.busybox
|
2023-01-02 03:59:02 +00:00
|
|
|
packages.attic-server
|
|
|
|
];
|
2023-01-01 00:01:07 +00:00
|
|
|
config = {
|
|
|
|
Entrypoint = [ "${packages.attic-server}/bin/atticd" ];
|
|
|
|
Cmd = [ "--mode" "api-server" ];
|
|
|
|
Env = [
|
|
|
|
"SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2023-01-06 07:59:35 +00:00
|
|
|
});
|
2023-01-03 05:12:56 +00:00
|
|
|
|
2023-01-01 00:01:07 +00:00
|
|
|
devShells = {
|
|
|
|
default = pkgs.mkShell {
|
|
|
|
inputsFrom = with packages; [ attic book ];
|
|
|
|
nativeBuildInputs = with pkgs; [
|
2023-01-02 17:32:05 +00:00
|
|
|
rustc
|
|
|
|
|
2023-01-01 00:01:07 +00:00
|
|
|
rustfmt clippy
|
|
|
|
cargo-expand cargo-outdated cargo-edit
|
2023-01-05 04:05:07 +00:00
|
|
|
tokio-console
|
2023-01-01 00:01:07 +00:00
|
|
|
|
|
|
|
sqlite-interactive
|
|
|
|
|
|
|
|
editorconfig-checker
|
|
|
|
|
|
|
|
flyctl
|
2023-01-05 04:05:07 +00:00
|
|
|
|
|
|
|
wrk
|
2023-01-01 00:01:07 +00:00
|
|
|
] ++ (lib.optionals pkgs.stdenv.isLinux [
|
|
|
|
linuxPackages.perf
|
|
|
|
]);
|
|
|
|
|
|
|
|
NIX_PATH = "nixpkgs=${pkgs.path}";
|
|
|
|
RUST_SRC_PATH = "${pkgs.rustPlatform.rustcSrc}/library";
|
|
|
|
|
|
|
|
ATTIC_DISTRIBUTOR = "dev";
|
|
|
|
};
|
|
|
|
|
|
|
|
demo = pkgs.mkShell {
|
|
|
|
nativeBuildInputs = [
|
|
|
|
packages.default
|
|
|
|
];
|
|
|
|
|
|
|
|
shellHook = ''
|
|
|
|
>&2 echo
|
|
|
|
>&2 echo '🚀 Run `atticd` to get started!'
|
|
|
|
>&2 echo
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
devShell = devShells.default;
|
2023-01-06 07:59:35 +00:00
|
|
|
|
|
|
|
internal = {
|
|
|
|
inherit (cranePkgs) attic-tests cargoArtifacts;
|
|
|
|
};
|
2023-01-06 07:59:38 +00:00
|
|
|
|
2023-01-16 21:14:14 +00:00
|
|
|
checks = let
|
|
|
|
makeIntegrationTests = pkgs: import ./integration-tests {
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
overlays = [ self.overlays.default ];
|
|
|
|
};
|
|
|
|
flake = self;
|
2023-01-06 07:59:38 +00:00
|
|
|
};
|
2023-01-16 21:14:14 +00:00
|
|
|
unstableTests = makeIntegrationTests pkgs;
|
|
|
|
stableTests = lib.mapAttrs' (name: lib.nameValuePair "stable-${name}") (makeIntegrationTests pkgsStable);
|
|
|
|
in lib.optionalAttrs pkgs.stdenv.isLinux (unstableTests // stableTests);
|
2023-01-06 07:59:35 +00:00
|
|
|
}) // {
|
|
|
|
overlays = {
|
|
|
|
default = final: prev: let
|
|
|
|
cranePkgs = makeCranePkgs final;
|
|
|
|
in {
|
|
|
|
inherit (cranePkgs) attic attic-client attic-server;
|
|
|
|
};
|
|
|
|
};
|
2023-01-06 07:59:35 +00:00
|
|
|
|
|
|
|
nixosModules = {
|
|
|
|
atticd = {
|
|
|
|
imports = [
|
|
|
|
./nixos/atticd.nix
|
|
|
|
];
|
|
|
|
|
|
|
|
services.atticd.useFlakeCompatOverlay = false;
|
|
|
|
|
|
|
|
nixpkgs.overlays = [
|
|
|
|
self.overlays.default
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2023-01-06 07:59:35 +00:00
|
|
|
};
|
2023-01-01 00:01:07 +00:00
|
|
|
}
|