nurl/flake.nix

112 lines
2.5 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});
2023-04-27 04:01:43 +03:00
runtimeInputs = pkgs:
with pkgs; [
gitMinimal
mercurial
nixVersions.unstable
];
2022-12-30 18:23:21 +03:00
2023-05-01 16:34:30 +03:00
packageFor = 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
installShellFiles
makeBinaryWrapper
rustPlatform
stdenv
;
2023-04-27 03:58:26 +03:00
src = sourceByRegex self [
"(src|tests)(/.*)?"
2023-05-02 20:17:12 +03:00
''Cargo\.(toml|lock)''
''build\.rs''
2023-04-27 03:58:26 +03:00
];
2022-12-30 21:18:27 +03:00
in
2023-05-01 16:34:30 +03:00
rustPlatform.buildRustPackage {
pname = "nurl";
inherit (package) version;
inherit src;
cargoLock = {
allowBuiltinFetchGit = true;
lockFile = src + "/Cargo.lock";
2022-12-30 21:18:27 +03:00
};
2023-05-01 16:34:30 +03:00
nativeBuildInputs = [
installShellFiles
makeBinaryWrapper
];
buildInputs = optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Security
];
# tests require internet access
doCheck = false;
env = {
GEN_ARTIFACTS = "artifacts";
};
postInstall = ''
wrapProgram $out/bin/nurl \
--prefix PATH : ${makeBinPath (runtimeInputs pkgs)}
installManPage artifacts/nurl.1
installShellCompletion artifacts/nurl.{bash,fish} --zsh artifacts/_nurl
'';
meta = {
inherit (package) description;
license = licenses.mpl20;
maintainers = with maintainers; [ figsoda ];
2023-08-11 20:38:32 +03:00
mainProgram = "nurl";
2023-05-01 16:34:30 +03:00
};
};
in
{
devShells = eachSystem (pkgs: {
default = pkgs.mkShell {
packages = runtimeInputs pkgs;
};
});
formatter = eachSystem (pkgs: pkgs.nixpkgs-fmt);
overlays.default = _: prev: {
nurl = packageFor prev;
};
packages = eachSystem (pkgs: {
default = packageFor pkgs;
});
2022-12-30 18:23:21 +03:00
};
}