Merge pull request #499 from LnL7/crate2nix

use crate2nix
This commit is contained in:
Daiderd Jordan 2020-05-24 20:27:22 +02:00 committed by GitHub
commit 65699e5555
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 5287 additions and 7718 deletions

6199
Cargo.nix

File diff suppressed because it is too large Load diff

View file

@ -214,8 +214,8 @@ Currently there is no easy way to set up a test instance of ofborg. If `cargo
check` and `cargo test` both succeed, feel free to Pull Request your changes. check` and `cargo test` both succeed, feel free to Pull Request your changes.
Make sure to format your code with `cargo fmt` and check for additional warnings Make sure to format your code with `cargo fmt` and check for additional warnings
with `cargo clippy`. If you added, removed, or updated the dependencies, also be with `cargo clippy`. If you added, removed, or updated the dependencies, also be
sure to update Carnix by running sure to update Cargo.nix by running
[`./nix/update-carnix.sh`](./nix/update-carnix.sh). [`./nix/update-crates.sh`](./nix/update-crates.sh).
To disable warnings as errors, run your command with an empty `RUSTFLAGS`. For To disable warnings as errors, run your command with an empty `RUSTFLAGS`. For
example: example:

4
crate-hashes.json Normal file
View file

@ -0,0 +1,4 @@
{
"amqp 0.1.0 (git+https://github.com/grahamc/rust-amqp.git#f9aec2f40aef69a459f26003ce47048f8e2a08d1)": "09k6fl7l0rcwilnckdfv3smiv1ilrwi1jxmrrkjwbrj64lky3jdy",
"hubcaps 0.3.16 (git+https://github.com/grahamc/hubcaps.git#5e656ba35ab4ee74aa72b3b5c3a62e1bf351ff6a)": "1p7rn8y71fjwfag65437gz7a56pysz9n69smaknvblyxpjdzmh4d"
}

View file

@ -1,197 +0,0 @@
aho-corasick-0.5.3
aho-corasick-0.7.10
amq-proto-0.1.0
amq-protocol-6.0.0-rc3
amq-protocol-codegen-6.0.0-rc3
amq-protocol-tcp-6.0.0-rc3
amq-protocol-types-6.0.0-rc3
amq-protocol-uri-6.0.0-rc3
ansi_term-0.11.0
antidote-1.0.0
arrayvec-0.5.1
async-std-1.5.0
async-task-1.3.1
async-task-3.0.0
autocfg-0.1.1
autocfg-1.0.0
backtrace-0.3.13
backtrace-sys-0.1.28
base64-0.9.3
base64-0.10.0
bit-vec-0.4.4
bitflags-0.9.1
bitflags-1.2.1
block-buffer-0.7.3
block-padding-0.1.5
byte-tools-0.3.1
byteorder-0.5.3
byteorder-1.2.7
cc-1.0.28
cfg-if-0.1.10
chrono-0.4.6
cloudabi-0.0.3
cookie-factory-0.3.1
core-foundation-0.2.3
core-foundation-0.7.0
core-foundation-sys-0.2.3
core-foundation-sys-0.7.0
crossbeam-channel-0.4.2
crossbeam-deque-0.7.3
crossbeam-epoch-0.8.2
crossbeam-utils-0.7.2
digest-0.8.1
doc-comment-0.3.3
either-1.5.0
enum_primitive-0.1.1
env_logger-0.3.5
error-chain-0.10.0
fake-simd-0.1.2
foreign-types-0.3.2
foreign-types-shared-0.1.1
frank_jwt-3.1.0
fs2-0.4.3
fuchsia-zircon-0.3.3
fuchsia-zircon-sys-0.3.3
futures-core-0.3.4
futures-io-0.3.4
futures-timer-2.0.2
generic-array-0.12.3
getrandom-0.1.14
handlebars-3.0.1
hermit-abi-0.1.12
httparse-1.3.3
hyper-0.10.15
hyper-native-tls-0.2.4
idna-0.1.5
idna-0.2.0
iovec-0.1.4
itoa-0.4.3
kernel32-sys-0.2.2
kv-log-macro-1.0.4
language-tags-0.2.2
lapin-1.0.0-beta4
lazy_static-0.2.11
lazy_static-1.4.0
lexical-core-0.7.4
libc-0.2.69
linked-hash-map-0.4.2
lock_api-0.3.4
log-0.3.8
log-0.4.8
lru-cache-0.1.1
maplit-1.0.2
matchers-0.0.1
matches-0.1.8
maybe-uninit-2.0.0
md5-0.3.8
memchr-0.1.11
memchr-2.3.3
memoffset-0.5.4
mime-0.2.6
mio-0.6.21
mio-0.7.0
mio-uds-0.6.7
miow-0.2.1
miow-0.3.3
native-tls-0.1.5
native-tls-0.2.4
net2-0.2.33
nom-4.1.1
nom-6.0.0-alpha1
ntapi-0.3.3
num-integer-0.1.39
num-traits-0.1.43
num-traits-0.2.6
num_cpus-1.13.0
once_cell-1.3.1
opaque-debug-0.2.3
openssl-0.9.24
openssl-0.10.29
openssl-probe-0.1.2
openssl-sys-0.9.55
parking_lot-0.10.2
parking_lot_core-0.7.2
percent-encoding-1.0.1
percent-encoding-2.1.0
pest-2.1.3
pest_derive-2.1.0
pest_generator-2.1.3
pest_meta-2.1.3
pin-project-lite-0.1.4
pin-utils-0.1.0
pinky-swear-4.0.0
pkg-config-0.3.14
ppv-lite86-0.2.6
proc-macro2-1.0.10
quick-error-1.2.3
quote-1.0.3
rand-0.3.22
rand-0.4.3
rand-0.7.3
rand_chacha-0.2.2
rand_core-0.5.1
rand_hc-0.2.0
redox_syscall-0.1.50
regex-0.1.80
regex-1.3.7
regex-automata-0.1.9
regex-syntax-0.3.9
regex-syntax-0.6.17
remove_dir_all-0.5.1
rustc-demangle-0.1.13
ryu-1.0.4
safemem-0.3.0
schannel-0.1.18
scopeguard-1.1.0
security-framework-0.1.16
security-framework-0.4.3
security-framework-sys-0.1.16
security-framework-sys-0.4.3
separator-0.4.1
serde-1.0.106
serde_derive-1.0.106
serde_json-1.0.52
sha-1-0.8.2
sharded-slab-0.0.9
slab-0.4.2
smallvec-1.4.0
socket2-0.3.12
static_assertions-1.1.0
syn-1.0.18
sys-info-0.5.6
tcp-stream-0.15.4
tempdir-0.3.7
tempfile-2.2.0
tempfile-3.1.0
thread-id-2.0.0
thread_local-0.2.7
thread_local-1.0.1
time-0.1.41
tracing-0.1.13
tracing-attributes-0.1.7
tracing-core-0.1.10
tracing-log-0.1.1
tracing-serde-0.1.1
tracing-subscriber-0.2.5
traitobject-0.1.0
typeable-0.1.2
typenum-1.12.0
ucd-trie-0.1.3
unicase-1.4.2
unicode-bidi-0.3.4
unicode-normalization-0.1.7
unicode-xid-0.2.0
url-1.7.2
url-2.1.1
utf8-ranges-0.1.3
uuid-0.4.0
vcpkg-0.2.8
version_check-0.1.5
version_check-0.9.1
wasi-0.9.0+wasi-snapshot-preview1
winapi-0.2.8
winapi-0.3.8
winapi-build-0.1.1
winapi-i686-pc-windows-gnu-0.4.0
winapi-x86_64-pc-windows-gnu-0.4.0
ws2_32-sys-0.2.1

File diff suppressed because it is too large Load diff

View file

@ -1,20 +1,18 @@
{ pkgs ? import ./nix { { pkgs ? import ./nix {
config.permittedInsecurePackages = [ config.permittedInsecurePackages = [
"openssl-1.0.2u" "openssl-1.0.2u"
]; ];
overlays = [ (import ./nix/overlay.nix) ]; overlays = [ (import ./nix/overlay.nix) ];
} }
, ofborgCrates ? import ./Cargo.nix {
inherit pkgs;
release = pkgs.stdenv.isDarwin;
}
}: }:
with ofborgCrates.workspaceMembers;
let let
ofborgCrates = pkgs.callPackage ./Cargo.nix {
cratesIO = pkgs.callPackage ./crates-io.nix {};
};
drv = ofborgCrates.ofborg {};
src = stripDeps (drv.override { release = pkgs.stdenv.isDarwin; });
stripDeps = pkg: pkgs.runCommand "${pkg.name}-deps-stripped" {} stripDeps = pkg: pkgs.runCommand "${pkg.name}-deps-stripped" {}
'' ''
cp -r ${pkg} $out cp -r ${pkg} $out
@ -23,10 +21,14 @@ let
find $out/bin -name '*.d' -delete find $out/bin -name '*.d' -delete
chmod -R a-w $out chmod -R a-w $out
''; '';
src = stripDeps ofborg.build;
in in
{ {
ofborg.simple-build = ofborgCrates.ofborg_simple_build {}; inherit ofborgCrates;
ofborg.simple-build = ofborg-simple-build.build;
ofborg.rs = pkgs.runCommand "ofborg-rs-symlink-compat" { inherit src; } '' ofborg.rs = pkgs.runCommand "ofborg-rs-symlink-compat" { inherit src; } ''
mkdir -p $out/bin mkdir -p $out/bin
@ -49,7 +51,7 @@ in
# Verify that the outpath contains the version number matching the # Verify that the outpath contains the version number matching the
# Cargo.toml # Cargo.toml
if ! grep -q 'version = "${drv.crateVersion}"' ${./ofborg/Cargo.toml}; then if ! grep -q 'version = "${ofborg.build.crateVersion}"' ${./ofborg/Cargo.toml}; then
cat <<EOF cat <<EOF
@ -57,14 +59,13 @@ in
Build failed because you bumped the Cargo Build failed because you bumped the Cargo
version without regenerating the carnix version without regenerating the Cargo.nix.
file.
Run: Run:
nix-shell --run ./nix/update-carnix.sh nix-shell --run ./nix/update-crates.sh
and commit those changes. and commit those changes.

View file

@ -1,7 +1,10 @@
{ {
"url": "https://github.com/nixos/nixpkgs-channels.git", "url": "https://github.com/nixos/nixpkgs-channels.git",
"rev": "e2b4abe3c8f2e09adfc6a52007841d1b96c89371", "rev": "0f5ce2fac0c726036ca69a5524c59a49e2973dd4",
"date": "2020-02-19T01:57:21+01:00", "date": "2020-05-19T01:31:20+02:00",
"sha256": "1l3jfr74s7wmx3fk5y76ayazbfclvnr532kg1hypbzydp3n372rz", "path": "/nix/store/57j44dl147z6956rc5ks4h1ff2rbdlxp-nixpkgs-channels",
"fetchSubmodules": false "sha256": "0nkk492aa7pr0d30vv1aw192wc16wpa1j02925pldc09s9m9i0r3",
"fetchSubmodules": false,
"deepClone": false,
"leaveDotGit": false
} }

View file

@ -1,20 +1,5 @@
(self: super: (self: super:
{ {
carnix = super.carnix.overrideDerivation (drv: {
patches = super.patches or [] ++ [
(super.fetchurl {
name = "carnix-cfg.patch";
url = "https://gist.githubusercontent.com/LnL7/27a567cd2b3162a21cbd0499c6fa0f71/raw/32d3055b6ce105c2c64e8cdfe0204d6c90f6d214/carnix-cfg.patch";
sha256 = "1nc5dlxqrhgh989dfzhjqw46hk3aii0rcz1qr3cvqbrwc7wzcj6w";
})
(super.fetchurl {
name = "carnix-workspaces.patch";
url = "https://gist.githubusercontent.com/LnL7/27a567cd2b3162a21cbd0499c6fa0f71/raw/d6395cfc06dff2a3555b0068e477274f9560fbae/carnix-workspace.patch";
sha256 = "1kvfing0s968pknsrpc98yjii8idsqmy00dsvwkyfbqx9frn7kjg";
})
];
});
defaultCrateOverrides = super.defaultCrateOverrides // { defaultCrateOverrides = super.defaultCrateOverrides // {
ofborg = attrs: { ofborg = attrs: {
buildInputs = with self.darwin.apple_sdk.frameworks; buildInputs = with self.darwin.apple_sdk.frameworks;

View file

@ -1,6 +0,0 @@
#!/bin/sh
set -eu
cargo build
carnix generate-nix --src .

6
nix/update-crates.sh Executable file
View file

@ -0,0 +1,6 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -E "with import ./nix {}; mkShell { nativeBuildInputs = [ cacert cargo (import (builtins.fetchTarball https://github.com/kolloch/crate2nix/archive/0.8.0.tar.gz) {}) ]; }"
set -e
cargo fetch --locked
crate2nix generate

View file

@ -2,7 +2,6 @@
name = "ofborg-simple-build" name = "ofborg-simple-build"
version = "0.1.0" version = "0.1.0"
authors = ["Daiderd Jordan <daiderd@gmail.com>"] authors = ["Daiderd Jordan <daiderd@gmail.com>"]
include = ["Cargo.toml", "ofborg-simple-build"] # TODO remove when carnix is fixed
edition = "2018" edition = "2018"
[dependencies] [dependencies]

View file

@ -2,7 +2,6 @@
name = "ofborg" name = "ofborg"
version = "0.1.9" version = "0.1.9"
authors = ["Graham Christensen <graham@grahamc.com>"] authors = ["Graham Christensen <graham@grahamc.com>"]
include = ["Cargo.toml", "ofborg"] # TODO remove when carnix is fixed
build = "build.rs" build = "build.rs"
edition = "2018" edition = "2018"

View file

@ -83,7 +83,6 @@ let
nix-prefetch-git nix-prefetch-git
latest.rustChannels.stable.rust latest.rustChannels.stable.rust
#rustfmt #rustfmt
carnix
openssl_1_0_2.dev openssl_1_0_2.dev
pkgconfig pkgconfig
git git