From 5dace9d0b996b644fefa536e3978dd983987fea3 Mon Sep 17 00:00:00 2001 From: Hannes <33062605+HannesGitH@users.noreply.github.com> Date: Mon, 11 Nov 2024 17:32:24 +0100 Subject: [PATCH 01/10] added rudementary, non-working flake --- flake.lock | 44 +++++++++++++++++++++++++++++++++++++++++ flake.nix | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..3b99675 --- /dev/null +++ b/flake.lock @@ -0,0 +1,44 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1731139594, + "narHash": "sha256-IigrKK3vYRpUu+HEjPL/phrfh7Ox881er1UEsZvw9Q4=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "76612b17c0ce71689921ca12d9ffdc9c23ce40b2", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs2": { + "locked": { + "lastModified": 1731271174, + "narHash": "sha256-lZEJ73HJ7fzRZPjIagxhwV7MjioKAU6VnvPoXqSmxJw=", + "owner": "hannesGitH", + "repo": "nixpkgs", + "rev": "4aceccb616087967966a2c1c3837cff9922816a4", + "type": "github" + }, + "original": { + "owner": "hannesGitH", + "ref": "tauri2", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "nixpkgs2": "nixpkgs2" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..cefec21 --- /dev/null +++ b/flake.nix @@ -0,0 +1,58 @@ +{ + description = "NeoHTop flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + # as upstream nixpkgs doesn't have tauri 2, we use a fork + nixpkgs2.url = "github:hannesGitH/nixpkgs?ref=tauri2"; + }; + + outputs = inputs@{ nixpkgs, ... }: + let + inherit (nixpkgs) lib; + # definitely not tested, but i like it exposed, who knows + systems = lib.systems.flakeExposed; + forAllSystems = lib.genAttrs systems; + spkgs = system : nixpkgs.legacyPackages.${system}.pkgs; + in + { + packages = forAllSystems (system: with spkgs system; rec { + remote2 = inputs.nixpkgs2.legacyPackages.${system}; + tauri = remote2.pkgs.cargo-tauri; + rquickshare = rustPlatform.buildRustPackage rec { + name = "rquickshare"; + src = ./app/main; + nativeBuildInputs = [ tauri.hook pnpm.configHook nodejs ]; + cargoRoot = "src-tauri"; + cargoHash = ""; + pnpmDeps = pnpm.fetchDeps { + inherit src; + pname = name; + hash = ""; + }; + # remove macOS signing + postConfigure = '' + ${jq}/bin/jq 'del(.bundle.macOS.signingIdentity, .bundle.macOS.hardenedRuntime)' src-tauri/tauri.conf.json > tmp.json + mv tmp.json src-tauri/tauri.conf.json + ''; + checkPhase = "true"; # idk why checks fail, todo + installPhase = let path = "${cargoRoot}/target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/bundle"; in + if stdenv.isDarwin then '' + mkdir -p $out/bin + mv ${path}/macos $out/Applications + echo "#!${zsh}/bin/zsh" >> $out/bin/${name} + echo "open -a $out/Applications/${name}.app" >> $out/bin/${name} + chmod +x $out/bin/${name} + '' else '' + mv ${path}/deb/*/data/usr $out + ''; + }; + default = rquickshare; + }); + devShells = forAllSystems (system: with spkgs system; { + default = mkShell { + buildInputs = [ cargo rustc nodejs ]; + }; + }); + }; +} From 88f3566a578faeebd43603729c3244cfad17455a Mon Sep 17 00:00:00 2001 From: Hannes <33062605+HannesGitH@users.noreply.github.com> Date: Mon, 11 Nov 2024 17:59:49 +0100 Subject: [PATCH 02/10] core flake --- core_lib/flake.nix | 32 ++++++++++++++++++++++++++++++++ flake.nix | 37 +++++++++++++++++++++---------------- 2 files changed, 53 insertions(+), 16 deletions(-) create mode 100644 core_lib/flake.nix diff --git a/core_lib/flake.nix b/core_lib/flake.nix new file mode 100644 index 0000000..e92bdb3 --- /dev/null +++ b/core_lib/flake.nix @@ -0,0 +1,32 @@ +{ + description = "rquickshare-core flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + }; + + outputs = inputs@{ nixpkgs, ... }: + let + inherit (nixpkgs) lib; + # definitely not tested, but i like it exposed, who knows + systems = lib.systems.flakeExposed; + forAllSystems = lib.genAttrs systems; + spkgs = system : nixpkgs.legacyPackages.${system}.pkgs; + in + { + packages = forAllSystems (system: with spkgs system; { + rcore = rustPlatform.buildRustPackage { + name = "rquickshare-core"; + src = ./.; + nativeBuildInputs = [ ]; + cargoLock = { + lockFile = ./Cargo.lock; + outputHashes = { + "mdns-sd-0.10.4" = "sha256-y8pHtG7JCJvmWCDlWuJWJDbCGOheD4PN+WmOxnakbE4="; + }; + }; + }; + default = rquickshare; + }); + }; +} diff --git a/flake.nix b/flake.nix index cefec21..542f13d 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "NeoHTop flake"; + description = "rquickshare flake"; inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; @@ -24,28 +24,33 @@ src = ./app/main; nativeBuildInputs = [ tauri.hook pnpm.configHook nodejs ]; cargoRoot = "src-tauri"; - cargoHash = ""; + cargoLock = { + lockFile = app/main/src-tauri/Cargo.lock; + outputHashes = { + "mdns-sd-0.10.4" = "sha256-y8pHtG7JCJvmWCDlWuJWJDbCGOheD4PN+WmOxnakbE4="; + }; + }; pnpmDeps = pnpm.fetchDeps { inherit src; pname = name; hash = ""; }; - # remove macOS signing + # remove macOS signing and relative links postConfigure = '' - ${jq}/bin/jq 'del(.bundle.macOS.signingIdentity, .bundle.macOS.hardenedRuntime)' src-tauri/tauri.conf.json > tmp.json - mv tmp.json src-tauri/tauri.conf.json - ''; - checkPhase = "true"; # idk why checks fail, todo - installPhase = let path = "${cargoRoot}/target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/bundle"; in - if stdenv.isDarwin then '' - mkdir -p $out/bin - mv ${path}/macos $out/Applications - echo "#!${zsh}/bin/zsh" >> $out/bin/${name} - echo "open -a $out/Applications/${name}.app" >> $out/bin/${name} - chmod +x $out/bin/${name} - '' else '' - mv ${path}/deb/*/data/usr $out + ${jq}/bin/jq -i 'del(.bundle.macOS.signingIdentity, .bundle.macOS.hardenedRuntime)' src-tauri/tauri.conf.json + ${yq}/bin/yq -i '.importers.".".dependencies."@martichou/core_lib".specifier = "link:${corelib}" | .importers.".".dependencies."@martichou/core_lib".version = "link:${corelib}"' pnpm-lock.yaml ''; + # checkPhase = "true"; # idk why checks fail, todo + # installPhase = let path = "${cargoRoot}/target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/bundle"; in + # if stdenv.isDarwin then '' + # mkdir -p $out/bin + # mv ${path}/macos $out/Applications + # echo "#!${zsh}/bin/zsh" >> $out/bin/${name} + # echo "open -a $out/Applications/${name}.app" >> $out/bin/${name} + # chmod +x $out/bin/${name} + # '' else '' + # mv ${path}/deb/*/data/usr $out + # ''; }; default = rquickshare; }); From e42ccebe41a7e4599e6830169c3f0839b9893a45 Mon Sep 17 00:00:00 2001 From: Hannes <33062605+HannesGitH@users.noreply.github.com> Date: Mon, 11 Nov 2024 19:12:21 +0100 Subject: [PATCH 03/10] use core_lib --- core_lib/flake.lock | 27 +++++++++++++++++++++++++++ core_lib/flake.nix | 16 ++++++++++++---- core_lib/result | 1 + flake.lock | 34 +++++++++++++++++++++++++++++++++- flake.nix | 30 ++++++++++++++++-------------- 5 files changed, 89 insertions(+), 19 deletions(-) create mode 100644 core_lib/flake.lock create mode 120000 core_lib/result diff --git a/core_lib/flake.lock b/core_lib/flake.lock new file mode 100644 index 0000000..e3a64e1 --- /dev/null +++ b/core_lib/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1731139594, + "narHash": "sha256-IigrKK3vYRpUu+HEjPL/phrfh7Ox881er1UEsZvw9Q4=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "76612b17c0ce71689921ca12d9ffdc9c23ce40b2", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/core_lib/flake.nix b/core_lib/flake.nix index e92bdb3..6502867 100644 --- a/core_lib/flake.nix +++ b/core_lib/flake.nix @@ -14,19 +14,27 @@ spkgs = system : nixpkgs.legacyPackages.${system}.pkgs; in { - packages = forAllSystems (system: with spkgs system; { - rcore = rustPlatform.buildRustPackage { + packages = forAllSystems (system: with spkgs system; rec { + rqscore = rustPlatform.buildRustPackage rec { name = "rquickshare-core"; src = ./.; - nativeBuildInputs = [ ]; + nativeBuildInputs = [ protobuf ]; cargoLock = { lockFile = ./Cargo.lock; outputHashes = { "mdns-sd-0.10.4" = "sha256-y8pHtG7JCJvmWCDlWuJWJDbCGOheD4PN+WmOxnakbE4="; }; }; + installPhase = '' + mkdir -p $out/bin + cp -r package.json $out/ + cp -r esm $out/ + cp -r dist $out/ + cp -r target $out/ + cp -r target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/core_bin $out/bin/${name} + ''; }; - default = rquickshare; + default = rqscore; }); }; } diff --git a/core_lib/result b/core_lib/result new file mode 120000 index 0000000..6d96aba --- /dev/null +++ b/core_lib/result @@ -0,0 +1 @@ +/nix/store/pp4a3njkwwizmbkx5nkxx4mq8kn5n6aj-rquickshare-core \ No newline at end of file diff --git a/flake.lock b/flake.lock index 3b99675..bb96c58 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,20 @@ { "nodes": { + "corelib": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1, + "narHash": "sha256-tTlcmV5iVVQc2V6Nb14ZDJy6HXQAcGX873wszn9DqpA=", + "path": "/nix/store/4al0ybv47gjla7pxjya4af63309cpwbm-source/core_lib", + "type": "path" + }, + "original": { + "path": "/nix/store/4al0ybv47gjla7pxjya4af63309cpwbm-source/core_lib", + "type": "path" + } + }, "nixpkgs": { "locked": { "lastModified": 1731139594, @@ -32,9 +47,26 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1731139594, + "narHash": "sha256-IigrKK3vYRpUu+HEjPL/phrfh7Ox881er1UEsZvw9Q4=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "76612b17c0ce71689921ca12d9ffdc9c23ce40b2", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { - "nixpkgs": "nixpkgs", + "corelib": "corelib", + "nixpkgs": "nixpkgs_2", "nixpkgs2": "nixpkgs2" } } diff --git a/flake.nix b/flake.nix index 542f13d..d7059f4 100644 --- a/flake.nix +++ b/flake.nix @@ -5,6 +5,7 @@ nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; # as upstream nixpkgs doesn't have tauri 2, we use a fork nixpkgs2.url = "github:hannesGitH/nixpkgs?ref=tauri2"; + corelib.url = "./core_lib"; }; outputs = inputs@{ nixpkgs, ... }: @@ -19,10 +20,11 @@ packages = forAllSystems (system: with spkgs system; rec { remote2 = inputs.nixpkgs2.legacyPackages.${system}; tauri = remote2.pkgs.cargo-tauri; + corelib = inputs.corelib.outputs.packages.${system}.default; rquickshare = rustPlatform.buildRustPackage rec { name = "rquickshare"; src = ./app/main; - nativeBuildInputs = [ tauri.hook pnpm.configHook nodejs ]; + nativeBuildInputs = [ tauri.hook pnpm.configHook nodejs moreutils ]; cargoRoot = "src-tauri"; cargoLock = { lockFile = app/main/src-tauri/Cargo.lock; @@ -33,24 +35,24 @@ pnpmDeps = pnpm.fetchDeps { inherit src; pname = name; - hash = ""; + hash = "sha256-ko0S934TnGDVbTrFkunHPt0e/pT5CVi4yorTi0WYqmc="; }; # remove macOS signing and relative links postConfigure = '' - ${jq}/bin/jq -i 'del(.bundle.macOS.signingIdentity, .bundle.macOS.hardenedRuntime)' src-tauri/tauri.conf.json + ${jq}/bin/jq -i 'del(.bundle.macOS.signingIdentity, .bundle.macOS.hardenedRuntime)' src-tauri/tauri.conf.json | sponge src-tauri/tauri.conf.json ${yq}/bin/yq -i '.importers.".".dependencies."@martichou/core_lib".specifier = "link:${corelib}" | .importers.".".dependencies."@martichou/core_lib".version = "link:${corelib}"' pnpm-lock.yaml ''; - # checkPhase = "true"; # idk why checks fail, todo - # installPhase = let path = "${cargoRoot}/target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/bundle"; in - # if stdenv.isDarwin then '' - # mkdir -p $out/bin - # mv ${path}/macos $out/Applications - # echo "#!${zsh}/bin/zsh" >> $out/bin/${name} - # echo "open -a $out/Applications/${name}.app" >> $out/bin/${name} - # chmod +x $out/bin/${name} - # '' else '' - # mv ${path}/deb/*/data/usr $out - # ''; + checkPhase = "true"; # idk why checks fail, todo + installPhase = let path = "${cargoRoot}/target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/bundle"; in + if stdenv.isDarwin then '' + mkdir -p $out/bin + mv ${path}/macos $out/Applications + echo "#!${zsh}/bin/zsh" >> $out/bin/${name} + echo "open -a $out/Applications/${name}.app" >> $out/bin/${name} + chmod +x $out/bin/${name} + '' else '' + mv ${path}/deb/*/data/usr $out + ''; }; default = rquickshare; }); From 567801c0560477338fc45003a938173a81075e93 Mon Sep 17 00:00:00 2001 From: Hannes <33062605+HannesGitH@users.noreply.github.com> Date: Tue, 12 Nov 2024 17:15:26 +0100 Subject: [PATCH 04/10] so nich --- core_lib/flake.nix | 11 ++--------- flake.lock | 6 +++--- flake.nix | 41 +++++++++++++++++++++++++++++++---------- result | 1 + 4 files changed, 37 insertions(+), 22 deletions(-) create mode 120000 result diff --git a/core_lib/flake.nix b/core_lib/flake.nix index 6502867..3b2aa63 100644 --- a/core_lib/flake.nix +++ b/core_lib/flake.nix @@ -15,7 +15,8 @@ in { packages = forAllSystems (system: with spkgs system; rec { - rqscore = rustPlatform.buildRustPackage rec { + rqscore_src = rqscore.src; + rqscore = rustPlatform.buildRustPackage { name = "rquickshare-core"; src = ./.; nativeBuildInputs = [ protobuf ]; @@ -25,14 +26,6 @@ "mdns-sd-0.10.4" = "sha256-y8pHtG7JCJvmWCDlWuJWJDbCGOheD4PN+WmOxnakbE4="; }; }; - installPhase = '' - mkdir -p $out/bin - cp -r package.json $out/ - cp -r esm $out/ - cp -r dist $out/ - cp -r target $out/ - cp -r target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/core_bin $out/bin/${name} - ''; }; default = rqscore; }); diff --git a/flake.lock b/flake.lock index bb96c58..e265ae7 100644 --- a/flake.lock +++ b/flake.lock @@ -6,12 +6,12 @@ }, "locked": { "lastModified": 1, - "narHash": "sha256-tTlcmV5iVVQc2V6Nb14ZDJy6HXQAcGX873wszn9DqpA=", - "path": "/nix/store/4al0ybv47gjla7pxjya4af63309cpwbm-source/core_lib", + "narHash": "sha256-hoESxrqOcGMGcBnSPbSsy08SiMdkuYWRJhkHGOz8LeE=", + "path": "/nix/store/crv49m16an4db4pg9mkm83rjf1m4ns8h-source/core_lib", "type": "path" }, "original": { - "path": "/nix/store/4al0ybv47gjla7pxjya4af63309cpwbm-source/core_lib", + "path": "/nix/store/crv49m16an4db4pg9mkm83rjf1m4ns8h-source/core_lib", "type": "path" } }, diff --git a/flake.nix b/flake.nix index d7059f4..fc4af0c 100644 --- a/flake.nix +++ b/flake.nix @@ -20,18 +20,37 @@ packages = forAllSystems (system: with spkgs system; rec { remote2 = inputs.nixpkgs2.legacyPackages.${system}; tauri = remote2.pkgs.cargo-tauri; - corelib = inputs.corelib.outputs.packages.${system}.default; - rquickshare = rustPlatform.buildRustPackage rec { + corelib_pkgs = inputs.corelib.outputs.packages.${system}; + corelib_src = corelib_pkgs.rqscore_src; + corelib_vendored = (stdenvNoCC.mkDerivation { + name = "cargo-vendor"; + src = corelib_src; + phases = [ "installPhase" ]; + installPhase = '' + mkdir -p $out/rqs_lib + cp -r $src/* $out/rqs_lib + ''; + }); + deps_vendored = (rustPlatform.importCargoLock { + lockFile = app/main/src-tauri/Cargo.lock; + outputHashes = { + "mdns-sd-0.10.4" = "sha256-y8pHtG7JCJvmWCDlWuJWJDbCGOheD4PN+WmOxnakbE4="; + }; + }); + cargo_vendor_dir = symlinkJoin { + name = "cargo-vendor"; + paths = [ + deps_vendored + corelib_vendored + ]; + }; + vendorDir = "vendorr"; + rquickshare = stdenv.mkDerivation rec { name = "rquickshare"; src = ./app/main; nativeBuildInputs = [ tauri.hook pnpm.configHook nodejs moreutils ]; cargoRoot = "src-tauri"; - cargoLock = { - lockFile = app/main/src-tauri/Cargo.lock; - outputHashes = { - "mdns-sd-0.10.4" = "sha256-y8pHtG7JCJvmWCDlWuJWJDbCGOheD4PN+WmOxnakbE4="; - }; - }; + cargoDeps = vendorDir; pnpmDeps = pnpm.fetchDeps { inherit src; pname = name; @@ -39,8 +58,10 @@ }; # remove macOS signing and relative links postConfigure = '' - ${jq}/bin/jq -i 'del(.bundle.macOS.signingIdentity, .bundle.macOS.hardenedRuntime)' src-tauri/tauri.conf.json | sponge src-tauri/tauri.conf.json - ${yq}/bin/yq -i '.importers.".".dependencies."@martichou/core_lib".specifier = "link:${corelib}" | .importers.".".dependencies."@martichou/core_lib".version = "link:${corelib}"' pnpm-lock.yaml + ${jq}/bin/jq 'del(.bundle.macOS.signingIdentity, .bundle.macOS.hardenedRuntime)' src-tauri/tauri.conf.json | sponge src-tauri/tauri.conf.json + ${yq}/bin/yq -iy '.importers.".".dependencies."@martichou/core_lib".specifier = "link:${corelib_src}" | .importers.".".dependencies."@martichou/core_lib".version = "link:${corelib_src}"' pnpm-lock.yaml + ${jq}/bin/jq '.dependencies."@martichou/core_lib" = "link:${corelib_src}"' package.json | sponge package.json + cp -r ${cargo_vendor_dir} ${vendorDir} ''; checkPhase = "true"; # idk why checks fail, todo installPhase = let path = "${cargoRoot}/target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/bundle"; in diff --git a/result b/result new file mode 120000 index 0000000..4169b27 --- /dev/null +++ b/result @@ -0,0 +1 @@ +/nix/store/z4xb5w6s7ymdxhr2df65pkjcwg6lxxj9-cargo-vendor \ No newline at end of file From e991e1de57ed8939472f626f12bc1a734d96aae3 Mon Sep 17 00:00:00 2001 From: Hannes <33062605+HannesGitH@users.noreply.github.com> Date: Tue, 12 Nov 2024 17:48:44 +0100 Subject: [PATCH 05/10] remoced build artifact symlinks --- core_lib/result | 1 - result | 1 - 2 files changed, 2 deletions(-) delete mode 120000 core_lib/result delete mode 120000 result diff --git a/core_lib/result b/core_lib/result deleted file mode 120000 index 6d96aba..0000000 --- a/core_lib/result +++ /dev/null @@ -1 +0,0 @@ -/nix/store/pp4a3njkwwizmbkx5nkxx4mq8kn5n6aj-rquickshare-core \ No newline at end of file diff --git a/result b/result deleted file mode 120000 index 4169b27..0000000 --- a/result +++ /dev/null @@ -1 +0,0 @@ -/nix/store/z4xb5w6s7ymdxhr2df65pkjcwg6lxxj9-cargo-vendor \ No newline at end of file From 674c183c34c5a4877f0d125fed0f4f160a97992b Mon Sep 17 00:00:00 2001 From: Hannes <33062605+HannesGitH@users.noreply.github.com> Date: Tue, 12 Nov 2024 17:52:32 +0100 Subject: [PATCH 06/10] made it (first party flake build) work ;) --- flake.lock | 6 +++--- flake.nix | 42 +++++++++++++----------------------------- result | 1 + 3 files changed, 17 insertions(+), 32 deletions(-) create mode 120000 result diff --git a/flake.lock b/flake.lock index e265ae7..3005ae1 100644 --- a/flake.lock +++ b/flake.lock @@ -6,12 +6,12 @@ }, "locked": { "lastModified": 1, - "narHash": "sha256-hoESxrqOcGMGcBnSPbSsy08SiMdkuYWRJhkHGOz8LeE=", - "path": "/nix/store/crv49m16an4db4pg9mkm83rjf1m4ns8h-source/core_lib", + "narHash": "sha256-3I2lB6V7aRPR5AGNkJD7VGq6f3fELpgsVg0PQmlK0jU=", + "path": "/nix/store/gwj2lcqnmrcjbxkbmxr69jqhaldkvm7y-source/core_lib", "type": "path" }, "original": { - "path": "/nix/store/crv49m16an4db4pg9mkm83rjf1m4ns8h-source/core_lib", + "path": "/nix/store/gwj2lcqnmrcjbxkbmxr69jqhaldkvm7y-source/core_lib", "type": "path" } }, diff --git a/flake.nix b/flake.nix index fc4af0c..74b591d 100644 --- a/flake.nix +++ b/flake.nix @@ -22,35 +22,18 @@ tauri = remote2.pkgs.cargo-tauri; corelib_pkgs = inputs.corelib.outputs.packages.${system}; corelib_src = corelib_pkgs.rqscore_src; - corelib_vendored = (stdenvNoCC.mkDerivation { - name = "cargo-vendor"; - src = corelib_src; - phases = [ "installPhase" ]; - installPhase = '' - mkdir -p $out/rqs_lib - cp -r $src/* $out/rqs_lib - ''; - }); - deps_vendored = (rustPlatform.importCargoLock { - lockFile = app/main/src-tauri/Cargo.lock; - outputHashes = { - "mdns-sd-0.10.4" = "sha256-y8pHtG7JCJvmWCDlWuJWJDbCGOheD4PN+WmOxnakbE4="; - }; - }); - cargo_vendor_dir = symlinkJoin { - name = "cargo-vendor"; - paths = [ - deps_vendored - corelib_vendored - ]; - }; - vendorDir = "vendorr"; - rquickshare = stdenv.mkDerivation rec { + corelib_path = "rqs_lib"; + rquickshare = rustPlatform.buildRustPackage rec { name = "rquickshare"; src = ./app/main; - nativeBuildInputs = [ tauri.hook pnpm.configHook nodejs moreutils ]; + nativeBuildInputs = [ tauri.hook pnpm.configHook nodejs moreutils protobuf ]; cargoRoot = "src-tauri"; - cargoDeps = vendorDir; + cargoLock = { + lockFile = app/main/src-tauri/Cargo.lock; + outputHashes = { + "mdns-sd-0.10.4" = "sha256-y8pHtG7JCJvmWCDlWuJWJDbCGOheD4PN+WmOxnakbE4="; + }; + }; pnpmDeps = pnpm.fetchDeps { inherit src; pname = name; @@ -59,9 +42,10 @@ # remove macOS signing and relative links postConfigure = '' ${jq}/bin/jq 'del(.bundle.macOS.signingIdentity, .bundle.macOS.hardenedRuntime)' src-tauri/tauri.conf.json | sponge src-tauri/tauri.conf.json - ${yq}/bin/yq -iy '.importers.".".dependencies."@martichou/core_lib".specifier = "link:${corelib_src}" | .importers.".".dependencies."@martichou/core_lib".version = "link:${corelib_src}"' pnpm-lock.yaml - ${jq}/bin/jq '.dependencies."@martichou/core_lib" = "link:${corelib_src}"' package.json | sponge package.json - cp -r ${cargo_vendor_dir} ${vendorDir} + ${yq}/bin/yq -iy '.importers.".".dependencies."@martichou/core_lib".specifier = "link:${corelib_path}" | .importers.".".dependencies."@martichou/core_lib".version = "link:${corelib_path}"' pnpm-lock.yaml + ${jq}/bin/jq '.dependencies."@martichou/core_lib" = "link:${corelib_path}"' package.json | sponge package.json + sed -i 's|path = "../../../core_lib"|path = "${corelib_path}"|' ${cargoRoot}/Cargo.toml + cp -r ${corelib_src} ${cargoRoot}/${corelib_path} && chmod -R +w ${cargoRoot}/${corelib_path} ''; checkPhase = "true"; # idk why checks fail, todo installPhase = let path = "${cargoRoot}/target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/bundle"; in diff --git a/result b/result new file mode 120000 index 0000000..b66af88 --- /dev/null +++ b/result @@ -0,0 +1 @@ +/nix/store/5f2yzrciw4hds9957x4vg2krqhzxrpdl-rquickshare \ No newline at end of file From 2f86fe7853a6a2bc3686a75fff4faa9b1ab82250 Mon Sep 17 00:00:00 2001 From: Hannes <33062605+HannesGitH@users.noreply.github.com> Date: Tue, 12 Nov 2024 17:53:24 +0100 Subject: [PATCH 07/10] rm flake build artifact --- result | 1 - 1 file changed, 1 deletion(-) delete mode 120000 result diff --git a/result b/result deleted file mode 120000 index b66af88..0000000 --- a/result +++ /dev/null @@ -1 +0,0 @@ -/nix/store/5f2yzrciw4hds9957x4vg2krqhzxrpdl-rquickshare \ No newline at end of file From 8737a5da529ee6da05749b36bde25c94cead59c8 Mon Sep 17 00:00:00 2001 From: Hannes <33062605+HannesGitH@users.noreply.github.com> Date: Sun, 17 Nov 2024 19:27:02 +0100 Subject: [PATCH 08/10] dropped nixpkgs2 dep as tauri2 is now upstream --- flake.lock | 29 ++++++----------------------- flake.nix | 5 +---- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/flake.lock b/flake.lock index 3005ae1..199fbef 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ "locked": { "lastModified": 1, "narHash": "sha256-3I2lB6V7aRPR5AGNkJD7VGq6f3fELpgsVg0PQmlK0jU=", - "path": "/nix/store/gwj2lcqnmrcjbxkbmxr69jqhaldkvm7y-source/core_lib", + "path": "/nix/store/hligicv9b7vcs5vvzh14ngmgrgr30rmi-source/core_lib", "type": "path" }, "original": { - "path": "/nix/store/gwj2lcqnmrcjbxkbmxr69jqhaldkvm7y-source/core_lib", + "path": "/nix/store/hligicv9b7vcs5vvzh14ngmgrgr30rmi-source/core_lib", "type": "path" } }, @@ -31,29 +31,13 @@ "type": "github" } }, - "nixpkgs2": { - "locked": { - "lastModified": 1731271174, - "narHash": "sha256-lZEJ73HJ7fzRZPjIagxhwV7MjioKAU6VnvPoXqSmxJw=", - "owner": "hannesGitH", - "repo": "nixpkgs", - "rev": "4aceccb616087967966a2c1c3837cff9922816a4", - "type": "github" - }, - "original": { - "owner": "hannesGitH", - "ref": "tauri2", - "repo": "nixpkgs", - "type": "github" - } - }, "nixpkgs_2": { "locked": { - "lastModified": 1731139594, - "narHash": "sha256-IigrKK3vYRpUu+HEjPL/phrfh7Ox881er1UEsZvw9Q4=", + "lastModified": 1731676054, + "narHash": "sha256-OZiZ3m8SCMfh3B6bfGC/Bm4x3qc1m2SVEAlkV6iY7Yg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "76612b17c0ce71689921ca12d9ffdc9c23ce40b2", + "rev": "5e4fbfb6b3de1aa2872b76d49fafc942626e2add", "type": "github" }, "original": { @@ -66,8 +50,7 @@ "root": { "inputs": { "corelib": "corelib", - "nixpkgs": "nixpkgs_2", - "nixpkgs2": "nixpkgs2" + "nixpkgs": "nixpkgs_2" } } }, diff --git a/flake.nix b/flake.nix index 74b591d..68e21f4 100644 --- a/flake.nix +++ b/flake.nix @@ -3,8 +3,6 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; - # as upstream nixpkgs doesn't have tauri 2, we use a fork - nixpkgs2.url = "github:hannesGitH/nixpkgs?ref=tauri2"; corelib.url = "./core_lib"; }; @@ -18,8 +16,7 @@ in { packages = forAllSystems (system: with spkgs system; rec { - remote2 = inputs.nixpkgs2.legacyPackages.${system}; - tauri = remote2.pkgs.cargo-tauri; + tauri = cargo-tauri; corelib_pkgs = inputs.corelib.outputs.packages.${system}; corelib_src = corelib_pkgs.rqscore_src; corelib_path = "rqs_lib"; From f7d48ef2d0e5249a4192ab34f6fbfd66f4d54498 Mon Sep 17 00:00:00 2001 From: Hannes <33062605+HannesGitH@users.noreply.github.com> Date: Sun, 17 Nov 2024 19:38:45 +0100 Subject: [PATCH 09/10] relock --- flake.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.lock b/flake.lock index 199fbef..d7b0895 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ "locked": { "lastModified": 1, "narHash": "sha256-3I2lB6V7aRPR5AGNkJD7VGq6f3fELpgsVg0PQmlK0jU=", - "path": "/nix/store/hligicv9b7vcs5vvzh14ngmgrgr30rmi-source/core_lib", + "path": "/nix/store/hqs54wki1cv48pipd0kkx7xwr9mvwyb7-source/core_lib", "type": "path" }, "original": { - "path": "/nix/store/hligicv9b7vcs5vvzh14ngmgrgr30rmi-source/core_lib", + "path": "/nix/store/hqs54wki1cv48pipd0kkx7xwr9mvwyb7-source/core_lib", "type": "path" } }, From 7e7185354f7d5cfb7d4d76d8c3ea73c890585646 Mon Sep 17 00:00:00 2001 From: Hannes <33062605+HannesGitH@users.noreply.github.com> Date: Wed, 20 Nov 2024 23:42:47 +0100 Subject: [PATCH 10/10] flake: more in line with downstream --- core_lib/flake.lock | 27 -------- core_lib/flake.nix | 33 ---------- flake.lock | 40 ++---------- flake.nix | 147 +++++++++++++++++++++++++++++--------------- 4 files changed, 103 insertions(+), 144 deletions(-) delete mode 100644 core_lib/flake.lock delete mode 100644 core_lib/flake.nix diff --git a/core_lib/flake.lock b/core_lib/flake.lock deleted file mode 100644 index e3a64e1..0000000 --- a/core_lib/flake.lock +++ /dev/null @@ -1,27 +0,0 @@ -{ - "nodes": { - "nixpkgs": { - "locked": { - "lastModified": 1731139594, - "narHash": "sha256-IigrKK3vYRpUu+HEjPL/phrfh7Ox881er1UEsZvw9Q4=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "76612b17c0ce71689921ca12d9ffdc9c23ce40b2", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/core_lib/flake.nix b/core_lib/flake.nix deleted file mode 100644 index 3b2aa63..0000000 --- a/core_lib/flake.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ - description = "rquickshare-core flake"; - - inputs = { - nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; - }; - - outputs = inputs@{ nixpkgs, ... }: - let - inherit (nixpkgs) lib; - # definitely not tested, but i like it exposed, who knows - systems = lib.systems.flakeExposed; - forAllSystems = lib.genAttrs systems; - spkgs = system : nixpkgs.legacyPackages.${system}.pkgs; - in - { - packages = forAllSystems (system: with spkgs system; rec { - rqscore_src = rqscore.src; - rqscore = rustPlatform.buildRustPackage { - name = "rquickshare-core"; - src = ./.; - nativeBuildInputs = [ protobuf ]; - cargoLock = { - lockFile = ./Cargo.lock; - outputHashes = { - "mdns-sd-0.10.4" = "sha256-y8pHtG7JCJvmWCDlWuJWJDbCGOheD4PN+WmOxnakbE4="; - }; - }; - }; - default = rqscore; - }); - }; -} diff --git a/flake.lock b/flake.lock index d7b0895..1720cb2 100644 --- a/flake.lock +++ b/flake.lock @@ -1,43 +1,12 @@ { "nodes": { - "corelib": { - "inputs": { - "nixpkgs": "nixpkgs" - }, - "locked": { - "lastModified": 1, - "narHash": "sha256-3I2lB6V7aRPR5AGNkJD7VGq6f3fELpgsVg0PQmlK0jU=", - "path": "/nix/store/hqs54wki1cv48pipd0kkx7xwr9mvwyb7-source/core_lib", - "type": "path" - }, - "original": { - "path": "/nix/store/hqs54wki1cv48pipd0kkx7xwr9mvwyb7-source/core_lib", - "type": "path" - } - }, "nixpkgs": { "locked": { - "lastModified": 1731139594, - "narHash": "sha256-IigrKK3vYRpUu+HEjPL/phrfh7Ox881er1UEsZvw9Q4=", + "lastModified": 1732014248, + "narHash": "sha256-y/MEyuJ5oBWrWAic/14LaIr/u5E0wRVzyYsouYY3W6w=", "owner": "nixos", "repo": "nixpkgs", - "rev": "76612b17c0ce71689921ca12d9ffdc9c23ce40b2", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1731676054, - "narHash": "sha256-OZiZ3m8SCMfh3B6bfGC/Bm4x3qc1m2SVEAlkV6iY7Yg=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "5e4fbfb6b3de1aa2872b76d49fafc942626e2add", + "rev": "23e89b7da85c3640bbc2173fe04f4bd114342367", "type": "github" }, "original": { @@ -49,8 +18,7 @@ }, "root": { "inputs": { - "corelib": "corelib", - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index 68e21f4..0984a28 100644 --- a/flake.nix +++ b/flake.nix @@ -3,65 +3,116 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; - corelib.url = "./core_lib"; }; - outputs = inputs@{ nixpkgs, ... }: + outputs = + inputs@{ nixpkgs, ... }: let inherit (nixpkgs) lib; # definitely not tested, but i like it exposed, who knows systems = lib.systems.flakeExposed; forAllSystems = lib.genAttrs systems; - spkgs = system : nixpkgs.legacyPackages.${system}.pkgs; + spkgs = system: nixpkgs.legacyPackages.${system}.pkgs; in { - packages = forAllSystems (system: with spkgs system; rec { - tauri = cargo-tauri; - corelib_pkgs = inputs.corelib.outputs.packages.${system}; - corelib_src = corelib_pkgs.rqscore_src; - corelib_path = "rqs_lib"; - rquickshare = rustPlatform.buildRustPackage rec { - name = "rquickshare"; - src = ./app/main; - nativeBuildInputs = [ tauri.hook pnpm.configHook nodejs moreutils protobuf ]; - cargoRoot = "src-tauri"; - cargoLock = { - lockFile = app/main/src-tauri/Cargo.lock; - outputHashes = { - "mdns-sd-0.10.4" = "sha256-y8pHtG7JCJvmWCDlWuJWJDbCGOheD4PN+WmOxnakbE4="; + packages = forAllSystems ( + system: with spkgs system; rec { + tauri = cargo-tauri; + # we could use rustPlatform.buildRustPackage, but there cargoDeps doesn't work + rquickshare = let + pname = "rquickshare"; + src = let fs = lib.fileset; in fs.toSource { + root = ./.; + fileset = fs.difference ./. ( + fs.unions [ + ./flake.nix + ./flake.lock + ] + ); + }; + in + stdenv.mkDerivation rec { + inherit src pname; + name = pname; + sourceRoot = "${src.name}/app/main"; + corelibSourceRoot = "${src.name}/core_lib"; + cargoRoot = "src-tauri"; + corelibPath = "rqs_lib"; + nativeBuildInputs = [ + tauri.hook + pnpm.configHook + nodejs + moreutils + protobuf + jq + yq + rustPlatform.cargoSetupHook + ]; + # seemingly the fetcher ignores cargoRoot (contrary to the docs) + cargoDeps = rustPlatform.fetchCargoVendor { + inherit src pname; + hash = cargoHash; + sourceRoot = "${sourceRoot}/${cargoRoot}"; + }; + cargoHash = "sha256-m+BHN0eCF8rwCBWQ94XWHP7vmtQMtT/9adFgcU0BDTQ="; + pnpmDeps = pnpm.fetchDeps { + inherit src sourceRoot pname; + hash = "sha256-ko0S934TnGDVbTrFkunHPt0e/pT5CVi4yorTi0WYqmc="; + }; + postUnpack = + let + fullCorePath = "${sourceRoot}/${cargoRoot}/${corelibPath}"; + in + '' + cp -r ${corelibSourceRoot} ${fullCorePath} && chmod -R +w ${fullCorePath} + ''; + # remove macOS signing and relative links + postConfigure = '' + jq 'del(.bundle.macOS.signingIdentity, .bundle.macOS.hardenedRuntime)' src-tauri/tauri.conf.json | sponge src-tauri/tauri.conf.json + yq -iy '.importers.".".dependencies."@martichou/core_lib".specifier = "link:${corelibPath}" | .importers.".".dependencies."@martichou/core_lib".version = "link:${corelibPath}"' pnpm-lock.yaml + jq '.dependencies."@martichou/core_lib" = "link:${corelibPath}"' package.json | sponge package.json + sed -i 's|path = "../../../core_lib"|path = "${corelibPath}"|' ${cargoRoot}/Cargo.toml + ''; + checkPhase = "true"; # idk why checks fail, todo + installPhase = + let + path = "${cargoRoot}/target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/bundle"; + in + if stdenv.isDarwin then + '' + mkdir -p $out/bin + mv ${path}/macos $out/Applications + echo "#!${lib.getExe zsh}" >> $out/bin/${name} + echo "open -a $out/Applications/${name}.app" >> $out/bin/${name} + chmod +x $out/bin/${name} + '' + else + '' + mv ${path}/deb/*/data/usr $out + ''; + meta = { + description = "Rust implementation of NearbyShare/QuickShare from Android for Linux"; + homepage = "https://github.com/Martichou/rquickshare"; + changelog = "https://github.com/Martichou/rquickshare/blob/master/CHANGELOG.md"; + license = lib.licenses.gpl3Plus; + maintainers = with lib.maintainers; [ hannesgith ]; + platforms = with lib.platforms; linux ++ darwin; + mainProgram = "rquickshare"; }; }; - pnpmDeps = pnpm.fetchDeps { - inherit src; - pname = name; - hash = "sha256-ko0S934TnGDVbTrFkunHPt0e/pT5CVi4yorTi0WYqmc="; + default = rquickshare; + } + ); + devShells = forAllSystems ( + system: with spkgs system; { + default = mkShell { + buildInputs = [ + cargo + rustc + nodejs + ]; }; - # remove macOS signing and relative links - postConfigure = '' - ${jq}/bin/jq 'del(.bundle.macOS.signingIdentity, .bundle.macOS.hardenedRuntime)' src-tauri/tauri.conf.json | sponge src-tauri/tauri.conf.json - ${yq}/bin/yq -iy '.importers.".".dependencies."@martichou/core_lib".specifier = "link:${corelib_path}" | .importers.".".dependencies."@martichou/core_lib".version = "link:${corelib_path}"' pnpm-lock.yaml - ${jq}/bin/jq '.dependencies."@martichou/core_lib" = "link:${corelib_path}"' package.json | sponge package.json - sed -i 's|path = "../../../core_lib"|path = "${corelib_path}"|' ${cargoRoot}/Cargo.toml - cp -r ${corelib_src} ${cargoRoot}/${corelib_path} && chmod -R +w ${cargoRoot}/${corelib_path} - ''; - checkPhase = "true"; # idk why checks fail, todo - installPhase = let path = "${cargoRoot}/target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/bundle"; in - if stdenv.isDarwin then '' - mkdir -p $out/bin - mv ${path}/macos $out/Applications - echo "#!${zsh}/bin/zsh" >> $out/bin/${name} - echo "open -a $out/Applications/${name}.app" >> $out/bin/${name} - chmod +x $out/bin/${name} - '' else '' - mv ${path}/deb/*/data/usr $out - ''; - }; - default = rquickshare; - }); - devShells = forAllSystems (system: with spkgs system; { - default = mkShell { - buildInputs = [ cargo rustc nodejs ]; - }; - }); + } + ); }; }