From f10ceafc4b0cabbca99a7075f6fd4de244c3ad79 Mon Sep 17 00:00:00 2001 From: Alex Six Date: Sat, 22 Aug 2026 03:44:05 -0400 Subject: [PATCH] feat: add nix support (#336) --- README.md | 17 +++++++++++++++ flake.lock | 27 +++++++++++++++++++++++ flake.nix | 43 +++++++++++++++++++++++++++++++++++++ nix/package.nix | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ site/index.html | 5 +++++ 5 files changed, 149 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/package.nix diff --git a/README.md b/README.md index 3d119ae..b036c35 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,23 @@ The formula pulls in all required runtime libraries automatically. yay -S cliamp ``` +**Nix** + +```sh +nix run github:bjarneo/cliamp +``` + +For a declarative NixOS configuration, add `github:bjarneo/cliamp` as a flake +input and install its default package: + +```nix +inputs.cliamp.url = "github:bjarneo/cliamp"; + +environment.systemPackages = [ + inputs.cliamp.packages.${pkgs.stdenv.hostPlatform.system}.default +]; +``` + **Go** ```sh diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a2b5752 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1787135253, + "narHash": "sha256-RD2kNWCG+Bjo6h+JVjWVNntZs2GtRoeY2xHjts/FNkA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ffb3c9b700e759be2ef13237c9d8f953b32a1e46", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..03b746b --- /dev/null +++ b/flake.nix @@ -0,0 +1,43 @@ +{ + description = "A retro terminal music player inspired by Winamp"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + outputs = + { self, nixpkgs }: + let + systems = [ + "aarch64-linux" + "x86_64-linux" + ]; + forAllSystems = nixpkgs.lib.genAttrs systems; + version = + if self ? shortRev then + self.shortRev + else if self ? dirtyShortRev then + self.dirtyShortRev + else + "dev"; + in + { + packages = forAllSystems ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + cliamp = pkgs.callPackage ./nix/package.nix { inherit version; }; + in + { + inherit cliamp; + default = cliamp; + } + ); + + apps = forAllSystems (system: { + default = { + type = "app"; + program = nixpkgs.lib.getExe self.packages.${system}.default; + meta.description = "Run cliamp"; + }; + }); + }; +} diff --git a/nix/package.nix b/nix/package.nix new file mode 100644 index 0000000..b8709e5 --- /dev/null +++ b/nix/package.nix @@ -0,0 +1,57 @@ +{ + alsa-lib, + buildGoModule, + ffmpeg-headless, + flac, + lib, + libogg, + libvorbis, + makeWrapper, + mpg123, + pkg-config, + version ? "dev", + yt-dlp, +}: + +buildGoModule { + pname = "cliamp"; + inherit version; + + src = lib.cleanSource ../.; + vendorHash = "sha256-/c2MOMnG8twpr2/9plFanXkJwoIYNwC0mPksTklIcRw="; + + nativeBuildInputs = [ + makeWrapper + pkg-config + ]; + + buildInputs = [ + alsa-lib + flac + libogg + libvorbis + mpg123 + ]; + + ldflags = [ + "-s" + "-w" + "-X=main.version=${version}" + ]; + + postInstall = '' + wrapProgram "$out/bin/cliamp" \ + --prefix PATH : ${lib.makeBinPath [ + ffmpeg-headless + yt-dlp + ]} + ''; + + meta = { + description = "Retro terminal music player inspired by Winamp"; + homepage = "https://github.com/bjarneo/cliamp"; + license = lib.licenses.mit; + mainProgram = "cliamp"; + platforms = lib.platforms.linux; + }; +} diff --git a/site/index.html b/site/index.html index 63b130f..d7bd405 100644 --- a/site/index.html +++ b/site/index.html @@ -682,6 +682,11 @@ footer{border-top:1px solid var(--line);background:var(--ink-2);padding:46px 0 5 $ yay -S cliamp COPIED +
+
Nix
+ $ nix run github:bjarneo/cliamp + COPIED +
Go
$ go install github.com/bjarneo/cliamp@latest