From 22769a18356ab0eb459061bb5b0880d79b45684b Mon Sep 17 00:00:00 2001 From: Wittano Date: Sun, 29 Oct 2023 21:50:39 +0100 Subject: [PATCH] feat(nix): added nix derivation --- .envrc | 1 + default.nix | 28 ++++++++++++++++++++++++++++ flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 .envrc create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..35e79a4 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake; \ No newline at end of file diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..29562c9 --- /dev/null +++ b/default.nix @@ -0,0 +1,28 @@ +{ lib, buildGoModule, gcc, pkg-config, libopus, ffmpeg, opusfile }: buildGoModule { + pname = "komputer"; + version = "v1.0.0"; + + src = ./.; + + vendorHash = "sha256-TAbmS8xYqleXIU0cCRiJVyC93jiXiLuLepMD4WcS7IQ="; + + nativeBuildInputs = [ gcc pkg-config libopus ]; + + CGO_ENABLED = 1; + + proxyVendor = true; + + preBuild = '' + go get layeh.com/gopus + ''; + + propagatedBuildInputs = [ ffmpeg opusfile ]; + + meta = with lib; { + homepage = "https://github.com/Wittano/komputer"; + description = "Discord bot behave as like 'komputer'. One of character in Star Track parody series created by Dem3000"; + license = licenses.gpl3; + maintainers = with maintainers; [ Wittano ]; + platforms = platforms.linux; + }; +} \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..cbd8681 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1698336494, + "narHash": "sha256-sO72WDBKyijYD1GcKPlGsycKbMBiTJMBCnmOxLAs880=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "808c0d8c53c7ae50f82aca8e7df263225cf235bf", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "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..d47ca28 --- /dev/null +++ b/flake.nix @@ -0,0 +1,32 @@ +{ + description = "komputer - discord bot"; + + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + + outputs = { self, nixpkgs }: + let + pkgs = import nixpkgs { + system = "x86_64-linux"; + }; + + lib = nixpkgs.lib.extend (self: super: { + my = import ./lib { inherit pkgs; lib = self; }; + }); + in rec { + inherit lib; + + packages.x86_64-linux.komputer = pkgs.callPackage ./default.nix {}; + + defaultPackage.x86_64-linux = self.packages.x86_64-linux.komputer; + + devShell = pkgs.mkShell { + packages = with pkgs; [ + go + ffmpeg + rnix-lsp + nixfmt + nixpkgs-fmt + ]; + }; + }; +} \ No newline at end of file