From 0139cd56214c5d378ac9e3f98f9d9ab51f2394f5 Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Sat, 25 Apr 2020 13:34:26 +0200 Subject: [PATCH 1/4] move carnix files to workspace --- ofborg/Cargo.nix => Cargo.nix | 35 +++++++++++++++++++++++-- ofborg/crates-io.list => crates-io.list | 0 ofborg/crates-io.nix => crates-io.nix | 0 default.nix | 4 +-- nix/update-carnix.sh | 2 -- ofborg/Cargo.toml | 2 +- 6 files changed, 36 insertions(+), 7 deletions(-) rename ofborg/Cargo.nix => Cargo.nix (92%) rename ofborg/crates-io.list => crates-io.list (100%) rename ofborg/crates-io.nix => crates-io.nix (100%) diff --git a/ofborg/Cargo.nix b/Cargo.nix similarity index 92% rename from ofborg/Cargo.nix rename to Cargo.nix index 506622a..eecf7fc 100644 --- a/ofborg/Cargo.nix +++ b/Cargo.nix @@ -112,7 +112,8 @@ rec { version = "0.1.8"; authors = [ "Graham Christensen " ]; edition = "2018"; - src = include [ "Cargo.toml" "Cargo.lock" "src" "test-srcs" "build.rs" ] ./.; + src = include [ "Cargo.toml" "src" "test-srcs" "build.rs" ] ./.; + workspace_member = "ofborg"; build = "build.rs"; dependencies = mapFeatures features ([ (crates."amqp"."${deps."ofborg"."0.1.8"."amqp"}" deps) @@ -183,12 +184,38 @@ rec { ]; +# end +# ofborg-simple-build-0.1.0 + + crates.ofborg_simple_build."0.1.0" = deps: { features?(features_.ofborg_simple_build."0.1.0" deps {}) }: buildRustCrate { + crateName = "ofborg-simple-build"; + version = "0.1.0"; + authors = [ "Daiderd Jordan " ]; + edition = "2018"; + src = include [ "Cargo.toml" " ofborg-simple-build" ] ./.; + workspace_member = "ofborg-simple-build"; + dependencies = mapFeatures features ([ + (cratesIO.crates."log"."${deps."ofborg_simple_build"."0.1.0"."log"}" deps) + (crates."ofborg"."${deps."ofborg_simple_build"."0.1.0"."ofborg"}" deps) + ]); + }; + features_.ofborg_simple_build."0.1.0" = deps: f: updateFeatures f (rec { + log."${deps.ofborg_simple_build."0.1.0".log}".default = true; + ofborg."${deps.ofborg_simple_build."0.1.0".ofborg}".default = true; + ofborg_simple_build."0.1.0".default = (f.ofborg_simple_build."0.1.0".default or true); + }) [ + (cratesIO.features_.log."${deps."ofborg_simple_build"."0.1.0"."log"}" deps) + (features_.ofborg."${deps."ofborg_simple_build"."0.1.0"."ofborg"}" deps) + ]; + + # end }; ofborg = crates.crates.ofborg."0.1.8" deps; - __all = [ (ofborg {}) ]; + ofborg_simple_build = crates.crates.ofborg_simple_build."0.1.0" deps; + __all = [ (ofborg {}) (ofborg_simple_build {}) ]; deps.aho_corasick."0.5.3" = { memchr = "0.1.11"; }; @@ -389,6 +416,10 @@ rec { tempfile = "2.2.0"; uuid = "0.4.0"; }; + deps.ofborg_simple_build."0.1.0" = { + log = "0.3.8"; + ofborg = "0.1.8"; + }; deps.openssl."0.9.24" = { bitflags = "0.9.1"; foreign_types = "0.3.2"; diff --git a/ofborg/crates-io.list b/crates-io.list similarity index 100% rename from ofborg/crates-io.list rename to crates-io.list diff --git a/ofborg/crates-io.nix b/crates-io.nix similarity index 100% rename from ofborg/crates-io.nix rename to crates-io.nix diff --git a/default.nix b/default.nix index 8772120..970daa5 100644 --- a/default.nix +++ b/default.nix @@ -10,8 +10,8 @@ let }; }; - drv = ((pkgs.callPackage ./ofborg/Cargo.nix { - cratesIO = pkgs.callPackage ./ofborg/crates-io.nix {}; + drv = ((pkgs.callPackage ./Cargo.nix { + cratesIO = pkgs.callPackage ./crates-io.nix {}; }).ofborg {}).override { release = false; }; src = stripDeps (drv.override ofborgOverrides); diff --git a/nix/update-carnix.sh b/nix/update-carnix.sh index 7cf3cd2..d5da7ca 100755 --- a/nix/update-carnix.sh +++ b/nix/update-carnix.sh @@ -2,7 +2,5 @@ set -eu -cd ofborg - cargo build carnix generate-nix --src . diff --git a/ofborg/Cargo.toml b/ofborg/Cargo.toml index 4a49573..dd0a422 100644 --- a/ofborg/Cargo.toml +++ b/ofborg/Cargo.toml @@ -2,7 +2,7 @@ name = "ofborg" version = "0.1.8" authors = ["Graham Christensen "] -include = ["Cargo.toml", "Cargo.lock", "src", "test-srcs", "build.rs"] +include = ["Cargo.toml", "src", "test-srcs", "build.rs"] build = "build.rs" edition = "2018" From 96639e9d7e456bcee261d40b7d92c6043ea9f907 Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Sat, 25 Apr 2020 13:51:14 +0200 Subject: [PATCH 2/4] work around carnix workspace issue Carnix doesn't properly handle includes for workspace members, this works around the issue by specifying what should be generated directly in Cargo.toml. https://nest.pijul.com/pmeunier/carnix/discussions/46 --- Cargo.nix | 4 ++-- ofborg-simple-build/Cargo.toml | 1 + ofborg/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.nix b/Cargo.nix index eecf7fc..5b38965 100644 --- a/Cargo.nix +++ b/Cargo.nix @@ -112,7 +112,7 @@ rec { version = "0.1.8"; authors = [ "Graham Christensen " ]; edition = "2018"; - src = include [ "Cargo.toml" "src" "test-srcs" "build.rs" ] ./.; + src = include [ "Cargo.toml" "ofborg" ] ./.; workspace_member = "ofborg"; build = "build.rs"; dependencies = mapFeatures features ([ @@ -192,7 +192,7 @@ rec { version = "0.1.0"; authors = [ "Daiderd Jordan " ]; edition = "2018"; - src = include [ "Cargo.toml" " ofborg-simple-build" ] ./.; + src = include [ "Cargo.toml" "ofborg-simple-build" ] ./.; workspace_member = "ofborg-simple-build"; dependencies = mapFeatures features ([ (cratesIO.crates."log"."${deps."ofborg_simple_build"."0.1.0"."log"}" deps) diff --git a/ofborg-simple-build/Cargo.toml b/ofborg-simple-build/Cargo.toml index b1bb6b6..5a1a241 100644 --- a/ofborg-simple-build/Cargo.toml +++ b/ofborg-simple-build/Cargo.toml @@ -2,6 +2,7 @@ name = "ofborg-simple-build" version = "0.1.0" authors = ["Daiderd Jordan "] +include = ["Cargo.toml", "ofborg-simple-build"] # TODO remove when carnix is fixed edition = "2018" [dependencies] diff --git a/ofborg/Cargo.toml b/ofborg/Cargo.toml index dd0a422..1af67f1 100644 --- a/ofborg/Cargo.toml +++ b/ofborg/Cargo.toml @@ -2,7 +2,7 @@ name = "ofborg" version = "0.1.8" authors = ["Graham Christensen "] -include = ["Cargo.toml", "src", "test-srcs", "build.rs"] +include = ["Cargo.toml", "ofborg"] # TODO remove when carnix is fixed build = "build.rs" edition = "2018" From 40c759e027cec4cfc456b6fdbc54678469fbc59a Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Sat, 25 Apr 2020 14:32:42 +0200 Subject: [PATCH 3/4] add build for ofborg-simple-build --- default.nix | 17 ++++++----------- nix/overlay.nix | 11 ++++++++++- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/default.nix b/default.nix index 970daa5..9fc5555 100644 --- a/default.nix +++ b/default.nix @@ -1,20 +1,13 @@ { pkgs ? import ./nix { overlays = [ (import ./nix/overlay.nix) ]; } }: let - ofborgOverrides = { - crateOverrides = pkgs.defaultCrateOverrides // { - ofborg = attrs: { - buildInputs = pkgs.lib.optional pkgs.stdenv.isDarwin - pkgs.darwin.apple_sdk.frameworks.Security; - }; - }; + ofborgCrates = pkgs.callPackage ./Cargo.nix { + cratesIO = pkgs.callPackage ./crates-io.nix {}; }; - drv = ((pkgs.callPackage ./Cargo.nix { - cratesIO = pkgs.callPackage ./crates-io.nix {}; - }).ofborg {}).override { release = false; }; + drv = ofborgCrates.ofborg {}; - src = stripDeps (drv.override ofborgOverrides); + src = stripDeps (drv.override { release = false; }); stripDeps = pkg: pkgs.runCommand "${pkg.name}-deps-stripped" {} '' @@ -27,6 +20,8 @@ let in { + ofborg.simple-build = ofborgCrates.ofborg_simple_build {}; + ofborg.rs = pkgs.runCommand "ofborg-rs-symlink-compat" { inherit src; } '' mkdir -p $out/bin for f in $(find $src -type f); do diff --git a/nix/overlay.nix b/nix/overlay.nix index 7e1b7a5..d874abd 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -1,5 +1,14 @@ -(self: super: { +(self: super: +{ defaultCrateOverrides = super.defaultCrateOverrides // { + ofborg = attrs: { + buildInputs = with self.darwin.apple_sdk.frameworks; + super.lib.optional super.stdenv.isDarwin Security; + }; + ofborg-simple-build = attrs: { + buildInputs = with self.darwin.apple_sdk.frameworks; + super.lib.optional super.stdenv.isDarwin Security; + }; openssl-sys = attrs: { buildInputs = [ self.openssl_1_0_2 ]; nativeBuildInputs = [ self.pkgconfig ]; From 5669d9b47eb3da88f17e496e3dbbc2d27680630b Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Sat, 25 Apr 2020 14:36:46 +0200 Subject: [PATCH 4/4] disable debug build on darwin Currently broken due to the .dSYM folders it generates next to the binaries. See https://github.com/NixOS/nixpkgs/pull/83488 --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index 9fc5555..2096daf 100644 --- a/default.nix +++ b/default.nix @@ -7,7 +7,7 @@ let drv = ofborgCrates.ofborg {}; - src = stripDeps (drv.override { release = false; }); + src = stripDeps (drv.override { release = pkgs.stdenv.isDarwin; }); stripDeps = pkg: pkgs.runCommand "${pkg.name}-deps-stripped" {} ''