mirror of
https://github.com/nix-community/nix-init.git
synced 2024-09-11 08:05:42 +03:00
flake: refactor
This commit is contained in:
parent
c8d505c314
commit
4c7db7e574
50
flake.lock
50
flake.lock
@ -3,20 +3,18 @@
|
||||
"crane": {
|
||||
"inputs": {
|
||||
"flake-compat": [],
|
||||
"flake-utils": [
|
||||
"flake-utils"
|
||||
],
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"rust-overlay": []
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1682796879,
|
||||
"narHash": "sha256-X0oDZylzDXBt7RBtYXBvFexARRFvousej15feeemAx0=",
|
||||
"lastModified": 1686621798,
|
||||
"narHash": "sha256-FUwWszmSiDzUdTk8f69xwMoYlhdPaLvDaIYOE/y6VXc=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "db21a44eb056ef65a33d9d2648ecc964b4acaddc",
|
||||
"rev": "75f7d715f8088f741be9981405f6444e2d49efdd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -33,11 +31,11 @@
|
||||
"rust-analyzer-src": []
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1682749232,
|
||||
"narHash": "sha256-tZdhmgUIuSrRB8j1fTa5JVdewdNf0crNwDMnNIKfYqE=",
|
||||
"lastModified": 1686723693,
|
||||
"narHash": "sha256-wd6WE5M1EdnZPvK5h9zh3hE9F+h+7z2YhK1UpobkjGQ=",
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"rev": "30d4a659367f2399cdc9e813c516ae53d46ab266",
|
||||
"rev": "ac2f1271f1e6623717220f31890658af351b0b2c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -46,16 +44,36 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1685662779,
|
||||
"narHash": "sha256-cKDDciXGpMEjP1n6HlzKinN0H+oLmNpgeCTzYnsA2po=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "71fb97f0d875fd4de4994dfb849f2c75e17eb6c3",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1681202837,
|
||||
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
||||
"lastModified": 1685518550,
|
||||
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
|
||||
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -66,11 +84,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1682692304,
|
||||
"narHash": "sha256-9/lyXN2BpHw+1xE+D2ySBSLMCHWqiWu5tPHBMRDib8M=",
|
||||
"lastModified": 1686592866,
|
||||
"narHash": "sha256-riGg89eWhXJcPNrQGcSwTEEm7CGxWC06oSX44hajeMw=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "937a9d1ee7b1351d8c55fff6611a8edf6e7c1c37",
|
||||
"rev": "0eeebd64de89e4163f4d3cf34ffe925a5cf67a05",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -84,7 +102,7 @@
|
||||
"inputs": {
|
||||
"crane": "crane",
|
||||
"fenix": "fenix",
|
||||
"flake-utils": "flake-utils",
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
|
357
flake.nix
357
flake.nix
@ -2,7 +2,6 @@
|
||||
inputs = {
|
||||
crane = {
|
||||
url = "github:ipetkov/crane";
|
||||
inputs.flake-utils.follows = "flake-utils";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
inputs.flake-compat.follows = "";
|
||||
inputs.rust-overlay.follows = "";
|
||||
@ -12,191 +11,199 @@
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
inputs.rust-analyzer-src.follows = "";
|
||||
};
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
flake-parts = {
|
||||
url = "github:hercules-ci/flake-parts";
|
||||
inputs.nixpkgs-lib.follows = "nixpkgs";
|
||||
};
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
};
|
||||
|
||||
outputs = { self, crane, fenix, flake-utils, nixpkgs }: {
|
||||
herculesCI.ciSystems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
];
|
||||
} // flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
inherit (builtins)
|
||||
attrValues
|
||||
getAttr
|
||||
listToAttrs
|
||||
readDir
|
||||
;
|
||||
inherit (crane.lib.${system}.overrideToolchain fenix.packages.${system}.default.toolchain)
|
||||
buildDepsOnly
|
||||
buildPackage
|
||||
cargoClippy
|
||||
cargoFmt
|
||||
cargoNextest
|
||||
;
|
||||
inherit (nixpkgs.legacyPackages.${system})
|
||||
bzip2
|
||||
callPackage
|
||||
curl
|
||||
darwin
|
||||
installShellFiles
|
||||
libgit2_1_5
|
||||
libiconv
|
||||
mkShell
|
||||
nix
|
||||
nixpkgs-fmt
|
||||
nurl
|
||||
openssl
|
||||
pkg-config
|
||||
spdx-license-list-data
|
||||
stdenv
|
||||
zlib
|
||||
zstd
|
||||
;
|
||||
inherit (nixpkgs.lib)
|
||||
concatMapAttrs
|
||||
flip
|
||||
getExe
|
||||
hasSuffix
|
||||
importTOML
|
||||
licenses
|
||||
maintainers
|
||||
nameValuePair
|
||||
optionalAttrs
|
||||
optionals
|
||||
pipe
|
||||
sourceByRegex
|
||||
;
|
||||
|
||||
src = sourceByRegex self [
|
||||
"(license-store-cache|src)(/.*)?"
|
||||
''Cargo\.(toml|lock)''
|
||||
''build\.rs''
|
||||
''rustfmt\.toml''
|
||||
outputs = inputs@{ crane, flake-parts, ... }:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
systems = [
|
||||
"aarch64-darwin"
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"x86_64-linux"
|
||||
];
|
||||
|
||||
get-nix-license = callPackage ./src/get-nix-license.nix { };
|
||||
perSystem = { inputs', lib, pkgs, self', system, ... }:
|
||||
let
|
||||
inherit (builtins)
|
||||
attrValues
|
||||
getAttr
|
||||
listToAttrs
|
||||
readDir
|
||||
;
|
||||
inherit (lib)
|
||||
concatMapAttrs
|
||||
flip
|
||||
getExe
|
||||
hasSuffix
|
||||
importTOML
|
||||
licenses
|
||||
maintainers
|
||||
nameValuePair
|
||||
optionalAttrs
|
||||
optionals
|
||||
pipe
|
||||
sourceByRegex
|
||||
;
|
||||
inherit (crane.lib.${system}.overrideToolchain inputs'.fenix.packages.default.toolchain)
|
||||
buildDepsOnly
|
||||
buildPackage
|
||||
cargoClippy
|
||||
cargoFmt
|
||||
cargoNextest
|
||||
;
|
||||
inherit (pkgs)
|
||||
bzip2
|
||||
callPackage
|
||||
curl
|
||||
darwin
|
||||
installShellFiles
|
||||
libgit2_1_5
|
||||
libiconv
|
||||
mkShell
|
||||
nix
|
||||
nixpkgs-fmt
|
||||
nurl
|
||||
openssl
|
||||
pkg-config
|
||||
spdx-license-list-data
|
||||
stdenv
|
||||
zlib
|
||||
zstd
|
||||
;
|
||||
|
||||
license-store-cache = buildPackage {
|
||||
pname = "license-store-cache";
|
||||
src = sourceByRegex ./. [
|
||||
"(license-store-cache|src)(/.*)?"
|
||||
''Cargo\.(toml|lock)''
|
||||
''build\.rs''
|
||||
''rustfmt\.toml''
|
||||
];
|
||||
|
||||
inherit src;
|
||||
get-nix-license = callPackage ./src/get-nix-license.nix { };
|
||||
|
||||
buildInputs = optionals stdenv.isDarwin [
|
||||
libiconv
|
||||
];
|
||||
license-store-cache = buildPackage {
|
||||
pname = "license-store-cache";
|
||||
|
||||
doCheck = false;
|
||||
doNotRemoveReferencesToVendorDir = true;
|
||||
inherit src;
|
||||
|
||||
cargoArtifacts = null;
|
||||
cargoExtraArgs = "-p license-store-cache";
|
||||
|
||||
CARGO_PROFILE = "";
|
||||
|
||||
postInstall = ''
|
||||
cache=$(mktemp)
|
||||
$out/bin/license-store-cache $cache ${spdx-license-list-data.json}/json/details
|
||||
rm -rf $out
|
||||
mv $cache $out
|
||||
'';
|
||||
};
|
||||
|
||||
args = {
|
||||
inherit src;
|
||||
|
||||
nativeBuildInputs = [
|
||||
curl
|
||||
installShellFiles
|
||||
pkg-config
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
bzip2
|
||||
curl
|
||||
libgit2_1_5
|
||||
openssl
|
||||
zlib
|
||||
zstd
|
||||
] ++ optionals stdenv.isDarwin [
|
||||
darwin.apple_sdk.frameworks.Security
|
||||
] ++ optionals (stdenv.isDarwin && stdenv.isx86_64) [
|
||||
darwin.apple_sdk.frameworks.CoreFoundation
|
||||
];
|
||||
|
||||
cargoArtifacts = buildDepsOnly args;
|
||||
cargoExtraArgs = "--no-default-features";
|
||||
|
||||
postPatch = ''
|
||||
mkdir -p data
|
||||
ln -s ${get-nix-license} data/get-nix-license.rs
|
||||
ln -s ${license-store-cache} data/license-store-cache.zstd
|
||||
'';
|
||||
|
||||
env = {
|
||||
GEN_ARTIFACTS = "artifacts";
|
||||
NIX = getExe nix;
|
||||
NURL = getExe nurl;
|
||||
ZSTD_SYS_USE_PKG_CONFIG = true;
|
||||
};
|
||||
|
||||
meta = {
|
||||
license = licenses.mpl20;
|
||||
maintainers = with maintainers; [ figsoda ];
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
checks = {
|
||||
build = self.packages.${system}.default;
|
||||
clippy = cargoClippy (args // {
|
||||
cargoClippyExtraArgs = "-- -D warnings";
|
||||
});
|
||||
fmt = cargoFmt (removeAttrs args [ "cargoExtraArgs" ]);
|
||||
test =
|
||||
let
|
||||
fixtures = src + "/src/lang/rust/fixtures";
|
||||
lock = src + "/Cargo.lock";
|
||||
getPackages = flip pipe [
|
||||
importTOML
|
||||
(getAttr "package")
|
||||
(map ({ name, version, ... }@pkg:
|
||||
nameValuePair "${name}-${version}" pkg))
|
||||
listToAttrs
|
||||
buildInputs = optionals stdenv.isDarwin [
|
||||
libiconv
|
||||
];
|
||||
in
|
||||
cargoNextest (args // {
|
||||
cargoLockParsed = importTOML lock // {
|
||||
package = attrValues (getPackages lock // concatMapAttrs
|
||||
(name: _: optionalAttrs
|
||||
(hasSuffix "-lock.toml" name)
|
||||
(getPackages (fixtures + "/${name}")))
|
||||
(readDir fixtures));
|
||||
|
||||
doCheck = false;
|
||||
doNotRemoveReferencesToVendorDir = true;
|
||||
|
||||
cargoArtifacts = null;
|
||||
cargoExtraArgs = "-p license-store-cache";
|
||||
|
||||
CARGO_PROFILE = "";
|
||||
|
||||
postInstall = ''
|
||||
cache=$(mktemp)
|
||||
$out/bin/license-store-cache $cache ${spdx-license-list-data.json}/json/details
|
||||
rm -rf $out
|
||||
mv $cache $out
|
||||
'';
|
||||
};
|
||||
|
||||
args = {
|
||||
inherit src;
|
||||
|
||||
nativeBuildInputs = [
|
||||
curl
|
||||
installShellFiles
|
||||
pkg-config
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
bzip2
|
||||
curl
|
||||
libgit2_1_5
|
||||
openssl
|
||||
zlib
|
||||
zstd
|
||||
] ++ optionals stdenv.isDarwin [
|
||||
darwin.apple_sdk.frameworks.Security
|
||||
] ++ optionals (stdenv.isDarwin && stdenv.isx86_64) [
|
||||
darwin.apple_sdk.frameworks.CoreFoundation
|
||||
];
|
||||
|
||||
cargoArtifacts = buildDepsOnly args;
|
||||
cargoExtraArgs = "--no-default-features";
|
||||
|
||||
postPatch = ''
|
||||
mkdir -p data
|
||||
ln -s ${get-nix-license} data/get-nix-license.rs
|
||||
ln -s ${license-store-cache} data/license-store-cache.zstd
|
||||
'';
|
||||
|
||||
env = {
|
||||
GEN_ARTIFACTS = "artifacts";
|
||||
NIX = getExe nix;
|
||||
NURL = getExe nurl;
|
||||
ZSTD_SYS_USE_PKG_CONFIG = true;
|
||||
};
|
||||
|
||||
meta = {
|
||||
license = licenses.mpl20;
|
||||
maintainers = with maintainers; [ figsoda ];
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
checks = {
|
||||
build = self'.packages.default;
|
||||
clippy = cargoClippy (args // {
|
||||
cargoClippyExtraArgs = "-- -D warnings";
|
||||
});
|
||||
fmt = cargoFmt (removeAttrs args [ "cargoExtraArgs" ]);
|
||||
test =
|
||||
let
|
||||
fixtures = src + "/src/lang/rust/fixtures";
|
||||
lock = src + "/Cargo.lock";
|
||||
getPackages = flip pipe [
|
||||
importTOML
|
||||
(getAttr "package")
|
||||
(map ({ name, version, ... }@pkg:
|
||||
nameValuePair "${name}-${version}" pkg))
|
||||
listToAttrs
|
||||
];
|
||||
in
|
||||
cargoNextest (args // {
|
||||
cargoLockParsed = importTOML lock // {
|
||||
package = attrValues (getPackages lock // concatMapAttrs
|
||||
(name: _: optionalAttrs
|
||||
(hasSuffix "-lock.toml" name)
|
||||
(getPackages (fixtures + "/${name}")))
|
||||
(readDir fixtures));
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
devShells.default = mkShell {
|
||||
NIX_INIT_LOG = "nix_init=trace";
|
||||
RUST_BACKTRACE = true;
|
||||
|
||||
shellHook = ''
|
||||
mkdir -p data
|
||||
ln -sf ${get-nix-license} data/get-nix-license.rs
|
||||
ln -sf ${license-store-cache} data/license-store-cache.zstd
|
||||
'';
|
||||
};
|
||||
|
||||
formatter = nixpkgs-fmt;
|
||||
|
||||
packages.default = buildPackage (args // {
|
||||
doCheck = false;
|
||||
postInstall = ''
|
||||
installManPage artifacts/nix-init.1
|
||||
installShellCompletion artifacts/nix-init.{bash,fish} --zsh artifacts/_nix-init
|
||||
'';
|
||||
});
|
||||
};
|
||||
|
||||
devShells.default = mkShell {
|
||||
NIX_INIT_LOG = "nix_init=trace";
|
||||
RUST_BACKTRACE = true;
|
||||
|
||||
shellHook = ''
|
||||
mkdir -p data
|
||||
ln -sf ${get-nix-license} data/get-nix-license.rs
|
||||
ln -sf ${license-store-cache} data/license-store-cache.zstd
|
||||
'';
|
||||
};
|
||||
|
||||
formatter = nixpkgs-fmt;
|
||||
|
||||
packages.default = buildPackage (args // {
|
||||
doCheck = false;
|
||||
postInstall = ''
|
||||
installManPage artifacts/nix-init.1
|
||||
installShellCompletion artifacts/nix-init.{bash,fish} --zsh artifacts/_nix-init
|
||||
'';
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user