Skip to content

Commit

Permalink
chore: reformat all files with nixfmt-rfc-style
Browse files Browse the repository at this point in the history
  • Loading branch information
msfjarvis committed Dec 16, 2024
1 parent f534ca4 commit ffbebac
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 153 deletions.
11 changes: 6 additions & 5 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
(import (let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/nix-community/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}) {src = ./.;})
.defaultNix
}
) { src = ./.; }).defaultNix
311 changes: 168 additions & 143 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,149 +26,174 @@
inputs.rust-msrv.url = "https://static.rust-lang.org/dist/channel-rust-1.72.0.toml";
inputs.rust-msrv.flake = false;

outputs = {
nixpkgs,
devshell,
fenix,
crane,
flake-utils,
advisory-db,
rust-msrv,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [devshell.overlays.default];
};

rustStable = (import fenix {inherit pkgs;}).fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-yMuSb5eQPO/bHv+Bcf/US8LVMbf/G/0MSfiPwBhiPpk=";
};
rustMsrv = (fenix.packages.${system}.fromManifestFile rust-msrv).minimalToolchain;

craneLib = (crane.mkLib pkgs).overrideToolchain rustStable;
markdownFilter = path: _type: builtins.match ".*md$" path != null;
markdownOrCargo = path: type:
(markdownFilter path type) || (craneLib.filterCargoSources path type);

commonArgs = {
src = pkgs.lib.cleanSourceWith {
src = craneLib.path ./.;
filter = markdownOrCargo;
outputs =
{
nixpkgs,
devshell,
fenix,
crane,
flake-utils,
advisory-db,
rust-msrv,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ devshell.overlays.default ];
};
buildInputs = [];
nativeBuildInputs = [];
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
};

hcctlName = craneLib.crateNameFromCargoToml {
cargoToml = ./hcctl/Cargo.toml;
};
healthchecksName = craneLib.crateNameFromCargoToml {
cargoToml = ./healthchecks/Cargo.toml;
};
monitorName = craneLib.crateNameFromCargoToml {
cargoToml = ./monitor/Cargo.toml;
};
workspaceName = {
version = "1.0.0";
pname = "healthchecks-rs";
};

audit = craneLib.cargoAudit (commonArgs
// {
inherit advisory-db;
inherit (workspaceName) pname version;
});
cargoArtifacts = craneLib.buildDepsOnly (commonArgs
// {
inherit (workspaceName) pname version;
});
fmt = craneLib.cargoFmt (commonArgs
// {
inherit (workspaceName) pname version;
});

hcctl = craneLib.buildPackage (
commonArgs
// {
inherit (hcctlName) pname version;
inherit cargoArtifacts;
cargoExtraArgs = "-p hcctl";
doCheck = false;
}
);

monitor = craneLib.buildPackage (
commonArgs
// {
inherit (monitorName) pname version;
inherit cargoArtifacts;
cargoExtraArgs = "-p healthchecks-monitor";
doCheck = false;
}
);

