Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
azuline committed May 12, 2024
1 parent 19b384c commit b3f2cf7
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 100 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ clean:
git clean -xdf

nixify-zig-deps:
cd rose-zig && nix run 'github:Cloudef/zig2nix#zon2nix' -- build.zig.zon > deps.nix
cd rose-zig && zon2nix > deps.nix

.PHONY: build-zig check test typecheck lintcheck lint clean nixify-zig-deps
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
nodePackages.prettier
zig
zls
zon2nix
];
})
];
Expand Down
4 changes: 2 additions & 2 deletions rose-cli/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
, rose-watch
}:

python-pin.pkgs.buildPythonPackage {
pname = "rose-cli";
python-pin.pkgs.buildPythonApplication {
pname = "rose";
version = version;
src = ./.;
propagatedBuildInputs = [
Expand Down
21 changes: 0 additions & 21 deletions rose-ffi/build.zig

This file was deleted.

10 changes: 0 additions & 10 deletions rose-ffi/build.zig.zon

This file was deleted.

12 changes: 0 additions & 12 deletions rose-ffi/default.nix

This file was deleted.

1 change: 1 addition & 0 deletions rose-py/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ python-pin.pkgs.buildPythonPackage {
propagatedBuildInputs = [
rose-zig
py-deps.appdirs
py-deps.cffi
py-deps.click
py-deps.jinja2
py-deps.mutagen
Expand Down
11 changes: 10 additions & 1 deletion rose-zig/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});

_ = b.addModule("rose", .{
const rose = b.addModule("rose", .{
.root_source_file = b.path("rose/root.zig"),
.target = target,
.optimize = optimize,
.imports = &[_]std.Build.Module.Import{
.{ .name = "sqlite", .module = sqlite.module("sqlite") },
},
});

const librose = b.addSharedLibrary(.{
.name = "rose",
.root_source_file = .{ .path = "ffi/root.zig" },
.target = target,
.optimize = optimize,
});
librose.root_module.addImport("rose", rose);
b.installArtifact(librose);
}
7 changes: 0 additions & 7 deletions rose-zig/build.zig.zon2json-lock

This file was deleted.

6 changes: 5 additions & 1 deletion rose-zig/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ stdenv
{ callPackage
, stdenv
, zig
, version
}:
Expand All @@ -8,4 +9,7 @@ stdenv.mkDerivation {
version = version;
src = ./.;
nativeBuildInputs = [ zig.hook ];
postPatch = ''
ln -s ${callPackage ./deps.nix { }} $ZIG_GLOBAL_CACHE_DIR/p
'';
}
51 changes: 6 additions & 45 deletions rose-zig/deps.nix
Original file line number Diff line number Diff line change
@@ -1,52 +1,13 @@
# generated by zon2nix (https://github.com/Cloudef/zig2nix)
# generated by zon2nix (https://github.com/nix-community/zon2nix)

{ lib, linkFarm, fetchurl, fetchgit, runCommandLocal, zig, name ? "zig-packages" }:
{ linkFarm, fetchzip }:

with builtins;
with lib;

let
unpackZigArtifact = { name, artifact }: runCommandLocal name {
nativeBuildInputs = [ zig ];
} ''
hash="$(zig fetch --global-cache-dir "$TMPDIR" ${artifact})"
mv "$TMPDIR/p/$hash" "$out"
chmod 755 "$out"
'';

fetchZig = { name, url, hash }: let
artifact = fetchurl { inherit url hash; };
in unpackZigArtifact { inherit name artifact; };

fetchGitZig = { name, url, hash }: let
parts = splitString "#" url;
base = elemAt parts 0;
rev = elemAt parts 1;
in fetchgit {
inherit name rev hash;
url = base;
deepClone = false;
};

fetchZigArtifact = { name, url, hash }: let
parts = splitString "://" url;
proto = elemAt parts 0;
path = elemAt parts 1;
fetcher = {
"git+http" = fetchGitZig { inherit name hash; url = "http://${path}"; };
"git+https" = fetchGitZig { inherit name hash; url = "https://${path}"; };
http = fetchZig { inherit name hash; url = "http://${path}"; };
https = fetchZig { inherit name hash; url = "https://${path}"; };
file = unpackZigArtifact { inherit name; artifact = /. + path; };
};
in fetcher.${proto};
in linkFarm name [
linkFarm "zig-packages" [
{
name = "1220e0961c135c5aa3af77a043dbc5890a18235a157238df0e2882fe84a8c8439c7a";
path = fetchZigArtifact {
name = "sqlite";
path = fetchzip {
url = "https://github.com/vrischmann/zig-sqlite/archive/dc339b7cf3bca82a12c2169231dd247587766781.tar.gz";
hash = "sha256-PbWUedWBuNxA7diVAEh225b6YQA757aSvomQjUgSgRk=";
hash = "sha256-YouCVidJqhI5+joTSe1aSbnjVC+qVG2aIz6MyibRmQk=";
};
}
]
]
File renamed without changes.
File renamed without changes.

0 comments on commit b3f2cf7

Please sign in to comment.