From d275b0e783504222e1e7db7983dc563ffd508155 Mon Sep 17 00:00:00 2001 From: doceys Date: Thu, 30 Apr 2026 11:31:47 +0200 Subject: [PATCH] Build on NixOS (#49) feat: add Nix flake for NixOS/darwin builds (#49) --- .gitignore | 3 +++ README.md | 58 +++++++++++++++++++++++++++++++++++++++++ flake.lock | 61 +++++++++++++++++++++++++++++++++++++++++++ flake.nix | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 198 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index 639be47..d81c0ac 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,9 @@ node_modules /.svelte-kit /build +# Nix +/result + # Tauri /src-tauri/target /src-tauri/gen diff --git a/README.md b/README.md index 7a05cc2..5352963 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,64 @@ yay -S helixnotes-appimage-bin curl -fsSL https://repo.arkhost.com/gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/arkhost.gpg && echo "deb [signed-by=/usr/share/keyrings/arkhost.gpg arch=amd64] https://repo.arkhost.com stable main" | sudo tee /etc/apt/sources.list.d/helixnotes.list && sudo apt update && sudo apt install helix-notes ``` +#### NixOS + +
+flake.nix + +```nix +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + helix-notes = { + url = "git+https://codeberg.org/ArkHost/HelixNotes"; + # inputs.nixpkgs.follows = "nixpkgs"; + } + }; + + outputs = { + nixpkgs, + helix-notes, + ... + }: let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + in { + nixosConfigurations.default = nixpkgs.lib.nixosSystem { + system = system; + specialArgs = { inherit helix-notes; }; + + modules = [ + /path/to/configuration.nix + ]; + }; + }; +} +``` +
+ + +
+configuration.nix + +```nix +{ + config, + lib, + pkgs, + helix-notes, + ... +}: +{ + users.users. = { + packages = with pkgs; [ + (helix-notes.packages.${pkgs.stdenv.hostPlatform.system}.default) + ]; + }; +} +``` +
+ #### AppImage (Arch, Fedora 43+, openSUSE Tumbleweed) [Download AppImage](https://download.helixnotes.com/releases/v1.2.9/HelixNotes_1.2.9_amd64.AppImage) diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..3f06416 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1777268161, + "narHash": "sha256-bxrdOn8SCOv8tN4JbTF/TXq7kjo9ag4M+C8yzzIRYbE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1c3fe55ad329cbcb28471bb30f05c9827f724c76", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..758a9c4 --- /dev/null +++ b/flake.nix @@ -0,0 +1,76 @@ +{ + description = "HelixNotes (local Markdown notes app) with Nix flake"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { + self, + nixpkgs, + flake-utils, + }: + flake-utils.lib.eachDefaultSystem (system: let + pkgs = import nixpkgs {inherit system;}; + + cargoToml = builtins.fromTOML (builtins.readFile ./src-tauri/Cargo.toml); + pname = cargoToml.package.name; + version = cargoToml.package.version; + in { + packages.default = pkgs.rustPlatform.buildRustPackage { + inherit pname version; + src = ./.; + + cargoHash = "sha256-Xk3+a4FION/b0Ktp3SpA5w7uatt96uSEadV9t2bZqw8="; + + pnpmDeps = pkgs.fetchPnpmDeps { + inherit pname version; + src = ./.; + fetcherVersion = 3; + hash = "sha256-Odmd1gwioCvnnExvCOQwDPCgLyrBfTpeUKHy3BrNtiM="; + }; + + nativeBuildInputs = with pkgs; [ + cargo-tauri.hook + + pnpmConfigHook + pnpm + nodejs + + pkg-config + jq + moreutils + wrapGAppsHook3 + ]; + + buildInputs = with pkgs; + lib.optionals stdenv.hostPlatform.isLinux [ + webkitgtk_4_1 + libayatana-appindicator + ]; + + cargoRoot = "src-tauri"; + buildAndTestSubdir = self.packages.${system}.default.cargoRoot; + + # Deactivate the upstream update mechanism + postPatch = '' + jq ' + .bundle.createUpdaterArtifacts = false | + .plugins.updater = {"active": false, "pubkey": "", "endpoints": []} + ' \ + src-tauri/tauri.conf.json | sponge src-tauri/tauri.conf.json + ''; + + meta = with pkgs.lib; { + description = "HelixNotes desktop application"; + homepage = "https://helixnotes.com/"; + license = licenses.agpl3Plus; + platforms = platforms.linux ++ platforms.darwin; + mainProgram = "helixnotes"; + }; + }; + + formatter = pkgs.alejandra; + }); +}