mirror of
https://codeberg.org/icewind/mill-scale.git
synced 2026-06-03 09:54:19 +02:00
This commit is contained in:
parent
c71caa3c2b
commit
77800944c2
3 changed files with 34 additions and 23 deletions
17
cargo-meta.nix
Normal file
17
cargo-meta.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
{ lib }:
|
||||||
|
let
|
||||||
|
inherit (builtins) isAttrs attrNames;
|
||||||
|
inherit (lib) assertMsg remove;
|
||||||
|
in
|
||||||
|
cargoToml: rec {
|
||||||
|
tomlPackage = cargoToml.package or cargoToml.workspace.package;
|
||||||
|
hasMsrv = tomlPackage ? rust-version;
|
||||||
|
hasWorkspace = tomlPackage ? workspace;
|
||||||
|
hasFeatures = cargoToml ? features && isAttrs cargoToml.features;
|
||||||
|
features = cargoToml.features or { };
|
||||||
|
defaultFeatures = features.default or [ ];
|
||||||
|
nonDefaultFeatures = remove "default" (attrNames features);
|
||||||
|
hasNonDefaultFeatures = hasFeatures && (defaultFeatures != nonDefaultFeatures);
|
||||||
|
hasDefaultFeatures = cargoToml ? features && cargoToml.features ? default;
|
||||||
|
msrv = assert assertMsg hasMsrv ''"rust-version" not set in Cargo.toml''; tomlPackage.rust-version;
|
||||||
|
}
|
||||||
24
flake.lock
generated
24
flake.lock
generated
|
|
@ -2,11 +2,11 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"crane": {
|
"crane": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1730060262,
|
"lastModified": 1733688869,
|
||||||
"narHash": "sha256-RMgSVkZ9H03sxC+Vh4jxtLTCzSjPq18UWpiM0gq6shQ=",
|
"narHash": "sha256-KrhxxFj1CjESDrL5+u/zsVH0K+Ik9tvoac/oFPoxSB8=",
|
||||||
"owner": "ipetkov",
|
"owner": "ipetkov",
|
||||||
"repo": "crane",
|
"repo": "crane",
|
||||||
"rev": "498d9f122c413ee1154e8131ace5a35a80d8fa76",
|
"rev": "604637106e420ad99907cae401e13ab6b452e7d9",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -20,11 +20,11 @@
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1730119299,
|
"lastModified": 1733748390,
|
||||||
"narHash": "sha256-dqI461waVG9UGhThjB1dMo+D2ykeiGIvthWE/belGS8=",
|
"narHash": "sha256-UqTETFjEkwu7WAtlRJPoM7rZpkMnvM9LeupKes+Breg=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "flakelight",
|
"repo": "flakelight",
|
||||||
"rev": "566fbde51a8129aa6e011988ca7eee1a80525da4",
|
"rev": "3b6d1f0651f7cf4f4dc17c45e12782778a11520b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -35,11 +35,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1729880355,
|
"lastModified": 1733581040,
|
||||||
"narHash": "sha256-RP+OQ6koQQLX5nw0NmcDrzvGL8HDLnyXt/jHhL1jwjM=",
|
"narHash": "sha256-Qn3nPMSopRQJgmvHzVqPcE3I03zJyl8cSbgnnltfFDY=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "18536bf04cd71abd345f9579158841376fdd0c5a",
|
"rev": "22c3f2cf41a0e70184334a958e6b124fb0ce3e01",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -64,11 +64,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1731897198,
|
"lastModified": 1733884434,
|
||||||
"narHash": "sha256-Ou7vLETSKwmE/HRQz4cImXXJBr/k9gp4J4z/PF8LzTE=",
|
"narHash": "sha256-8GXR9kC07dyOIshAyfZhG11xfvBRSZzYghnZ2weOKJU=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "0be641045af6d8666c11c2c40e45ffc9667839b5",
|
"rev": "d0483df44ddf0fd1985f564abccbe568e020ddf2",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
|
|
@ -5,22 +5,16 @@
|
||||||
{ lib, src, config, flakelight, inputs, ... }:
|
{ lib, src, config, flakelight, inputs, ... }:
|
||||||
let
|
let
|
||||||
inherit (builtins) elem readFile pathExists isAttrs attrNames match any;
|
inherit (builtins) elem readFile pathExists isAttrs attrNames match any;
|
||||||
inherit (lib) map mkDefault mkIf mkMerge mkOption warnIf assertMsg optionalAttrs types optionalString genAttrs hasInfix intersectLists foldl attrVals remove;
|
inherit (lib) map mkDefault mkIf mkMerge mkOption warnIf assertMsg optionalAttrs types optionalString genAttrs hasInfix intersectLists foldl attrVals;
|
||||||
inherit (lib.fileset) fileFilter toSource unions;
|
inherit (lib.fileset) fileFilter toSource unions;
|
||||||
inherit (flakelight.types) fileset function optFunctionTo;
|
inherit (flakelight.types) fileset function optFunctionTo;
|
||||||
|
|
||||||
filteredSrc = toSource { root = src; fileset = unions (config.extraPaths ++ [ config.fileset ]); };
|
filteredSrc = toSource { root = src; fileset = unions (config.extraPaths ++ [ config.fileset ]); };
|
||||||
|
|
||||||
cargoToml = fromTOML (readFile (src + /Cargo.toml));
|
cargoToml = fromTOML (readFile (src + /Cargo.toml));
|
||||||
tomlPackage = cargoToml.package or cargoToml.workspace.package;
|
cargoMeta = (import ./cargo-meta.nix { inherit lib; }) cargoToml;
|
||||||
hasMsrv = tomlPackage ? rust-version;
|
inherit (cargoMeta) tomlPackage hasMsrv hasWorkspace hasFeatures hasNonDefaultFeatures hasDefaultFeatures msrv;
|
||||||
hasWorkspace = tomlPackage ? workspace;
|
|
||||||
hasFeatures = cargoToml ? features && isAttrs cargoToml.features;
|
|
||||||
features = cargoToml.features or {};
|
|
||||||
defaultFeatures = features.default or [];
|
|
||||||
nonDefaultFeatures = remove "default" (attrNames features);
|
|
||||||
hasNonDefaultFeatures = hasFeatures && (defaultFeatures != nonDefaultFeatures);
|
|
||||||
hasDefaultFeatures = cargoToml ? features && cargoToml.features ? default;
|
|
||||||
msrv = assert assertMsg hasMsrv ''"rust-version" not set in Cargo.toml''; tomlPackage.rust-version;
|
|
||||||
maybeWorkspace = optionalString hasWorkspace "--workspace";
|
maybeWorkspace = optionalString hasWorkspace "--workspace";
|
||||||
hasExamples = pathExists (src + /examples);
|
hasExamples = pathExists (src + /examples);
|
||||||
hasDefaultPackage = pathExists (src + /nix/package.nix);
|
hasDefaultPackage = pathExists (src + /nix/package.nix);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue