1
Fork 0
mirror of https://github.com/RGBCube/Site synced 2025-08-02 14:07:47 +00:00

Switch to crane

This commit is contained in:
RGBCube 2023-12-30 15:17:13 +03:00
parent 80b2066222
commit 3950f840ad
No known key found for this signature in database
5 changed files with 119 additions and 2806 deletions

1
.gitattributes vendored
View file

@ -1 +0,0 @@
Cargo.nix linguist-language=GeneratedFileInvalidLanguageName

1
.gitignore vendored
View file

@ -2,7 +2,6 @@
!src/ !src/
!.gitattributes
!.gitignore !.gitignore
!*.css !*.css

2701
Cargo.nix

File diff suppressed because it is too large Load diff

134
flake.lock generated
View file

@ -1,59 +1,59 @@
{ {
"nodes": { "nodes": {
"cargo2nix": { "advisory-db": {
"flake": false,
"locked": {
"lastModified": 1703184318,
"narHash": "sha256-vx2/goSpegxiFc7e1jKNHzBkhnsIQjriV4GZLaVe17M=",
"owner": "rustsec",
"repo": "advisory-db",
"rev": "a5fb72de318a74eb69a2c241c0e46705684a35d0",
"type": "github"
},
"original": {
"owner": "rustsec",
"repo": "advisory-db",
"type": "github"
}
},
"crane": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1703439018,
"narHash": "sha256-VT+06ft/x3eMZ1MJxWzQP3zXFGcrxGo5VR2rB7t88hs=",
"owner": "ipetkov",
"repo": "crane",
"rev": "afdcd41180e3dfe4dac46b5ee396e3b12ccc967a",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"fenix": {
"inputs": { "inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
], ],
"rust-overlay": "rust-overlay" "rust-analyzer-src": []
}, },
"locked": { "locked": {
"lastModified": 1699033427, "lastModified": 1703917281,
"narHash": "sha256-OVtd5IPbb4NvHibN+QvMrMxq7aZN5GFoINZSAXKjUdA=", "narHash": "sha256-fmhKbANx4PLG/Rt/QvKBsAdmyl8vAGQfROtccenMonw=",
"owner": "cargo2nix", "owner": "nix-community",
"repo": "cargo2nix", "repo": "fenix",
"rev": "c6f33051f412352f293e738cc8da6fd4c457080f", "rev": "8ad4353759945bec3a5f4bfc53efe818bb41e12a",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "cargo2nix", "owner": "nix-community",
"repo": "cargo2nix", "repo": "fenix",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github" "type": "github"
} }
}, },
@ -75,51 +75,13 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"cargo2nix": "cargo2nix", "advisory-db": "advisory-db",
"crane": "crane",
"fenix": "fenix",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"tools": "tools" "tools": "tools"
} }
}, },
"rust-overlay": {
"inputs": {
"flake-utils": [
"cargo2nix",
"flake-utils"
],
"nixpkgs": [
"cargo2nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1697336027,
"narHash": "sha256-ctmmw7j4liyfSh63v9rdFZeIoNYCkCvgqvtEOB7KhX8=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "e494404d36a41247987eeb1bfc2f1ca903e97764",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"tools": { "tools": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [

View file

@ -12,36 +12,90 @@
}; };
tools = { tools = {
url = "github:RGBCube/FlakeTools"; url = "github:RGBCube/FlakeTools";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
cargo2nix = { crane = {
url = "github:cargo2nix/cargo2nix"; url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.rust-analyzer-src.follows = "";
};
advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
};
}; };
outputs = { self, nixpkgs, tools, cargo2nix } @ inputs: tools.eachDefaultLinuxArch (system: let outputs = { self, nixpkgs, tools, fenix, advisory-db, ... } @ inputs: tools.eachDefaultLinuxArch (system: let
pkgs = import nixpkgs { lib = nixpkgs.lib;
inherit system; pkgs = import nixpkgs { inherit system; };
overlays = [ cargo2nix.overlays.default ]; toolchain = fenix.packages.${system}.complete.withComponents [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
];
crane = inputs.crane.lib.${system}.overrideToolchain toolchain;
cssFilter = path: type: builtins.match ".*css$" path != null;
jsFilter = path: type: builtins.match ".*js$" path != null;
assetFilter = path: type: type == "directory" && builtins.match "^assets.*" path != null;
src = lib.cleanSourceWith {
src = crane.path ./.;
filter = path: type: (crane.filterCargoSources path type)
|| (cssFilter path type)
|| (jsFilter path type)
|| (assetFilter path type);
}; };
rustPackages = pkgs.rustBuilder.makePackageSet { srcArgs = {
rustVersion = "1.76.0"; inherit src;
rustChannel = "nightly";
rustProfile = "minimal";
packageFun = import ./Cargo.nix;
}; };
commonArgs = srcArgs // {
strictDeps = true;
};
cargoArtifacts = crane.buildDepsOnly commonArgs;
site = crane.buildPackage (commonArgs // {
inherit cargoArtifacts;
});
in { in {
devShells.${system}.default = rustPackages.workspaceShell { devShells.${system}.default = crane.devShell {};
packages = [ cargo2nix.packages.${system}.default ];
checks.${system} = {
inherit site;
clippy = crane.cargoClippy (commonArgs // {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});
fmt = crane.cargoFmt srcArgs;
audit = crane.cargoAudit (srcArgs // {
inherit advisory-db;
});
deny = crane.cargoDeny srcArgs;
}; };
packages = rec { packages.${system} = {
site = rustPackages.workspace.site {}; inherit site;
default = site; default = site;
}; };