nix: refactor
This commit is contained in:
parent
0f5a523505
commit
7bf662ab7e
26
default.nix
Normal file
26
default.nix
Normal file
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
pkgs,
|
||||
inputs,
|
||||
makeRustPlatform,
|
||||
system,
|
||||
}: let
|
||||
toolchain = inputs.fenix.packages.${system}.minimal.toolchain;
|
||||
in
|
||||
(makeRustPlatform {
|
||||
cargo = toolchain;
|
||||
rustc = toolchain;
|
||||
})
|
||||
.buildRustPackage {
|
||||
pname = "forcebot_rs";
|
||||
version = "v1.0";
|
||||
|
||||
src = ./.;
|
||||
cargoLock = {
|
||||
lockFile = ./.;
|
||||
};
|
||||
|
||||
nativeBuildInputs = with pkgs; [pkg-config];
|
||||
buildInputs = with pkgs; [openssl];
|
||||
|
||||
doCheck = false;
|
||||
}
|
53
flake.lock
53
flake.lock
|
@ -1,25 +1,5 @@
|
|||
{
|
||||
"nodes": {
|
||||
"crane": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1712513517,
|
||||
"narHash": "sha256-VuLm5tTMqfS82NZAsNfsW7U+pTZ1+GcOU7gYR/Fb1Z4=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "9caad1eb0c69a13ee6467035353b71a76c85ea53",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"fenix": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs",
|
||||
|
@ -40,24 +20,6 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1711703276,
|
||||
|
@ -92,10 +54,9 @@
|
|||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"crane": "crane",
|
||||
"fenix": "fenix",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"systems": "systems"
|
||||
}
|
||||
},
|
||||
"rust-analyzer-src": {
|
||||
|
@ -117,16 +78,16 @@
|
|||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"lastModified": 1689347949,
|
||||
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"repo": "default-linux",
|
||||
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"repo": "default-linux",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
|
|
73
flake.nix
73
flake.nix
|
@ -1,53 +1,47 @@
|
|||
{
|
||||
description = "A basic flake";
|
||||
|
||||
inputs = {
|
||||
systems.url = "github:nix-systems/default-linux";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
fenix.url = "github:nix-community/fenix/monthly";
|
||||
|
||||
crane = {
|
||||
url = "github:ipetkov/crane";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
systems,
|
||||
nixpkgs,
|
||||
crane,
|
||||
fenix,
|
||||
flake-utils,
|
||||
...
|
||||
} @ inputs:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system overlays;
|
||||
};
|
||||
|
||||
}: let
|
||||
eachSystem = nixpkgs.lib.genAttrs (import systems);
|
||||
pkgsFor = eachSystem (system:
|
||||
import nixpkgs {
|
||||
localSystem.system = system;
|
||||
overlays = [fenix.overlays.default];
|
||||
|
||||
craneLib = crane.lib.${system};
|
||||
forcebot_rs = craneLib.buildPackage {
|
||||
src = craneLib.cleanCargoSource (craneLib.path ./.);
|
||||
strictDeps = true;
|
||||
|
||||
nativeBuildInputs = [pkgs.pkg-config];
|
||||
buildInputs = [pkgs.openssl];
|
||||
};
|
||||
});
|
||||
in {
|
||||
checks = {
|
||||
inherit forcebot_rs;
|
||||
packages = eachSystem (system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in {
|
||||
default = pkgsFor.${system}.rustPlatform.buildRustPackage {
|
||||
pname = "forcebot_rs";
|
||||
version = "v0.1";
|
||||
|
||||
src = self;
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
};
|
||||
|
||||
packages.default = forcebot_rs;
|
||||
nativeBuildInputs = with pkgs; [pkg-config];
|
||||
buildInputs = with pkgs; [openssl];
|
||||
|
||||
apps.default = flake-utils.lib.mkApp {
|
||||
drv = forcebot_rs;
|
||||
doCheck = false;
|
||||
};
|
||||
|
||||
devShells.default = craneLib.devShell {
|
||||
checks = self.checks.${system};
|
||||
packages = with pkgs; [
|
||||
});
|
||||
devShells = eachSystem (system: {
|
||||
default = pkgsFor.${system}.mkShell {
|
||||
packages = with pkgsFor.${system}; [
|
||||
nil
|
||||
alejandra
|
||||
rust-analyzer-nightly
|
||||
|
@ -60,14 +54,7 @@
|
|||
])
|
||||
];
|
||||
};
|
||||
nixosModules.forcebot_rs = import ./nix/module.nix;
|
||||
nixosModules.default = self.nixosModules.forcebot_rs;
|
||||
RUST_BACKTRACE = 1;
|
||||
RUST_SRC_PATH = "${fenix.packages.${system}.complete.rust-src}/lib/rustlib/src/rust/library";
|
||||
})
|
||||
// {
|
||||
overlays.default = final: prev: {
|
||||
forcebot_rs = self.packages."${final.system}".default;
|
||||
};
|
||||
});
|
||||
nixosModules.default = import ./nix/module.nix;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue