nix build for the backend

This commit is contained in:
Cadey Ratio 2020-11-04 15:50:28 -05:00
parent 790dbbfe55
commit 36e025f518
4 changed files with 38 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
/backend/target
mi.db
result*

20
backend/default.nix Normal file
View File

@ -0,0 +1,20 @@
{ sources ? import ../nix/sources.nix, pkgs ? import sources.nixpkgs { } }:
with pkgs;
let
rust = import ../nix/rust.nix { inherit sources; };
naersk = pkgs.callPackage sources.naersk {
rustc = rust;
cargo = rust;
};
src = builtins.filterSource
(path: type: type != "directory" || builtins.baseNameOf path != "target")
./.;
in {
backend = naersk.buildPackage {
name = "mi_backend";
inherit src;
buildInputs = with pkgs; [ openssl pkg-config sqlite libsodium ];
SODIUM_USE_PKG_CONFIG = "1";
SODIUM_SHARED = "1";
};
}

View File

@ -1,4 +1,16 @@
{
"naersk": {
"branch": "master",
"description": "Build rust crates in Nix. No configuration, no code generation, no IFD. Sandbox friendly.",
"homepage": "",
"owner": "nmattia",
"repo": "naersk",
"rev": "d645515b7159c75087b3d51f23a68047c2c09699",
"sha256": "16hjyf1nkvwhb5nw989qhm3gdlim5wfw515bnvxpix5ff8jfbh9x",
"type": "tarball",
"url": "https://github.com/nmattia/naersk/archive/d645515b7159c75087b3d51f23a68047c2c09699.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"niv": {
"branch": "master",
"description": "Easy dependency management for Nix projects",

View File

@ -11,9 +11,9 @@ in pkgs.mkShell rec {
openssl
cmake
zlib
libgit2
diesel-cli
sqlite
libsodium
cargo-watch
# elm
@ -29,4 +29,8 @@ in pkgs.mkShell rec {
DATABASE_URL = "./mi.db";
ROCKET_DATABASES = ''{ main_data = { url = "${DATABASE_URL}" } }'';
RUST_LOG = "info";
# libsodium-sys
SODIUM_USE_PKG_CONFIG = "1";
SODIUM_SHARED = "1";
}