nurl/flake.nix

100 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
inherit (nixpkgs.lib)
2023-04-27 03:58:26 +03:00
genAttrs
importTOML
licenses
maintainers
makeBinPath
optionals
sourceByRegex
;
2022-12-30 18:23:21 +03:00
inherit (importTOML (self + "/Cargo.toml")) package;
2022-12-30 21:18:27 +03:00
2023-04-27 03:58:26 +03:00
eachSystem = f: genAttrs
[
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
]
(system: f nixpkgs.legacyPackages.${system});
2022-12-30 18:23:21 +03:00
in
{
2023-04-27 03:58:26 +03:00
formatter = eachSystem (pkgs: pkgs.nixpkgs-fmt);
2022-12-30 18:23:21 +03:00
herculesCI.ciSystems = [
"x86_64-linux"
"aarch64-linux"
];
2023-04-27 03:58:26 +03:00
packages = eachSystem (pkgs:
2022-12-30 21:18:27 +03:00
let
2023-04-27 03:58:26 +03:00
inherit (pkgs)
2023-04-15 17:18:46 +03:00
darwin
gitMinimal
installShellFiles
makeBinaryWrapper
mercurial
nixVersions
rustPlatform
stdenv
;
2023-04-27 03:58:26 +03:00
src = sourceByRegex self [
"(src|tests)(/.*)?"
"Cargo\\.(toml|lock)"
"build.rs"
];
2022-12-30 21:18:27 +03:00
in
{
default = rustPlatform.buildRustPackage {
pname = "nurl";
inherit (package) version;
2023-04-27 03:58:26 +03:00
inherit src;
2022-12-30 21:18:27 +03:00
2023-02-28 06:30:20 +03:00
cargoLock = {
allowBuiltinFetchGit = true;
2023-04-27 03:58:26 +03:00
lockFile = src + "/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;
2023-04-27 03:58:26 +03:00
env = {
GEN_ARTIFACTS = "artifacts";
};
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
'';
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
};
}