initial commit
Some checks failed
Build and Push to Cachix / Push to Binary Cache (X86-64) (push) Failing after 1m5s
Build and Push to Cachix / Push to Binary Cache (aarch64) (push) Successful in 16m4s

This commit is contained in:
Adithya 2024-11-03 19:11:03 +05:30
commit dee0348c05
Signed by: adtya
GPG key ID: B8857BFBA2C47B9C
9 changed files with 268 additions and 0 deletions

View file

@ -0,0 +1,60 @@
name: Build and Push to Cachix
on:
push:
branches:
- main
workflow_run:
workflows: ['Update Inputs']
types: [completed]
branches:
- main
workflow_dispatch:
jobs:
publish-x86_64:
name: Push to Binary Cache (X86-64)
runs-on: x86_64-docker
container:
image: ghcr.io/catthehacker/ubuntu:act-22.04
steps:
- uses: https://github.com/DeterminateSystems/nix-installer-action@main
with:
extra-conf: |
access-tokens = ${{ secrets.GH_PUBLIC_REPO_ACCESS_TOKEN }}
- uses: https://github.com/DeterminateSystems/magic-nix-cache-action@main
- uses: https://github.com/cachix/cachix-action@v15
with:
name: ${{ vars.CACHIX_CACHE_NAME }}
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- uses: actions/checkout@v4
- name: Build and push flake output
run: |
nix build -L .#autobrr
publish-aarch64:
name: Push to Binary Cache (aarch64)
runs-on: aarch64-docker
container:
image: ghcr.io/catthehacker/ubuntu:act-22.04
steps:
- uses: https://github.com/DeterminateSystems/nix-installer-action@main
with:
extra-conf: |
access-tokens = ${{ secrets.GH_PUBLIC_REPO_ACCESS_TOKEN }}
- uses: https://github.com/DeterminateSystems/magic-nix-cache-action@main
- uses: https://github.com/cachix/cachix-action@v15
with:
name: ${{ vars.CACHIX_CACHE_NAME }}
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- uses: actions/checkout@v4
- run: |
nix build -L .#autobrr

View file

@ -0,0 +1,30 @@
name: Update Inputs
on:
schedule:
- cron: "0 0 * * 5"
workflow_dispatch:
jobs:
update-inputs:
runs-on: docker
container:
image: ghcr.io/catthehacker/ubuntu:act-22.04
name: Update Inputs
steps:
- uses: actions/checkout@v4
with:
token: ${{ github.token }}
ref: ${{ github.head_ref }}
- uses: https://github.com/cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable
github_access_token: ${{ secrets.GH_PUBLIC_REPO_ACCESS_TOKEN }}
- name: Update inputs
run: |
nix flake update --access-tokens "github.com=${{ secrets.GH_PUBLIC_REPO_ACCESS_TOKEN }}"
- name: Commit changes
uses: https://github.com/EndBug/add-and-commit@v9
with:
message: 'Actions: Update Inputs'
add: 'flake.lock'

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
result*

62
flake.lock Normal file
View file

@ -0,0 +1,62 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1726560853,
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
"type": "github"
},
"original": {
"owner": "numtide",
"ref": "main",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1730531603,
"narHash": "sha256-Dqg6si5CqIzm87sp57j5nTaeBbWhHFaVyG7V6L8k3lY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "7ffd9ae656aec493492b44d0ddfb28e79a1ea25d",
"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
}

29
flake.nix Normal file
View file

@ -0,0 +1,29 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
flake-utils.url = "github:numtide/flake-utils?ref=main";
};
outputs = { nixpkgs, flake-utils, ... }:
let
pkgs_x86_64-linux = import nixpkgs {
system = "x86_64-linux";
};
pkgs_aarch64-linux = import nixpkgs {
system = "aarch64-linux";
};
in
{
overlays.default = import ./overlay.nix;
packages.x86_64-linux.autobrr = pkgs_x86_64-linux.callPackage ./packages/autobrr { };
packages.aarch64-linux.autobrr = pkgs_aarch64-linux.callPackage ./packages/autobrr { };
} // flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
in
{
formatter = pkgs.nixpkgs-fmt;
}
);
}

3
overlay.nix Normal file
View file

@ -0,0 +1,3 @@
final: prev: {
autobrr = prev.callPackage ./packages/autobrr { };
}

View file

@ -0,0 +1,28 @@
{ lib
, buildGoModule
, fetchFromGitHub
, callPackage
, nodejs
, pnpm
}:
let
inherit (import ./sources.nix { inherit fetchFromGitHub; }) pname version src vendorHash;
web = callPackage ./web.nix { inherit nodejs pnpm fetchFromGitHub; };
in
buildGoModule rec {
inherit pname version src vendorHash;
ldflags = [ "-s" "-w" "-X main.commit=${src.rev}" "-X main.tag=${version}" ];
postPatch = ''
cp -r ${web}/share/autobrr-web/* web/dist/
'';
meta = {
description = "Modern, easy to use download automation for torrents and usenet";
homepage = "https://github.com/autobrr/autobrr";
license = lib.licenses.gpl2Only;
maintainers = with lib.maintainers; [ adtya ];
mainProgram = "autobrr";
};
}

View file

@ -0,0 +1,15 @@
{ fetchFromGitHub }:
rec {
pname = "autobrr";
version = "1.48.0";
src = fetchFromGitHub {
owner = "autobrr";
repo = "autobrr";
rev = "v${version}";
hash = "sha256-aCIjdVSBxR2Uq96ZtKrU97LpzIR6Pcfv0vLJNCdRrC0=";
};
vendorHash = "sha256-C+SzLqdzOLp4BDwE097RtsrR34davPzylgWN3mMoGaU=";
pnpmDepsHash = "sha256-Fkr/VFTh7foQBKbw0C5oJLr3pFA1wdYNmjEsoCemJ/I=";
}

40
packages/autobrr/web.nix Normal file
View file

@ -0,0 +1,40 @@
{ stdenv, nodejs, pnpm, fetchFromGitHub }:
let
inherit (import ./sources.nix { inherit fetchFromGitHub; }) pname version src pnpmDepsHash;
in
stdenv.mkDerivation (finalAttrs: {
pname = "${pname}-web";
inherit src version;
sourceRoot = "${finalAttrs.src.name}/web";
nativeBuildInputs = [
nodejs
pnpm.configHook
];
pnpmDeps = pnpm.fetchDeps {
inherit (finalAttrs) pname version src sourceRoot;
hash = pnpmDepsHash;
};
# postPatch = ''
#substituteInPlace ./vite.config.ts \
# --replace 'outDir: "../internal/server/public_html"' 'outDir: "dist"'
#'';
postBuild = ''
pnpm run build
'';
installPhase = ''
runHook preInstall
mkdir -p $out/share
mv dist $out/share/autobrr-web
runHook postInstall
'';
})