-
Notifications
You must be signed in to change notification settings - Fork 128
Add Nix flake and systemd deployment for Alby Hub #2142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,4 +30,4 @@ glalby | |
| *.db-shm | ||
| *.db-wal | ||
| *.db-journal | ||
| albyhub-data | ||
| albyhub-dataresult | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Alby Hub Nix Installation | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ```bash | ||
| ./deploy.sh | ||
| ``` | ||
|
|
||
| This will: | ||
| - Build Alby Hub with Nix | ||
| - Install as user systemd service | ||
| - Run on port 8087 | ||
| - Store data in `~/.local/share/albyhub` | ||
|
|
||
| ## Access | ||
|
|
||
| Open browser to: `http://localhost:8087` | ||
|
|
||
| ## Manage Service | ||
|
|
||
| ```bash | ||
| # Check status | ||
| systemctl --user status albyhub | ||
|
|
||
| # View logs | ||
| journalctl --user -u albyhub -f | ||
|
|
||
| # Stop service | ||
| systemctl --user stop albyhub | ||
|
|
||
| # Restart service | ||
| systemctl --user restart albyhub | ||
| ``` | ||
|
|
||
| ## Files | ||
|
|
||
| - `flake.nix` - Nix flake configuration | ||
| - `albyhub.service` - Systemd service template | ||
| - `deploy.sh` - Build and deploy script |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| [Unit] | ||
| Description=Alby Hub - Lightning Wallet Service | ||
| After=network.target | ||
|
|
||
| [Service] | ||
| Type=simple | ||
| WorkingDirectory=%h/.local/share/albyhub | ||
| ExecStart=STORE_PATH_PLACEHOLDER/bin/albyhub | ||
| Restart=always | ||
| RestartSec=10 | ||
|
|
||
| Environment="WORK_DIR=%h/.local/share/albyhub" | ||
| Environment="PORT=8087" | ||
|
|
||
| [Install] | ||
| WantedBy=default.target |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,35 @@ | ||||||
| #!/usr/bin/env bash | ||||||
| set -e | ||||||
|
|
||||||
| echo "=== Deploying Alby Hub ===" | ||||||
|
|
||||||
| # Build with Nix | ||||||
| nix build --impure | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify impure flag is removed and default flake output is buildable.
rg -n -- '--impure' deploy.sh
rg -n 'nix build' deploy.sh
nix build .#default --dry-runRepository: getAlby/hub Length of output: 157 🏁 Script executed: fd -name "flake.nix" -o -name "flake.lock"Repository: getAlby/hub Length of output: 285 🏁 Script executed: rg -n "default\s*=" | head -20Repository: getAlby/hub Length of output: 287 🏁 Script executed: cat -n deploy.shRepository: getAlby/hub Length of output: 1116 Avoid impure builds in deployment. Line 7 uses Suggested change-nix build --impure
+nix build .#default📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| # Get Nix store path | ||||||
| STORE_PATH=$(readlink -f result) | ||||||
| echo "Built: $STORE_PATH" | ||||||
|
|
||||||
| # Create data directory | ||||||
| mkdir -p ~/.local/share/albyhub | ||||||
|
|
||||||
| # Generate systemd service | ||||||
| sed "s|STORE_PATH_PLACEHOLDER|$STORE_PATH|g" albyhub.service > albyhub-generated.service | ||||||
|
|
||||||
| echo "" | ||||||
| echo "=== Install ===" | ||||||
| echo "1. Systemd:" | ||||||
| mkdir -p ~/.config/systemd/user/ | ||||||
| cp albyhub-generated.service ~/.config/systemd/user/albyhub.service | ||||||
| systemctl --user daemon-reload | ||||||
| systemctl --user enable albyhub | ||||||
| systemctl --user restart albyhub | ||||||
| echo " ✅ Service restarted" | ||||||
| echo "" | ||||||
| echo "2. Status:" | ||||||
| systemctl --user status albyhub --no-pager | ||||||
| echo "" | ||||||
| echo "3. Access:" | ||||||
| echo " http://localhost:8087" | ||||||
| echo "" | ||||||
| echo "View logs: journalctl --user -u albyhub -f" | ||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,32 @@ | ||||||
| { | ||||||
| description = "Alby Hub - Your Own Center for Internet Money"; | ||||||
|
|
||||||
| 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 = nixpkgs.legacyPackages.${system}; | ||||||
| in | ||||||
| { | ||||||
| packages.default = pkgs.callPackage /mnt/data1/time2/time/2023/07/06/nixpkgs/pkgs/by-name/al/albyhub/package.nix { }; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify no absolute callPackage path remains, and default package is exposed.
rg -n 'callPackage\s+/' flake.nix
nix flake show . | rg -n 'packages\..*\.default'Repository: getAlby/hub Length of output: 242 🏁 Script executed: # Check the full flake.nix structure to understand nixpkgs setup
cat -n flake.nixRepository: getAlby/hub Length of output: 1089 🏁 Script executed: # Search for albyhub references in the repo
rg -i albyhub --type nixRepository: getAlby/hub Length of output: 270 🏁 Script executed: # Check if package.nix exists at the referenced path (or any package.nix in repo)
fd -name 'package.nix' -type fRepository: getAlby/hub Length of output: 285 🌐 Web query:
💡 Result:
Install on NixOS (system-wide)Add to your configuration (e.g., { pkgs, ... }:
{
environment.systemPackages = [
pkgs.albyhub
];
}Then: sudo nixos-rebuild switchInstall ad-hoc (flakes / CLI)nix shell nixpkgs#albyhub
# or
nix profile install nixpkgs#albyhubNotes
Citations:
🏁 Script executed: # Check if there's a local package.nix or similar in the repo
fd package.nixRepository: getAlby/hub Length of output: 37 🏁 Script executed: # Check git history to see if the absolute path was recently added
git log --oneline -20 flake.nixRepository: getAlby/hub Length of output: 112 Replace machine-local package path with nixpkgs package reference. Line 15 hardcodes a host-specific absolute path, which will break on any other machine/CI. Since Portable fix- packages.default = pkgs.callPackage /mnt/data1/time2/time/2023/07/06/nixpkgs/pkgs/by-name/al/albyhub/package.nix { };
+ packages.default = pkgs.albyhub;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| devShells.default = pkgs.mkShell { | ||||||
| buildInputs = with pkgs; [ | ||||||
| go | ||||||
| nodejs | ||||||
| yarn | ||||||
| wails | ||||||
| ]; | ||||||
| }; | ||||||
|
|
||||||
| apps.default = { | ||||||
| type = "app"; | ||||||
| program = "${self.packages.${system}.default}/bin/albyhub"; | ||||||
| }; | ||||||
| } | ||||||
| ); | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible typo in ignored artifact path.
Line 33 (
albyhub-dataresult) looks accidental and may fail to ignore the intended local artifact directory. Also,deploy.shgeneratesalbyhub-generated.servicein the repo root and that file should be ignored.Proposed .gitignore update
📝 Committable suggestion
🤖 Prompt for AI Agents