Added nix stuff
This commit is contained in:
parent
40925f1f31
commit
48298b3190
5 changed files with 191 additions and 0 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
@ -0,0 +1 @@
|
|||
use flake
|
51
default.nix
Normal file
51
default.nix
Normal file
|
@ -0,0 +1,51 @@
|
|||
# (import (
|
||||
# fetchTarball {
|
||||
# url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz";
|
||||
# sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; }
|
||||
# ) {
|
||||
# src = ./.;
|
||||
# }).defaultNix
|
||||
{ lib
|
||||
, naersk
|
||||
, stdenv
|
||||
, clangStdenv
|
||||
, hostPlatform
|
||||
, targetPlatform
|
||||
, pkg-config
|
||||
, libiconv
|
||||
, rustfmt
|
||||
, cargo
|
||||
, rustc
|
||||
, openssl
|
||||
}:
|
||||
let cargoToml = (builtins.fromTOML (builtins.readFile ./Cargo.toml));
|
||||
in
|
||||
naersk.lib."${targetPlatform.system}".buildPackage rec {
|
||||
src = ./.;
|
||||
|
||||
buildInputs = [
|
||||
rustfmt
|
||||
pkg-config
|
||||
cargo
|
||||
rustc
|
||||
libiconv
|
||||
openssl
|
||||
];
|
||||
|
||||
checkInputs = [ cargo rustc ];
|
||||
doCheck = true;
|
||||
|
||||
CARGO_BUILD_INCREMENTAL = "false";
|
||||
RUST_BACKTRACE = "full";
|
||||
copyLibs = true;
|
||||
|
||||
name = cargoToml.package.name;
|
||||
version = cargoToml.package.version;
|
||||
|
||||
meta = with lib; {
|
||||
description = cargoToml.package.description;
|
||||
homepage = cargoToml.package.homepage;
|
||||
license = with licenses; [ mit ];
|
||||
maintainers = with maintainers; [ ];
|
||||
};
|
||||
}
|
60
flake.lock
Normal file
60
flake.lock
Normal file
|
@ -0,0 +1,60 @@
|
|||
{
|
||||
"nodes": {
|
||||
"naersk": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1636968630,
|
||||
"narHash": "sha256-/C8OVV8mo9M9MgQprHo4A5bM9waWMsw6PI4hb4DnGaA=",
|
||||
"owner": "nmattia",
|
||||
"repo": "naersk",
|
||||
"rev": "55c4c0288ea3f115b5dd73af88052c4712994746",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nmattia",
|
||||
"ref": "master",
|
||||
"repo": "naersk",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1636976544,
|
||||
"narHash": "sha256-9ZmdyoRz4Qu8bP5BKR1T10YbzcB9nvCeQjOEw2cRKR0=",
|
||||
"path": "/nix/store/ha4ld6wd29q1igjmhjdvkvbxpxxxxbxf-source",
|
||||
"rev": "931ab058daa7e4cd539533963f95e2bb0dbd41e6",
|
||||
"type": "path"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1637186689,
|
||||
"narHash": "sha256-NU7BhgnwA/3ibmCeSzFK6xGi+Bari9mPfn+4cBmyEjw=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "7fad01d9d5a3f82081c00fb57918d64145dc904c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"naersk": "naersk",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
76
flake.nix
Normal file
76
flake.nix
Normal file
|
@ -0,0 +1,76 @@
|
|||
{
|
||||
|
||||
inputs = {
|
||||
naersk.url = "github:nmattia/naersk/master";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, naersk }:
|
||||
let
|
||||
cargoToml = (builtins.fromTOML (builtins.readFile ./Cargo.toml));
|
||||
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
|
||||
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
|
||||
in
|
||||
{
|
||||
overlay = final: prev: {
|
||||
"${cargoToml.package.name}" = final.callPackage ./. { inherit naersk; };
|
||||
};
|
||||
|
||||
packages = forAllSystems (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
self.overlay
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
"${cargoToml.package.name}" = pkgs."${cargoToml.package.name}";
|
||||
});
|
||||
|
||||
defaultPackage = forAllSystems (system: (import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ self.overlay ];
|
||||
})."${cargoToml.package.name}");
|
||||
|
||||
checks = forAllSystems (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ self.overlay ];
|
||||
};
|
||||
in
|
||||
{
|
||||
format = pkgs.runCommand "check-format"
|
||||
{
|
||||
buildInputs = with pkgs; [ rustfmt cargo ];
|
||||
} ''
|
||||
${pkgs.rustfmt}/bin/cargo-fmt fmt --manifest-path ${./.}/Cargo.toml -- --check
|
||||
${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt --check ${./.}
|
||||
touch $out
|
||||
'';
|
||||
"${cargoToml.package.name}" = pkgs."${cargoToml.package.name}";
|
||||
}
|
||||
);
|
||||
|
||||
devShell = forAllSystems (system:
|
||||
let pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ self.overlay ];
|
||||
};
|
||||
in
|
||||
pkgs.mkShell {
|
||||
inputsFrom = with pkgs; [
|
||||
pkgs."${cargoToml.package.name}"
|
||||
];
|
||||
buildInputs = with pkgs; [
|
||||
rustfmt
|
||||
nixpkgs-fmt
|
||||
];
|
||||
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
}
|
3
rust-toolchain.toml
Normal file
3
rust-toolchain.toml
Normal file
|
@ -0,0 +1,3 @@
|
|||
[toolchain]
|
||||
channel = "stable"
|
||||
components = [ "rustfmt", "clippy" ]
|
Loading…
Reference in a new issue