diff --git a/Makefile b/Makefile index 536bd61..d74c242 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/flake.nix b/flake.nix index fb1209e..2fd5f7b 100644 --- a/flake.nix +++ b/flake.nix @@ -80,6 +80,7 @@ nodePackages.prettier zig zls + zon2nix ]; }) ]; diff --git a/rose-cli/default.nix b/rose-cli/default.nix index 49261c0..a50ed5e 100644 --- a/rose-cli/default.nix +++ b/rose-cli/default.nix @@ -6,8 +6,8 @@ , rose-watch }: -python-pin.pkgs.buildPythonPackage { - pname = "rose-cli"; +python-pin.pkgs.buildPythonApplication { + pname = "rose"; version = version; src = ./.; propagatedBuildInputs = [ diff --git a/rose-ffi/build.zig b/rose-ffi/build.zig deleted file mode 100644 index dfa7a43..0000000 --- a/rose-ffi/build.zig +++ /dev/null @@ -1,21 +0,0 @@ -const std = @import("std"); - -pub fn build(b: *std.Build) void { - const target = b.standardTargetOptions(.{}); - const optimize = b.standardOptimizeOption(.{}); - - const rose = b.dependency("rose", .{ - .target = target, - .optimize = optimize, - }); - - const librose = b.addSharedLibrary(.{ - .name = "rose", - .root_source_file = .{ .path = "src/root.zig" }, - .target = target, - .optimize = optimize, - }); - // TODO: Doesn't work. How do I depend? - librose.linkLibrary(rose.artifact("rose")); - b.installArtifact(librose); -} diff --git a/rose-ffi/build.zig.zon b/rose-ffi/build.zig.zon deleted file mode 100644 index 3cec32e..0000000 --- a/rose-ffi/build.zig.zon +++ /dev/null @@ -1,10 +0,0 @@ -.{ - .name = "rose-ffi", - .version = "0.5.0", - .dependencies = .{ - .rose = .{ - .path = "../rose-zig", - }, - }, - .paths = .{""}, -} diff --git a/rose-ffi/default.nix b/rose-ffi/default.nix deleted file mode 100644 index dad233b..0000000 --- a/rose-ffi/default.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ stdenv -, zig -, version -, rose-zig -}: - -stdenv.mkDerivation { - pname = "rose-ffi"; - version = version; - src = ./.; - nativeBuildInputs = [ zig.hook rose-zig ]; -} diff --git a/rose-py/default.nix b/rose-py/default.nix index 2c56594..9a36267 100644 --- a/rose-py/default.nix +++ b/rose-py/default.nix @@ -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 diff --git a/rose-zig/build.zig b/rose-zig/build.zig index 89a03ce..7873998 100644 --- a/rose-zig/build.zig +++ b/rose-zig/build.zig @@ -9,7 +9,7 @@ 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, @@ -17,4 +17,13 @@ pub fn build(b: *std.Build) void { .{ .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); } diff --git a/rose-zig/build.zig.zon2json-lock b/rose-zig/build.zig.zon2json-lock deleted file mode 100644 index cfd4667..0000000 --- a/rose-zig/build.zig.zon2json-lock +++ /dev/null @@ -1,7 +0,0 @@ -{ - "1220e0961c135c5aa3af77a043dbc5890a18235a157238df0e2882fe84a8c8439c7a": { - "name": "sqlite", - "url": "https://github.com/vrischmann/zig-sqlite/archive/dc339b7cf3bca82a12c2169231dd247587766781.tar.gz", - "hash": "sha256-PbWUedWBuNxA7diVAEh225b6YQA757aSvomQjUgSgRk=" - } -} diff --git a/rose-zig/default.nix b/rose-zig/default.nix index c6b648a..235af1d 100644 --- a/rose-zig/default.nix +++ b/rose-zig/default.nix @@ -1,4 +1,5 @@ -{ stdenv +{ callPackage +, stdenv , zig , version }: @@ -8,4 +9,7 @@ stdenv.mkDerivation { version = version; src = ./.; nativeBuildInputs = [ zig.hook ]; + postPatch = '' + ln -s ${callPackage ./deps.nix { }} $ZIG_GLOBAL_CACHE_DIR/p + ''; } diff --git a/rose-zig/deps.nix b/rose-zig/deps.nix index ccb0013..a6d7ce3 100644 --- a/rose-zig/deps.nix +++ b/rose-zig/deps.nix @@ -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="; }; } -] \ No newline at end of file +] diff --git a/rose-ffi/src/root.zig b/rose-zig/ffi/root.zig similarity index 100% rename from rose-ffi/src/root.zig rename to rose-zig/ffi/root.zig diff --git a/rose-zig/src/root.zig b/rose-zig/rose/root.zig similarity index 100% rename from rose-zig/src/root.zig rename to rose-zig/rose/root.zig