From 348996fe52d31cb39abb4234ab332e651ef9f5ff Mon Sep 17 00:00:00 2001 From: Luke Worth Date: Wed, 10 Jul 2024 10:35:27 +1000 Subject: [PATCH] Add nix flake --- flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..57357b0 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1720492477, + "narHash": "sha256-PV6LKJpj43tuKAMEfmXiKZjlOW1IqZORUJ8WYcdLtGE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "64f145f456b7a3953f191cad9e257cd88412044e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-24.05-darwin", + "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..e3d28f6 --- /dev/null +++ b/flake.nix @@ -0,0 +1,44 @@ +{ + description = "A tool to download private videos on vimeo"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-24.05-darwin"; + + outputs = { self, nixpkgs }: + let + + # to work with older version of flakes + lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101"; + + # Generate a user-friendly version number. + version = builtins.substring 0 8 lastModifiedDate; + + # System types to support. + supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + + # Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + + # Nixpkgs instantiated for supported system types. + nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); + + in + { + packages = forAllSystems (system: + let + pkgs = nixpkgsFor.${system}; + in + { + default = pkgs.buildGoModule rec { + pname = "vimeo-dl"; + inherit version; + src = ./.; + vendorHash = "sha256-hocnLCzWN8srQcO3BMNkd2lt0m54Qe7sqAhUxVZlz1k="; + nativeBuildInputs = with pkgs; [ makeWrapper ]; + postInstall = '' + wrapProgram $out/bin/${pname} \ + --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.ffmpeg ]} + ''; + }; + }); + }; +}