flake: clean up

This commit is contained in:
figsoda 2023-04-26 20:58:26 -04:00
parent 837d29a7cf
commit 23b36061c8

View File

@ -5,30 +5,38 @@
outputs = { self, nixpkgs }: outputs = { self, nixpkgs }:
let let
inherit (builtins) path;
inherit (nixpkgs.lib) inherit (nixpkgs.lib)
genAttrs importTOML licenses makeBinPath maintainers optionals sourceByRegex; genAttrs
importTOML
licenses
maintainers
makeBinPath
optionals
sourceByRegex
;
inherit (importTOML (self + "/Cargo.toml")) package; inherit (importTOML (self + "/Cargo.toml")) package;
forEachSystem = genAttrs [ eachSystem = f: genAttrs
"aarch64-darwin" [
"aarch64-linux" "aarch64-darwin"
"x86_64-darwin" "aarch64-linux"
"x86_64-linux" "x86_64-darwin"
]; "x86_64-linux"
]
(system: f nixpkgs.legacyPackages.${system});
in in
{ {
formatter = forEachSystem formatter = eachSystem (pkgs: pkgs.nixpkgs-fmt);
(system: nixpkgs.legacyPackages.${system}.nixpkgs-fmt);
herculesCI.ciSystems = [ herculesCI.ciSystems = [
"x86_64-linux" "x86_64-linux"
"aarch64-linux" "aarch64-linux"
]; ];
packages = forEachSystem (system: packages = eachSystem (pkgs:
let let
inherit (nixpkgs.legacyPackages.${system}) inherit (pkgs)
darwin darwin
gitMinimal gitMinimal
installShellFiles installShellFiles
@ -38,23 +46,23 @@
rustPlatform rustPlatform
stdenv stdenv
; ;
src = sourceByRegex self [
"(src|tests)(/.*)?"
"Cargo\\.(toml|lock)"
"build.rs"
];
in in
{ {
default = rustPlatform.buildRustPackage { default = rustPlatform.buildRustPackage {
pname = "nurl"; pname = "nurl";
inherit (package) version; inherit (package) version;
src = sourceByRegex self [ inherit src;
"(src|tests)(/.*)?"
"Cargo\\.(toml|lock)"
"build.rs"
];
cargoLock = { cargoLock = {
allowBuiltinFetchGit = true; allowBuiltinFetchGit = true;
lockFile = path { lockFile = src + "/Cargo.lock";
path = self + "/Cargo.lock";
};
}; };
nativeBuildInputs = [ nativeBuildInputs = [
@ -69,6 +77,10 @@
# tests require internet access # tests require internet access
doCheck = false; doCheck = false;
env = {
GEN_ARTIFACTS = "artifacts";
};
postInstall = '' postInstall = ''
wrapProgram $out/bin/nurl \ wrapProgram $out/bin/nurl \
--prefix PATH : ${makeBinPath [ gitMinimal mercurial nixVersions.unstable ]} --prefix PATH : ${makeBinPath [ gitMinimal mercurial nixVersions.unstable ]}
@ -76,10 +88,6 @@
installShellCompletion artifacts/nurl.{bash,fish} --zsh artifacts/_nurl installShellCompletion artifacts/nurl.{bash,fish} --zsh artifacts/_nurl
''; '';
env = {
GEN_ARTIFACTS = "artifacts";
};
meta = { meta = {
inherit (package) description; inherit (package) description;
license = licenses.mpl20; license = licenses.mpl20;