chore: Add nix build files

This commit is contained in:
Arne Dußin 2024-08-22 12:48:30 +02:00
commit 45c3e91560
4 changed files with 121 additions and 0 deletions

17
derivation.nix Normal file
View file

@ -0,0 +1,17 @@
{
lib,
pkgs,
rustPlatform,
name,
}:
(rustPlatform.buildRustPackage {
inherit name;
nativeBuildInputs = with pkgs; [
];
src = lib.cleanSource ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
})

48
flake.lock generated Normal file
View file

@ -0,0 +1,48 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1724322575,
"narHash": "sha256-kRYwAdYsaICNb2WYcWtBFG6caSuT0v/vTAyR8ap0IR0=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "2a02822b466ffb9f1c02d07c5dd6b96d08b56c6b",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "release-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1724293269,
"narHash": "sha256-x/XhOAszT/ejditCHUtGOjQcVg2AQhrC/QVew3i7kTI=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "6dc6d34a3a217457d7044dcce32b6d537480a6a1",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

53
flake.nix Normal file
View file

@ -0,0 +1,53 @@
{
description = "Light control over the network";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/release-24.05";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, rust-overlay }:
let
inherit (nixpkgs) lib;
systems = ["x86_64-linux"];
systemClosure = attrs:
builtins.foldl' (acc: system:
lib.recursiveUpdate acc (attrs system)) {}
systems;
in
systemClosure (system:
let
inherit ((builtins.fromTOML (builtins.readFile ./Cargo.toml)).package) name;
pkgs = import nixpkgs {
inherit system;
overlays = [(import rust-overlay)];
};
toolchain = (
pkgs.rust-bin.fromRustupToolchainFile ./rust_toolchain.toml
);
rustPlatform = pkgs.makeRustPlatform
{
rustc = toolchain;
cargo = toolchain;
};
libPath = with pkgs; lib.makeLibraryPath [
];
in
{
packages.${system}.default = pkgs.callPackage ./derivation.nix {
inherit name rustPlatform;
};
devShells.${system}.default = pkgs.mkShell {
buildInputs = with pkgs; [
toolchain
clang
llvmPackages.bintools
];
LD_LIBRARY_PATH = libPath;
};
});
}

3
rust_toolchain.toml Normal file
View file

@ -0,0 +1,3 @@
[toolchain]
channel = "nightly-2024-06-15"
components = ["rust-src", "rust-analyzer"]