diff --git a/default.nix b/default.nix deleted file mode 100644 index 8ec5c8f..0000000 --- a/default.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ lib, buildGoModule, sqlite }: - -buildGoModule rec { - pname = "tealfm-piper"; - version = "0.0.3"; - src = ./.; - vendorHash = "sha256-poQutY1V8X6BdmPMXdQuPWIWE/j3xNoEp4PKSimj2bA="; - buildInputs = [ sqlite ]; - env.CGO_ENABLED = 1; - subPackages = [ "cmd" ]; - ldflags = [ "-s" "-w" ]; - - postInstall = '' - mv $out/bin/cmd $out/bin/piper - ''; - - meta = with lib; { - description = "Music scrobbler service for teal.fm"; - longDescription = '' - Piper is a teal.fm tool that scrobbles music plays from various - music providers (Spotify, Apple Music, Last.fm) to ATProto Personal - Data Servers using the teal.fm lexicons. - ''; - homepage = "https://github.com/teal-fm/piper"; - changelog = "https://github.com/teal-fm/piper/releases/tag/v${version}"; - license = licenses.mit; - maintainers = with maintainers; [ ptdewey ]; - mainProgram = "piper"; - platforms = lib.platforms.unix; - }; -} diff --git a/flake.nix b/flake.nix index 7ac48a6..e28c49f 100644 --- a/flake.nix +++ b/flake.nix @@ -15,8 +15,9 @@ packages = forAllSystems (system: let pkgs = nixpkgsFor.${system}; in { - default = pkgs.callPackage ./default.nix { }; - tealfm-piper = pkgs.callPackage ./default.nix { }; + tealfm-piper = pkgs.callPackage ./package.nix { }; + # Local development build + default = pkgs.callPackage ./package.nix { source = ./.; }; }); apps = forAllSystems (system: @@ -36,10 +37,9 @@ }); nixosModules.default = import ./module.nix; - nixosModules.tealfm-piper = import ./module.nix; overlays.default = final: prev: { - tealfm-piper = final.callPackage ./default.nix { }; + tealfm-piper = final.callPackage ./package.nix { }; }; }; } diff --git a/package.nix b/package.nix new file mode 100644 index 0000000..9363189 --- /dev/null +++ b/package.nix @@ -0,0 +1,45 @@ +{ lib, buildGoModule, tailwindcss_4, fetchFromGitHub, source ? null }: + +let + # Default to GitHub source for builds. + # Override with `source = ./.` for local development. + defaultSource = fetchFromGitHub { + owner = "teal-fm"; + repo = "piper"; + rev = "ccb72442021bd9f6ed20acc63f9703cf475b0f51"; + hash = "sha256-wXA2RnvQ0J0QwUeDIg2gLRI2DNjgu07+QYjw5pRmyyI="; + }; +in buildGoModule { + pname = "tealfm-piper"; + version = "0.0.3"; + + src = if source != null then source else defaultSource; + + vendorHash = "sha256-poQutY1V8X6BdmPMXdQuPWIWE/j3xNoEp4PKSimj2bA="; + + nativeBuildInputs = [ tailwindcss_4 ]; + + env.CGO_ENABLED = 1; + + subPackages = [ "cmd" ]; + + ldflags = [ "-s" "-w" ]; + + postBuild = '' + cp -r ./pages/templates $out/ + cp -r ./pages/static $out/ + tailwindcss -i $out/static/base.css -o $out/static/main.css -m + ''; + + postInstall = '' + mv $out/bin/cmd $out/bin/piper + ''; + + meta = with lib; { + description = "Music scrobbler service for teal.fm"; + homepage = "https://github.com/teal-fm/piper"; + license = licenses.mit; + maintainers = with maintainers; [ ptdewey ]; + mainProgram = "piper"; + }; +}