diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-21 12:47:29 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-21 12:47:29 +0200 |
commit | 61997911557fa8da66598ec54f5f280e1be1dd5d (patch) | |
tree | 4baf547d438fe92dc49ef44bba56371b460ee28e | |
parent | docs(NEWS): Add (diff) | |
download | yt-61997911557fa8da66598ec54f5f280e1be1dd5d.tar.gz yt-61997911557fa8da66598ec54f5f280e1be1dd5d.zip |
build(flake): Setup up checks (formatter and derivation)
-rw-r--r-- | flake.lock | 23 | ||||
-rw-r--r-- | flake.nix | 18 | ||||
-rw-r--r-- | package.nix | 79 | ||||
-rw-r--r-- | yt.nix | 39 |
4 files changed, 68 insertions, 91 deletions
diff --git a/flake.lock b/flake.lock index f588694..51482e9 100644 --- a/flake.lock +++ b/flake.lock @@ -37,7 +37,8 @@ "root": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "treefmt-nix": "treefmt-nix" } }, "systems": { @@ -54,6 +55,26 @@ "repo": "default", "type": "github" } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1723808491, + "narHash": "sha256-rhis3qNuGmJmYC/okT7Dkc4M8CeUuRCSvW6kC2f3hBc=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "1d07739554fdc4f8481068f1b11d6ab4c1a4167a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 5413444..2c79390 100644 --- a/flake.nix +++ b/flake.nix @@ -14,12 +14,19 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs = { + nixpkgs.follows = "nixpkgs"; + }; + }; }; outputs = { self, nixpkgs, flake-utils, + treefmt-nix, }: (flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages."${system}"; @@ -35,7 +42,18 @@ nativeBuildInputs = with pkgs; [ llvmPackages_latest.clang-unwrapped.lib ]; + + yt = pkgs.callPackage ./package.nix {}; + + treefmtEval = import ./treefmt.nix {inherit treefmt-nix pkgs;}; in { + checks = { + inherit yt; + formatting = treefmtEval.config.build.check self; + }; + + formatter = treefmtEval.config.build.wrapper; + devShells.default = pkgs.mkShell { env = let clang_version = diff --git a/package.nix b/package.nix index 5035128..d57477b 100644 --- a/package.nix +++ b/package.nix @@ -1,54 +1,31 @@ -# yt - A fully featured command line YouTube client -# -# Copyright (C) 2024 Benedikt Peetz <benedikt.peetz@b-peetz.de> -# SPDX-License-Identifier: GPL-3.0-or-later -# -# This file is part of Yt. -# -# You should have received a copy of the License along with this program. -# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. - { - lib, - makeWrapper, rustPlatform, - # dependencies - ytcc, - yt-dlp, - mpv, -}: { - yt = import ./yt.nix { - inherit - lib - makeWrapper - rustPlatform - # dependencies - - ytcc - yt-dlp - mpv - ; - }; - yts = import ./yts.nix { - inherit - lib - makeWrapper - rustPlatform - # dependencies - - ytcc - ; - }; - ytc = import ./ytc.nix { - inherit - lib - makeWrapper - rustPlatform - # dependencies - - ytcc - yt-dlp - mpv - ; + python3, + makeWrapper, + fetchurl, +}: +rustPlatform.buildRustPackage (finalAttrs: { + pname = "yt"; + version = "0.1.0"; + + src = fetchurl { + url = "https://git.vhack.eu/soispha/clients/yt/${finalAttrs.pname}-${finalAttrs.version}.tar.xz"; + sha256 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; }; -} + + nativeBuildInputs = [ + makeWrapper + python3.withPackages + (ps: [ps.yt-dlp]) + ]; + + postBuild = '' + install -m755 ./python_update/raw_update.py -D "$out/bin/raw_update.py" + patchShebangs "$out/bin/raw_update.py" + ''; + + postInstall = '' + wrapProgram $out/bin/yt \ + --prefix PATH : $out/bin/ + ''; +}) diff --git a/yt.nix b/yt.nix deleted file mode 100644 index 015fc3f..0000000 --- a/yt.nix +++ /dev/null @@ -1,39 +0,0 @@ -# yt - A fully featured command line YouTube client -# -# Copyright (C) 2024 Benedikt Peetz <benedikt.peetz@b-peetz.de> -# SPDX-License-Identifier: GPL-3.0-or-later -# -# This file is part of Yt. -# -# You should have received a copy of the License along with this program. -# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. - -{ - lib, - rustPlatform, - ytcc, - yt-dlp, - mpv, - makeWrapper, -}: -rustPlatform.buildRustPackage { - pname = "yt"; - version = "0.1.0"; - - src = ./.; - cargoLock = { - lockFile = ./Cargo.lock; - }; - - buildNoDefaultFeatures = true; - buildFeatures = ["yt"]; - - nativeBuildInputs = [ - makeWrapper - ]; - - postInstall = '' - wrapProgram $out/bin/yt \ - --prefix PATH : ${lib.makeBinPath [mpv yt-dlp ytcc]} - ''; -} |