mysqladm-rs/flake.nix

87 lines
2.6 KiB
Nix
Raw Normal View History

2024-04-20 03:37:05 +02:00
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
};
2024-04-20 03:37:05 +02:00
outputs = { self, nixpkgs, rust-overlay }@inputs:
let
inherit (nixpkgs) lib;
2024-04-20 03:37:05 +02:00
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
2024-04-20 03:37:05 +02:00
"aarch64-darwin"
"armv7l-linux"
2024-04-20 03:37:05 +02:00
];
2024-04-20 03:37:05 +02:00
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
(import rust-overlay)
2024-04-20 03:37:05 +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 {
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 {
nativeBuildInputs = with pkgs; [
toolchain
mysql-client
cargo-nextest
];
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
2024-04-20 03:37:05 +02:00
});
overlays = {
default = self.overlays.mysqladm-rs;
2024-08-19 00:19:17 +02:00
mysqladm-rs = final: prev: {
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;
};
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
};
}