Merge pull request #2076 from FliegendeWurst/flake-1

feat(flake): desktop item, wrapped binary
This commit is contained in:
Elian Doran 2025-05-31 20:00:52 +03:00 committed by GitHub
commit 0e4ad86fbd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 67 additions and 17 deletions

8
flake.lock generated
View File

@ -20,16 +20,16 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1748460289, "lastModified": 1748437600,
"narHash": "sha256-7doLyJBzCllvqX4gszYtmZUToxKvMUrg45EUWaUYmBg=", "narHash": "sha256-hYKMs3ilp09anGO7xzfGs3JqEgUqFMnZ8GMAqI6/k04=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "96ec055edbe5ee227f28cdbc3f1ddf1df5965102", "rev": "7282cb574e0607e65224d33be8241eae7cfe0979",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nixos", "owner": "nixos",
"ref": "nixos-unstable", "ref": "nixos-25.05",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }

View File

@ -1,28 +1,50 @@
{ {
description = "A very basic flake"; description = "TriliumNext Notes (experimental flake)";
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
}; };
outputs = { self, nixpkgs, flake-utils }: outputs =
flake-utils.lib.eachDefaultSystem (system: {
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let let
packageJSON = builtins.fromJSON (builtins.readFile ./package.json);
pkgs = import nixpkgs { inherit system; }; pkgs = import nixpkgs { inherit system; };
electron = pkgs.electron_35; electron = pkgs.electron_35;
build = pkgs.stdenv.mkDerivation (finalAttrs: { inherit (pkgs)
copyDesktopItems
lib
makeBinaryWrapper
makeDesktopItem
nodejs
pnpm
stdenv
wrapGAppsHook3
;
desktop = stdenv.mkDerivation (finalAttrs: {
pname = "triliumnext-desktop"; pname = "triliumnext-desktop";
version = "0.94.0"; version = packageJSON.version;
src = pkgs.lib.cleanSource ./.; src = lib.cleanSource ./.;
nativeBuildInputs = with pkgs; [ nativeBuildInputs = [
pnpm.configHook pnpm.configHook
nodejs nodejs
nodejs.python nodejs.python
copyDesktopItems
makeBinaryWrapper
wrapGAppsHook3
]; ];
buildPhase = '' buildPhase = ''
runHook preBuild
# Disable NX interaction # Disable NX interaction
export NX_TUI=false export NX_TUI=false
export NX_DAEMON=false export NX_DAEMON=false
@ -33,20 +55,48 @@
# Rebuild dependencies # Rebuild dependencies
export npm_config_nodedir=${electron.headers} export npm_config_nodedir=${electron.headers}
pnpm nx run desktop:rebuild-deps --outputStyle stream --verbose pnpm nx run desktop:rebuild-deps --outputStyle stream --verbose
runHook postBuild
''; '';
installPhase = '' installPhase = ''
mkdir -p $out runHook preInstall
cp -r apps/desktop/dist $out
mkdir -p $out/{bin,opt/trilium}
cp --archive apps/desktop/dist/* $out/opt/trilium
makeWrapper ${lib.getExe electron} $out/bin/trilium \
"''${gappsWrapperArgs[@]}" \
--set-default ELECTRON_IS_DEV 0 \
--add-flags $out/opt/trilium/main.cjs
runHook postInstall
''; '';
pnpmDeps = pkgs.pnpm.fetchDeps { desktopItems = [
(makeDesktopItem {
name = "TriliumNext Notes";
exec = finalAttrs.meta.mainProgram;
icon = "trilium";
comment = finalAttrs.meta.description;
desktopName = "TriliumNext Notes";
categories = [ "Office" ];
startupWMClass = "Trilium Notes Next";
})
];
pnpmDeps = pnpm.fetchDeps {
inherit (finalAttrs) pname version src; inherit (finalAttrs) pname version src;
hash = "sha256-xC0u1h92wtthylOAw+IF9mpFi0c4xajJhUcA9pqzcAw="; hash = "sha256-xC0u1h92wtthylOAw+IF9mpFi0c4xajJhUcA9pqzcAw=";
}; };
meta = {
description = "Free and open-source, cross-platform hierarchical note taking application with focus on building large personal knowledge bases";
mainProgram = "trilium";
};
}); });
in { in
packages.default = build; {
packages.default = desktop;
} }
); );
} }