Skip to content

Commit

Permalink
init flake
Browse files Browse the repository at this point in the history
  • Loading branch information
trs committed Aug 19, 2024
1 parent 7647e91 commit ddc7df3
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 1 deletion.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
15 changes: 15 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "Nix"
on:
pull_request:
push:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: DeterminateSystems/magic-nix-cache-action@v2
- run: nix build
- run: nix flake check
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ log.log
GHTOKEN
dist
t.txt
.direnv
result
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██████ ██ ██████ ██████ ██████ ██ ██ ██
```
[![Open in Visual Studio Code](https://open.vscode.dev/badges/open-in-vscode.svg)](https://open.vscode.dev/slashformotion/radioboat)

![Contributors](https://img.shields.io/github/contributors/slashformotion/radioboat)
![Forks](https://img.shields.io/github/forks/slashformotion/radioboat)
![Stars](https://img.shields.io/github/stars/slashformotion/radioboat)
Expand Down
56 changes: 56 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
lib,
buildGoModule,
mpv,
makeWrapper,
installShellFiles,
nix-update-script,
testers,
nix-gitignore,
radioboat,
}:
buildGoModule rec {
pname = "radioboat";
version = "0.3.0";

src = nix-gitignore.gitignoreSource [] ./.;

vendorHash = "sha256-PYO1ZhbNpzN5AJMNo4odSJWufVeRTpUC6i9ZAJryRJo=";

buildInputs = [mpv];

ldflags = [
"-s"
"-w"
"-X github.com/slashformotion/radioboat/internal/buildinfo.Version=${version}"
];

nativeBuildInputs = [makeWrapper installShellFiles];

preFixup = ''
wrapProgram $out/bin/radioboat --prefix PATH ":" "${lib.makeBinPath [mpv]}";
'';

postInstall = ''
installShellCompletion --cmd radioboat \
--bash <($out/bin/radioboat completion bash) \
--fish <($out/bin/radioboat completion fish) \
--zsh <($out/bin/radioboat completion zsh)
'';

passthru = {
updateScript = nix-update-script {};
tests.version = testers.testVersion {
package = radioboat;
command = "radioboat version";
};
};

meta = with lib; {
description = "Terminal web radio client";
mainProgram = "radioboat";
homepage = "https://github.com/slashformotion/radioboat";
license = licenses.asl20;
platforms = platforms.linux;
};
}
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
outputs = {nixpkgs, ...}: let
forAllSystems = function:
nixpkgs.lib.genAttrs [
"x86_64-darwin"
"x86_64-linux"
"aarch64-darwin"
"aarch64-linux"
"aarch64-applr-darwin"
] (system: function nixpkgs.legacyPackages.${system});
in {
packages = forAllSystems (pkgs: {
default = pkgs.callPackage ./default.nix {};
});
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
buildInputs = with pkgs; [
nurl
nix-update
nvfetcher
];
};
});
};
}

0 comments on commit ddc7df3

Please sign in to comment.