2024-04-20 03:37:05 +02:00
|
|
|
{
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
|
|
|
2024-07-10 17:08:53 +02:00
|
|
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
|
|
|
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2024-04-20 03:37:05 +02:00
|
|
|
|
2024-07-10 17:08:53 +02:00
|
|
|
outputs = { self, nixpkgs, rust-overlay }@inputs:
|
2024-08-09 19:05:16 +02:00
|
|
|
let
|
|
|
|
inherit (nixpkgs) lib;
|
|
|
|
|
2024-04-20 03:37:05 +02:00
|
|
|
systems = [
|
|
|
|
"x86_64-linux"
|
|
|
|
"aarch64-linux"
|
2024-07-10 17:08:53 +02:00
|
|
|
"x86_64-darwin"
|
2024-04-20 03:37:05 +02:00
|
|
|
"aarch64-darwin"
|
2024-07-10 17:08:53 +02:00
|
|
|
"armv7l-linux"
|
2024-04-20 03:37:05 +02:00
|
|
|
];
|
2024-08-09 19:05:16 +02:00
|
|
|
|
2024-04-20 03:37:05 +02:00
|
|
|
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
overlays = [
|
2024-07-10 17:08:53 +02:00
|
|
|
(import rust-overlay)
|
2024-04-20 03:37:05 +02:00
|
|
|
];
|
|
|
|
};
|
2024-07-10 17:08:53 +02:00
|
|
|
|
|
|
|
rust-bin = rust-overlay.lib.mkRustBin { } pkgs.buildPackages;
|
|
|
|
toolchain = rust-bin.stable.latest.default;
|
2024-04-20 03:37:05 +02:00
|
|
|
in f system pkgs toolchain);
|
|
|
|
in {
|
2024-08-09 19:05:16 +02:00
|
|
|
|
|
|
|
apps = let
|
|
|
|
mkApp = program: { type = "app"; program = toString program; };
|
|
|
|
in forAllSystems (system: pkgs: _: {
|
|
|
|
mysqladm-rs = mkApp (lib.getExe self.packages.${system}.mysqladm-rs);
|
|
|
|
coverage = mkApp (pkgs.writeScript "mysqladm-rs-coverage" ''
|
|
|
|
${lib.getExe pkgs.python3} -m http.server -d "${self.packages.${system}.coverage}/html/src"
|
|
|
|
'');
|
|
|
|
});
|
|
|
|
|
2024-04-20 03:37:05 +02:00
|
|
|
devShell = forAllSystems (system: pkgs: toolchain: pkgs.mkShell {
|
2024-08-08 19:31:02 +02:00
|
|
|
nativeBuildInputs = with pkgs; [
|
2024-08-07 20:50:56 +02:00
|
|
|
toolchain
|
2024-08-08 19:31:02 +02:00
|
|
|
mysql-client
|
|
|
|
cargo-nextest
|
2024-08-07 20:50:56 +02:00
|
|
|
];
|
2024-07-10 17:08:53 +02:00
|
|
|
|
|
|
|
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
|
2024-04-20 03:37:05 +02:00
|
|
|
});
|
2024-08-09 19:05:16 +02:00
|
|
|
|
|
|
|
overlays = {
|
|
|
|
default = self.overlays.mysqladm-rs;
|
2024-08-19 00:19:17 +02:00
|
|
|
mysqladm-rs = final: prev: {
|
2024-08-09 19:05:16 +02:00
|
|
|
inherit (self.packages.${prev.system}) mysqladm-rs;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-08-19 00:19:17 +02:00
|
|
|
nixosModules = {
|
|
|
|
default = self.nixosModules.mysqladm-rs;
|
|
|
|
mysqladm-rs = import ./nix/module.nix;
|
|
|
|
};
|
|
|
|
|
2024-08-09 19:05:16 +02:00
|
|
|
packages = let
|
|
|
|
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
|
|
|
cargoLock = ./Cargo.lock;
|
|
|
|
src = builtins.filterSource (path: type: let
|
|
|
|
baseName = baseNameOf (toString path);
|
|
|
|
in !(lib.any (b: b) [
|
|
|
|
(!(lib.cleanSourceFilter path type))
|
|
|
|
(baseName == "target" && type == "directory")
|
|
|
|
(baseName == "nix" && type == "directory")
|
|
|
|
(baseName == "flake.nix" && type == "regular")
|
|
|
|
(baseName == "flake.lock" && type == "regular")
|
|
|
|
])) ./.;
|
|
|
|
in forAllSystems (system: pkgs: _: {
|
|
|
|
default = self.packages.${system}.mysqladm-rs;
|
|
|
|
mysqladm-rs = pkgs.callPackage ./nix/default.nix { inherit cargoToml cargoLock src; };
|
|
|
|
coverage = pkgs.callPackage ./nix/coverage.nix { inherit cargoToml cargoLock src; };
|
|
|
|
filteredSource = pkgs.runCommandLocal "filtered-source" { } ''
|
|
|
|
ln -s ${src} $out
|
|
|
|
'';
|
|
|
|
});
|
2024-04-20 03:37:05 +02:00
|
|
|
};
|
|
|
|
}
|