This commit is contained in:
Alois 2026-07-21 11:39:28 +02:00
commit f41cf7cfa4
Signed by: alois
SSH key fingerprint: SHA256:GBzT2DXvAuGV9XIV5W3WrzVpjU54FThmxHXdbz95J24

View file

@ -6,22 +6,27 @@
rust-overlay.url = "github:oxalica/rust-overlay"; rust-overlay.url = "github:oxalica/rust-overlay";
}; };
outputs = { outputs =
{
self, self,
nixpkgs, nixpkgs,
rust-overlay, rust-overlay,
... ...
}: let }:
systems = ["x86_64-linux"]; let
systems = [ "x86_64-linux" ];
forAllSystems = nixpkgs.lib.genAttrs systems; forAllSystems = nixpkgs.lib.genAttrs systems;
version = "0.0.10"; version = "0.0.10";
x86_64DebHash = "sha256-9s47HyPJf/6yA6XGgKBJ+60gTXLTV/jvE2tS/Fth8zA="; x86_64DebHash = "sha256-VVKkZ9yQ7BoLnYnCf5OSHcrakoBNfUx/uWxBmm3gBZE=";
forgejoBaseUrl = "https://git.methanium.net/tensamin/client/releases/download/${version}"; forgejoBaseUrl = "https://git.methanium.net/tensamin/client/releases/download/${version}";
in { in
packages = forAllSystems (system: let {
packages = forAllSystems (
system:
let
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
overlays = [(import rust-overlay)]; overlays = [ (import rust-overlay) ];
config = { config = {
allowUnfree = true; allowUnfree = true;
android_sdk.accept_license = true; android_sdk.accept_license = true;
@ -69,7 +74,8 @@
libXtst libXtst
libxcb libxcb
]; ];
packageDeb = src: packageDeb =
src:
pkgs.stdenv.mkDerivation { pkgs.stdenv.mkDerivation {
pname = "tensamin"; pname = "tensamin";
inherit version src; inherit version src;
@ -100,40 +106,47 @@
mkdir -p "$out/bin" mkdir -p "$out/bin"
makeWrapper "$out/opt/Tensamin/tensamin" "$out/bin/tensamin" makeWrapper "$out/opt/Tensamin/tensamin" "$out/bin/tensamin"
substituteInPlace "$out/share/applications/tensamin.desktop" \ substituteInPlace "$out/share/applications/Tensamin.desktop" \
--replace-fail "Exec=/opt/Tensamin/tensamin" "Exec=tensamin" --replace-fail "Exec=/opt/Tensamin/tensamin" "Exec=tensamin"
runHook postInstall runHook postInstall
''; '';
}; };
defaultPackage = packageDeb (pkgs.fetchurl { defaultPackage = packageDeb (
pkgs.fetchurl {
url = "${forgejoBaseUrl}/${debArtifact}"; url = "${forgejoBaseUrl}/${debArtifact}";
hash = x86_64DebHash; hash = x86_64DebHash;
}); }
);
localDebPath = builtins.getEnv "TENSAMIN_DEB"; localDebPath = builtins.getEnv "TENSAMIN_DEB";
localPathPackage = localPathPackage =
if localDebPath == "" if localDebPath == "" then
then
pkgs.writeShellScriptBin "tensamin" '' pkgs.writeShellScriptBin "tensamin" ''
echo "Set TENSAMIN_DEB to a local .deb path and run with --impure." >&2 echo "Set TENSAMIN_DEB to a local .deb path and run with --impure." >&2
exit 1 exit 1
'' ''
else else
packageDeb (builtins.path { packageDeb (
builtins.path {
path = localDebPath; path = localDebPath;
name = debArtifact; name = debArtifact;
}); }
in { );
in
{
default = defaultPackage; default = defaultPackage;
tensamin = defaultPackage; tensamin = defaultPackage;
electron = defaultPackage; electron = defaultPackage;
localPathForDev = localPathPackage; localPathForDev = localPathPackage;
}); }
);
devShells = forAllSystems (system: let devShells = forAllSystems (
system:
let
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
overlays = [(import rust-overlay)]; overlays = [ (import rust-overlay) ];
config = { config = {
allowUnfree = true; allowUnfree = true;
android_sdk.accept_license = true; android_sdk.accept_license = true;
@ -187,16 +200,22 @@
cmdLineToolsVersion = "8.0"; cmdLineToolsVersion = "8.0";
toolsVersion = "26.1.1"; toolsVersion = "26.1.1";
platformToolsVersion = "35.0.2"; platformToolsVersion = "35.0.2";
buildToolsVersions = [buildToolsVersion]; buildToolsVersions = [ buildToolsVersion ];
platformVersions = ["35" "36"]; platformVersions = [
"35"
"36"
];
includeSources = false; includeSources = false;
includeSystemImages = false; includeSystemImages = false;
includeNDK = true; includeNDK = true;
ndkVersions = [ndkVersion]; ndkVersions = [ ndkVersion ];
useGoogleAPIs = false; useGoogleAPIs = false;
}; };
rustToolchain = pkgs.rust-bin.stable.latest.default.override { rustToolchain = pkgs.rust-bin.stable.latest.default.override {
extensions = ["rust-src" "rust-analyzer"]; extensions = [
"rust-src"
"rust-analyzer"
];
targets = [ targets = [
"aarch64-linux-android" "aarch64-linux-android"
"armv7-linux-androideabi" "armv7-linux-androideabi"
@ -206,23 +225,37 @@
]; ];
}; };
commonDeps = [rustToolchain pkgs.wasm-pack pkgs.lld]; commonDeps = [
rustToolchain
pkgs.wasm-pack
pkgs.lld
];
appImageToolsArchive = pkgs.fetchurl { appImageToolsArchive = pkgs.fetchurl {
url = "https://github.com/electron-userland/electron-builder-binaries/releases/download/appimage@1.0.3/appimage-tools-runtime-20251108.tar.gz"; url = "https://github.com/electron-userland/electron-builder-binaries/releases/download/appimage@1.0.3/appimage-tools-runtime-20251108.tar.gz";
hash = "sha256-hAIaeO4hSub9M6LWKpK6JVQt0QvIa/EXqbLQu6ROdmU="; hash = "sha256-hAIaeO4hSub9M6LWKpK6JVQt0QvIa/EXqbLQu6ROdmU=";
}; };
appImageTools = pkgs.runCommand "electron-builder-appimage-tools-nix" {nativeBuildInputs = [pkgs.gnutar pkgs.gzip];} '' appImageTools =
pkgs.runCommand "electron-builder-appimage-tools-nix"
{
nativeBuildInputs = [
pkgs.gnutar
pkgs.gzip
];
}
''
mkdir -p "$out" mkdir -p "$out"
tar -xzf ${appImageToolsArchive} --strip-components=1 -C "$out" tar -xzf ${appImageToolsArchive} --strip-components=1 -C "$out"
rm -f "$out/mksquashfs" "$out/desktop-file-validate" rm -f "$out/mksquashfs" "$out/desktop-file-validate"
ln -s ${pkgs.squashfsTools}/bin/mksquashfs "$out/mksquashfs" ln -s ${pkgs.squashfsTools}/bin/mksquashfs "$out/mksquashfs"
ln -s ${pkgs.desktop-file-utils}/bin/desktop-file-validate "$out/desktop-file-validate" ln -s ${pkgs.desktop-file-utils}/bin/desktop-file-validate "$out/desktop-file-validate"
''; '';
in rec { in
rec {
default = electron; default = electron;
electron = pkgs.mkShell { electron = pkgs.mkShell {
packages = with pkgs; packages =
with pkgs;
[ [
nodejs_22 nodejs_22
corepack_22 corepack_22
@ -245,7 +278,8 @@
xz xz
p7zip p7zip
] ]
++ electronRuntimeLibs ++ commonDeps; ++ electronRuntimeLibs
++ commonDeps;
shellHook = '' shellHook = ''
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath electronRuntimeLibs}:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath electronRuntimeLibs}:$LD_LIBRARY_PATH"
@ -266,7 +300,8 @@
}; };
tauri = pkgs.mkShell { tauri = pkgs.mkShell {
buildInputs = with pkgs; buildInputs =
with pkgs;
[ [
jdk17 jdk17
gradle gradle
@ -340,6 +375,7 @@
fi fi
''; '';
}; };
}); }
);
}; };
} }