Skip to content

Commit b7fdc8a

Browse files
attic/nix_store: Add support for Lix
Fixes #229. Co-authored-by: Nikodem Rabuliński <nikodem@rabulinski.com>
1 parent 006bda6 commit b7fdc8a

File tree

6 files changed

+37
-2
lines changed

6 files changed

+37
-2
lines changed

.github/workflows/build.yml

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ jobs:
7676
- "2.24"
7777
- "2.25"
7878
- "2.26"
79+
- "lix-2.91"
7980
- "default"
8081
runs-on: ${{ matrix.os }}
8182
steps:

attic/Cargo.toml

+9-2
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,17 @@ system-deps = { version = "7.0", optional = true }
5050
version-compare = "0.2.0"
5151

5252
[package.metadata.system-deps]
53-
nix-store = { version = "2.24", feature = "nix_store" }
54-
nix-main = { version = "2.24", feature = "nix_store" }
53+
nix-store = { version = "2.24", feature = "nix_store_nix" }
54+
nix-main = { version = "2.24", feature = "nix_store_nix" }
55+
56+
lix-store = { version = "2.91", feature = "nix_store_lix" }
57+
lix-main = { version = "2.91", feature = "nix_store_lix" }
5558

5659
[features]
5760
default = [
5861
"chunking",
5962
"nix_store",
63+
"nix_store_nix",
6064
"stream",
6165
"tokio",
6266
]
@@ -76,6 +80,9 @@ nix_store = [
7680
"dep:system-deps",
7781
]
7882

83+
nix_store_nix = []
84+
nix_store_lix = []
85+
7986
# Stream utilities.
8087
stream = ["tokio", "dep:async-stream"]
8188

attic/build.rs

+11
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ mod nix_store {
1313
use version_compare::Version;
1414
use system_deps::Dependencies;
1515

16+
#[cfg(all(feature = "nix_store_nix", feature = "nix_store_lix"))]
17+
compile_error!("nix_store_nix and nix_store_lix are mutually exclusive");
1618

19+
#[cfg(all(not(feature = "nix_store_nix"), not(feature = "nix_store_lix")))]
20+
compile_error!("One of nix_store_nix and nix_store_lix must be enabled");
21+
22+
#[cfg(feature = "nix_store_nix")]
1723
fn apply_variant_flags(build: &mut Build, deps: &Dependencies) {
1824
let nix_main = deps.get_by_name("nix-main").expect("Failed to get version of nix-main");
1925
let version = Version::from(&nix_main.version).unwrap();
@@ -28,6 +34,11 @@ mod nix_store {
2834
build.define("NIX_VERSION", &*format!("{version}"));
2935
}
3036

37+
#[cfg(feature = "nix_store_lix")]
38+
fn apply_variant_flags(build: &mut Build, deps: &Dependencies) {
39+
build.define("ATTIC_VARIANT_LIX", None);
40+
}
41+
3142
pub fn build_bridge() {
3243
let deps = system_deps::Config::new().probe().unwrap();
3344

attic/src/nix_store/bindings/nix-includes.hpp

+11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@
1414
#include <nix/path.hh>
1515
#include <nix/serialise.hh>
1616
#include <nix/shared.hh>
17+
#elif defined(ATTIC_VARIANT_LIX)
18+
#include <lix/config.h>
19+
20+
#include <lix/libstore/store-api.hh>
21+
#include <lix/libstore/local-store.hh>
22+
#include <lix/libstore/remote-store.hh>
23+
#include <lix/libstore/uds-remote-store.hh>
24+
#include <lix/libutil/hash.hh>
25+
#include <lix/libstore/path.hh>
26+
#include <lix/libutil/serialise.hh>
27+
#include <lix/libmain/shared.hh>
1728
#else
1829
#error Unsupported variant
1930
#endif

attic/src/nix_store/bindings/nix.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ using RBasePathSlice = RSlice<const unsigned char>;
2525
using RHashSlice = RSlice<const unsigned char>;
2626

2727
static bool hash_is_sha256(const nix::Hash &hash) {
28+
#ifdef ATTIC_VARIANT_LIX
29+
return hash.type == nix::HashType::SHA256;
30+
#else
2831
return hash.algo == nix::HashAlgorithm::SHA256;
32+
#endif
2933
}
3034

3135
struct AsyncWriteSender;

flake/nix-versions.nix

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ in
3939
"2.24" = pkgs.nixVersions.nix_2_24;
4040
"2.25" = pkgs.nixVersions.nix_2_25;
4141
"2.26" = pkgs.nixVersions.nix_2_26;
42+
"lix-2.91" = pkgs.lixVersions.lix_2_91;
4243
};
4344

4445
manifestFile = let

0 commit comments

Comments
 (0)