2022-12-11 14:08:07 +00:00
|
|
|
{
|
2023-07-16 19:20:39 +01:00
|
|
|
description = "Docker registry frontend & basic library";
|
2022-12-11 14:08:07 +00:00
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
|
|
|
|
|
|
crane = {
|
|
|
|
url = "github:ipetkov/crane";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
2022-12-11 18:09:02 +00:00
|
|
|
|
2022-12-11 18:14:50 +00:00
|
|
|
Xess.url = "github:Xe/Xess";
|
2023-07-19 08:48:24 +01:00
|
|
|
|
|
|
|
advisory-db = {
|
|
|
|
url = "github:rustsec/advisory-db";
|
|
|
|
flake = false;
|
|
|
|
};
|
2022-12-11 14:08:07 +00:00
|
|
|
};
|
|
|
|
|
2023-07-19 08:48:24 +01:00
|
|
|
outputs = { self, nixpkgs, crane, flake-utils, Xess, advisory-db, ... }:
|
2022-12-12 17:13:20 +00:00
|
|
|
flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system:
|
2022-12-11 14:08:07 +00:00
|
|
|
let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
};
|
|
|
|
|
2023-07-19 08:48:24 +01:00
|
|
|
inherit (pkgs) lib;
|
|
|
|
|
2022-12-11 14:08:07 +00:00
|
|
|
craneLib = crane.lib.${system};
|
2023-07-19 08:48:24 +01:00
|
|
|
src = craneLib.cleanCargoSource (craneLib.path ./.);
|
|
|
|
commonArgs = {
|
|
|
|
inherit src;
|
2022-12-11 14:08:07 +00:00
|
|
|
|
|
|
|
buildInputs = [
|
2023-07-16 10:48:40 +01:00
|
|
|
pkgs.openssl
|
|
|
|
pkgs.pkg-config
|
2022-12-11 14:08:07 +00:00
|
|
|
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
|
|
|
|
pkgs.libiconv
|
|
|
|
];
|
|
|
|
};
|
2022-12-12 14:59:35 +00:00
|
|
|
|
2023-07-19 08:48:24 +01:00
|
|
|
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
|
|
|
|
|
|
|
dref = craneLib.buildPackage (commonArgs // {
|
|
|
|
inherit cargoArtifacts;
|
|
|
|
});
|
|
|
|
|
2022-12-12 14:59:35 +00:00
|
|
|
dockerImage = pkgs.dockerTools.buildImage {
|
|
|
|
name = "dref";
|
|
|
|
config = {
|
2023-07-16 19:20:39 +01:00
|
|
|
Cmd = [ "${dref}/bin/dref" ];
|
2022-12-12 14:59:35 +00:00
|
|
|
ExposedPorts = {
|
|
|
|
"3000/tcp" = {};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2022-12-11 14:08:07 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
checks = {
|
2023-07-16 19:20:39 +01:00
|
|
|
inherit dref;
|
2023-07-19 08:48:24 +01:00
|
|
|
dref-clippy = craneLib.cargoClippy (commonArgs // {
|
|
|
|
inherit cargoArtifacts;
|
|
|
|
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
|
|
|
|
});
|
|
|
|
|
|
|
|
dref-doc = craneLib.cargoDoc (commonArgs // {
|
|
|
|
inherit cargoArtifacts;
|
|
|
|
});
|
|
|
|
|
|
|
|
dref-fmt = craneLib.cargoFmt {
|
|
|
|
inherit src;
|
|
|
|
};
|
|
|
|
|
|
|
|
dref-audit = craneLib.cargoAudit {
|
|
|
|
inherit src advisory-db;
|
|
|
|
};
|
|
|
|
|
|
|
|
# Run tests with cargo-nextest
|
|
|
|
# Consider setting `doCheck = false` on `dref` if you do not want
|
|
|
|
# the tests to run twice
|
|
|
|
dref-nextest = craneLib.cargoNextest (commonArgs // {
|
|
|
|
inherit cargoArtifacts;
|
|
|
|
partitions = 1;
|
|
|
|
partitionType = "count";
|
|
|
|
});
|
2022-12-11 14:08:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
apps.default = flake-utils.lib.mkApp {
|
2023-07-16 19:20:39 +01:00
|
|
|
drv = dref;
|
2022-12-11 14:08:07 +00:00
|
|
|
};
|
|
|
|
|
2022-12-11 18:14:50 +00:00
|
|
|
packages = rec {
|
2023-07-16 19:20:39 +01:00
|
|
|
bin = dref;
|
2022-12-12 14:59:35 +00:00
|
|
|
docker = dockerImage;
|
2022-12-11 18:14:50 +00:00
|
|
|
default = pkgs.symlinkJoin {
|
|
|
|
name = "dref-${bin.version}";
|
2022-12-12 14:59:35 +00:00
|
|
|
paths = [ bin ];
|
2022-12-11 18:14:50 +00:00
|
|
|
};
|
2022-12-11 18:09:02 +00:00
|
|
|
};
|
|
|
|
|
2022-12-12 17:13:20 +00:00
|
|
|
defaultPackage = self.packages.${system}.bin;
|
|
|
|
|
2022-12-11 14:08:07 +00:00
|
|
|
devShells.default = pkgs.mkShell {
|
|
|
|
inputsFrom = builtins.attrValues self.checks;
|
|
|
|
|
|
|
|
# Extra inputs can be added here
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
|
|
cargo
|
|
|
|
rustc
|
|
|
|
rust-analyzer
|
2023-07-16 10:48:40 +01:00
|
|
|
openssl
|
|
|
|
pkg-config
|
2022-12-11 14:08:07 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|