mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-09 20:20:29 +00:00
Migrate from crane back to buildRustPackage
Some checks are pending
Some checks are pending
This commit is contained in:
parent
c148dca438
commit
e07949378c
4 changed files with 35 additions and 36 deletions
10
.github/workflows/build_test.yml
vendored
10
.github/workflows/build_test.yml
vendored
|
@ -64,6 +64,16 @@ jobs:
|
||||||
run: cargo test
|
run: cargo test
|
||||||
env:
|
env:
|
||||||
SQLX_OFFLINE: "true"
|
SQLX_OFFLINE: "true"
|
||||||
|
checkDeps:
|
||||||
|
name: Check dependency hash
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: cachix/install-nix-action@v27
|
||||||
|
with:
|
||||||
|
github_access_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Build dependencies
|
||||||
|
run: nix build .#youmubot.cargoDeps --option substituters "https://cache.nixos.org" --option extra-substituters ""
|
||||||
build:
|
build:
|
||||||
name: Build
|
name: Build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
16
flake.lock
generated
16
flake.lock
generated
|
@ -1,20 +1,5 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"crane": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1734744351,
|
|
||||||
"narHash": "sha256-fN9npuZHHHzDVr1wuKoh/TheHkerDaLB9l4vj/48Exg=",
|
|
||||||
"owner": "ipetkov",
|
|
||||||
"repo": "crane",
|
|
||||||
"rev": "a83a48a62640517588c3d137c948ed034706363c",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "ipetkov",
|
|
||||||
"repo": "crane",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"flake-utils": {
|
"flake-utils": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
|
@ -51,7 +36,6 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"crane": "crane",
|
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"rust-overlay": "rust-overlay"
|
"rust-overlay": "rust-overlay"
|
||||||
|
|
12
flake.nix
12
flake.nix
|
@ -2,7 +2,6 @@
|
||||||
description = "A discord bot for Dự Tuyển Tổng Hợp server";
|
description = "A discord bot for Dự Tuyển Tổng Hợp server";
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
crane.url = "github:ipetkov/crane";
|
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
rust-overlay = {
|
rust-overlay = {
|
||||||
url = "github:oxalica/rust-overlay";
|
url = "github:oxalica/rust-overlay";
|
||||||
|
@ -14,9 +13,6 @@
|
||||||
extra-trusted-public-keys = [ "natsukagami.cachix.org-1:3U6GV8i8gWEaXRUuXd2S4ASfYgdl2QFPWg4BKPbmYiQ=" ];
|
extra-trusted-public-keys = [ "natsukagami.cachix.org-1:3U6GV8i8gWEaXRUuXd2S4ASfYgdl2QFPWg4BKPbmYiQ=" ];
|
||||||
};
|
};
|
||||||
outputs = { self, nixpkgs, flake-utils, ... }@inputs:
|
outputs = { self, nixpkgs, flake-utils, ... }@inputs:
|
||||||
let
|
|
||||||
rustVersion = "1.83.0";
|
|
||||||
in
|
|
||||||
flake-utils.lib.eachDefaultSystem
|
flake-utils.lib.eachDefaultSystem
|
||||||
(system:
|
(system:
|
||||||
let
|
let
|
||||||
|
@ -24,11 +20,9 @@
|
||||||
{
|
{
|
||||||
inherit system; overlays = [ (import inputs.rust-overlay) ];
|
inherit system; overlays = [ (import inputs.rust-overlay) ];
|
||||||
};
|
};
|
||||||
craneLib = (inputs.crane.mkLib pkgs).overrideToolchain (p: p.rust-bin.stable.${rustVersion}.default);
|
|
||||||
# craneLib = inputs.crane.mkLib pkgs;
|
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
packages.youmubot = pkgs.callPackage ./package.nix { inherit craneLib; };
|
packages.youmubot = pkgs.callPackage ./package.nix { };
|
||||||
|
|
||||||
defaultPackage = packages.youmubot;
|
defaultPackage = packages.youmubot;
|
||||||
|
|
||||||
|
@ -54,9 +48,7 @@
|
||||||
};
|
};
|
||||||
}) // {
|
}) // {
|
||||||
overlays.default = final: prev: {
|
overlays.default = final: prev: {
|
||||||
youmubot = final.callPackage ./package.nix {
|
youmubot = final.callPackage ./package.nix { };
|
||||||
craneLib = (inputs.crane.mkLib final).overrideToolchain (p: p.rust-bin.stable.${rustVersion}.default);
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
# module
|
# module
|
||||||
nixosModules.default = import ./module.nix;
|
nixosModules.default = import ./module.nix;
|
||||||
|
|
33
package.nix
33
package.nix
|
@ -1,27 +1,41 @@
|
||||||
{ craneLib
|
{ rustPlatform
|
||||||
, lib
|
, lib
|
||||||
, stdenv
|
, stdenv
|
||||||
, pkg-config
|
, pkg-config
|
||||||
, openssl
|
, openssl
|
||||||
|
|
||||||
, enableCodeforces ? true
|
, enableCodeforces ? false
|
||||||
, enableOsu ? true
|
, enableOsu ? true
|
||||||
, ...
|
, ...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
customizeFeatures = !(enableCodeforces && enableOsu);
|
customizeFeatures = !(enableCodeforces && enableOsu);
|
||||||
featureFlags = lib.optionals customizeFeatures (
|
|
||||||
[ "--no-default-features" "--features=core" ]
|
|
||||||
++ lib.optional enableCodeforces "--features=codeforces"
|
|
||||||
++ lib.optional enableOsu "--features=osu"
|
|
||||||
);
|
|
||||||
in
|
in
|
||||||
craneLib.buildPackage {
|
rustPlatform.buildRustPackage {
|
||||||
pname = "youmubot";
|
pname = "youmubot";
|
||||||
version = "0.1.0";
|
version = "0.1.0";
|
||||||
|
|
||||||
src = ./.;
|
src = ./.;
|
||||||
cargoExtraArgs = builtins.concatStringsSep " " ([ "--locked" "--package youmubot" ] ++ featureFlags);
|
cargoLock = {
|
||||||
|
lockFile = ./Cargo.lock;
|
||||||
|
outputHashes = {
|
||||||
|
"poise-0.6.1" = "sha256-44pPe02JJ97GEpzAXdQmDq/9bb4KS9G7ZFVlBRC6EYs=";
|
||||||
|
"rosu-v2-0.9.0" = "sha256-dx0EwqqgkLaHwCPHyn5vMkhZ2NZcahH5SACFcsJKP1E=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
buildNoDefaultFeatures = customizeFeatures;
|
||||||
|
buildFeatures = lib.optionals customizeFeatures (
|
||||||
|
[ "core" ]
|
||||||
|
++ lib.optional enableCodeforces "codeforces"
|
||||||
|
++ lib.optional enableOsu "osu"
|
||||||
|
);
|
||||||
|
|
||||||
|
cargoBuildFlags = [
|
||||||
|
"--locked"
|
||||||
|
"--package"
|
||||||
|
"youmubot"
|
||||||
|
];
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
openssl
|
openssl
|
||||||
|
@ -33,4 +47,3 @@ craneLib.buildPackage {
|
||||||
|
|
||||||
SQLX_OFFLINE = "true";
|
SQLX_OFFLINE = "true";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue