nurl/flake.nix

92 lines
2.3 KiB
Nix
Raw Normal View History

2022-12-30 18:23:21 +03:00
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
2023-02-10 23:27:27 +03:00
inherit (builtins) path;
2022-12-30 18:23:21 +03:00
inherit (nixpkgs.lib)
2023-02-10 23:27:27 +03:00
genAttrs importTOML licenses makeBinPath maintainers optionals sourceByRegex;
2022-12-30 18:23:21 +03:00
inherit (importTOML (self + "/Cargo.toml")) package;
2022-12-30 21:18:27 +03:00
forEachSystem = genAttrs [
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];
2022-12-30 18:23:21 +03:00
in
{
2022-12-30 21:18:27 +03:00
formatter = forEachSystem
2022-12-30 18:23:21 +03:00
(system: nixpkgs.legacyPackages.${system}.nixpkgs-fmt);
herculesCI.ciSystems = [
"x86_64-linux"
"aarch64-linux"
];
2022-12-30 21:18:27 +03:00
packages = forEachSystem (system:
let
inherit (nixpkgs.legacyPackages.${system})
2023-04-15 17:18:46 +03:00
darwin
gitMinimal
installShellFiles
makeBinaryWrapper
mercurial
nixVersions
rustPlatform
stdenv
;
2022-12-30 21:18:27 +03:00
in
{
default = rustPlatform.buildRustPackage {
pname = "nurl";
inherit (package) version;
2023-02-10 23:27:27 +03:00
src = sourceByRegex self [
"(src|tests)(/.*)?"
"Cargo\\.(toml|lock)"
"build.rs"
];
2022-12-30 21:18:27 +03:00
2023-02-28 06:30:20 +03:00
cargoLock = {
allowBuiltinFetchGit = true;
lockFile = path {
path = self + "/Cargo.lock";
};
2023-02-10 23:27:27 +03:00
};
2022-12-30 21:18:27 +03:00
2022-12-30 23:36:38 +03:00
nativeBuildInputs = [
installShellFiles
2023-04-15 17:18:46 +03:00
makeBinaryWrapper
2022-12-30 23:36:38 +03:00
];
2022-12-30 21:18:27 +03:00
2023-01-11 04:56:44 +03:00
buildInputs = optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Security
];
2023-01-03 22:16:29 +03:00
# tests require internet access
doCheck = false;
2022-12-30 21:18:27 +03:00
postInstall = ''
wrapProgram $out/bin/nurl \
--prefix PATH : ${makeBinPath [ gitMinimal mercurial nixVersions.unstable ]}
2022-12-30 23:36:38 +03:00
installManPage artifacts/nurl.1
installShellCompletion artifacts/nurl.{bash,fish} --zsh artifacts/_nurl
2022-12-30 21:18:27 +03:00
'';
env = {
GEN_ARTIFACTS = "artifacts";
};
2022-12-30 23:36:38 +03:00
2022-12-30 21:18:27 +03:00
meta = {
inherit (package) description;
license = licenses.mpl20;
maintainers = with maintainers; [ figsoda ];
2022-12-30 18:23:21 +03:00
};
2022-12-30 21:18:27 +03:00
};
});
2022-12-30 18:23:21 +03:00
};
}