workspace = craneLib.buildPackage (
commonArgs
// {
inherit (healthchecksName) pname version;
inherit cargoArtifacts;
doCheck = false;
}
);
workspace-clippy = craneLib.cargoClippy (commonArgs
// {
inherit (healthchecksName) pname version;
inherit cargoArtifacts;
});
workspace-nextest = craneLib.cargoNextest (commonArgs
// {
inherit (healthchecksName) pname version;
inherit cargoArtifacts;
partitions = 1;
partitionType = "count";
});
healthchecks-msrv = ((crane.mkLib pkgs).overrideToolchain rustMsrv).buildPackage (commonArgs
// {
inherit (healthchecksName) version;
pname = "healthchecks-msrv";
cargoExtraArgs = "-p healthchecks";
doCheck = false;
});
in {
checks = {
inherit audit fmt workspace workspace-clippy healthchecks-msrv workspace-nextest;
};

packages = {
inherit hcctl monitor;
};

apps.hcctl = flake-utils.lib.mkApp {drv = hcctl;};
apps.monitor = flake-utils.lib.mkApp {drv = monitor;};

devShells.default = pkgs.devshell.mkShell {
bash = {interactive = "";};

env = [
{
name = "DEVSHELL_NO_MOTD";
value = 1;

rustStable = (import fenix { inherit pkgs; }).fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-yMuSb5eQPO/bHv+Bcf/US8LVMbf/G/0MSfiPwBhiPpk=";
};
rustMsrv = (fenix.packages.${system}.fromManifestFile rust-msrv).minimalToolchain;

craneLib = (crane.mkLib pkgs).overrideToolchain rustStable;
markdownFilter = path: _type: builtins.match ".*md$" path != null;
markdownOrCargo = path: type: (markdownFilter path type) || (craneLib.filterCargoSources path type);

commonArgs = {
src = pkgs.lib.cleanSourceWith {
src = craneLib.path ./.;
filter = markdownOrCargo;
};
buildInputs = [ ];
nativeBuildInputs = [ ];
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
};

hcctlName = craneLib.crateNameFromCargoToml {
cargoToml = ./hcctl/Cargo.toml;
};
healthchecksName = craneLib.crateNameFromCargoToml {
cargoToml = ./healthchecks/Cargo.toml;
};
monitorName = craneLib.crateNameFromCargoToml {
cargoToml = ./monitor/Cargo.toml;
};
workspaceName = {
version = "1.0.0";
pname = "healthchecks-rs";
};

audit = craneLib.cargoAudit (
commonArgs
// {
inherit advisory-db;
inherit (workspaceName) pname version;
}
);
cargoArtifacts = craneLib.buildDepsOnly (
commonArgs
// {
inherit (workspaceName) pname version;
}
);
fmt = craneLib.cargoFmt (
commonArgs
// {
inherit (workspaceName) pname version;
}
];

packages = with pkgs; [
cargo-nextest
cargo-release
cargo-semver-checks
fenix.packages.${system}.rust-analyzer
nil
rustStable
stdenv.cc
];
};
});
);

hcctl = craneLib.buildPackage (
commonArgs
// {
inherit (hcctlName) pname version;
inherit cargoArtifacts;
cargoExtraArgs = "-p hcctl";
doCheck = false;
}
);

monitor = craneLib.buildPackage (
commonArgs
// {
inherit (monitorName) pname version;
inherit cargoArtifacts;
cargoExtraArgs = "-p healthchecks-monitor";
doCheck = false;
}
);

workspace = craneLib.buildPackage (
commonArgs
// {
inherit (healthchecksName) pname version;
inherit cargoArtifacts;
doCheck = false;
}
);
workspace-clippy = craneLib.cargoClippy (
commonArgs
// {
inherit (healthchecksName) pname version;
inherit cargoArtifacts;
}
);
workspace-nextest = craneLib.cargoNextest (
commonArgs
// {
inherit (healthchecksName) pname version;
inherit cargoArtifacts;
partitions = 1;
partitionType = "count";
}
);
healthchecks-msrv = ((crane.mkLib pkgs).overrideToolchain rustMsrv).buildPackage (
commonArgs
// {
inherit (healthchecksName) version;
pname = "healthchecks-msrv";
cargoExtraArgs = "-p healthchecks";
doCheck = false;
}
);
in
{
checks = {
inherit
audit
fmt
workspace
workspace-clippy
healthchecks-msrv
workspace-nextest
;
};

packages = {
inherit hcctl monitor;
};

apps.hcctl = flake-utils.lib.mkApp { drv = hcctl; };
apps.monitor = flake-utils.lib.mkApp { drv = monitor; };

devShells.default = pkgs.devshell.mkShell {
bash = {
interactive = "";
};

env = [
{
name = "DEVSHELL_NO_MOTD";
value = 1;
}
];

packages = with pkgs; [
cargo-nextest
cargo-release
cargo-semver-checks
fenix.packages.${system}.rust-analyzer
nil
rustStable
stdenv.cc
];
};
}
);
}
11 changes: 6 additions & 5 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
(import (let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/nix-community/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}) {src = ./.;})
.shellNix
}
) { src = ./.; }).shellNix

0 comments on commit ffbebac

Please sign in to comment.