emanueljg 11 meses atrás
pai
commit
1e316ebbb5
6 arquivos alterados com 151 adições e 3 exclusões
  1. 7 1
      .gitignore
  2. 4 2
      README.md
  3. 27 0
      flake.lock
  4. 37 0
      flake.nix
  5. 28 0
      nix/module-hm.nix
  6. 48 0
      nix/package.nix

+ 7 - 1
.gitignore

@@ -1,4 +1,10 @@
 discordo*
 
 # Visual Studio Code
-.vscode/
+.vscode/
+
+# Nix stuff
+result
+
+# direnv (devs should have this file locally)
+.envrc

+ 4 - 2
README.md

@@ -23,8 +23,10 @@ You can download and install a [prebuilt binary here](https://nightly.link/ayn2o
 
 - Arch Linux: `yay -S discordo-git`
 - FreeBSD: `pkg install discordo` or via the ports system `make -C /usr/ports/net-im/discordo install clean`.
-- NixOS: `nix-shell -p discordo`
-
+- Nix (NixOS, home-manager)
+  - Downstream nixpkgs installation: Add `pkgs.discordo` to `environment.systemPackages` or `home.packages`.
+  <!-- Temporary until downstream home-manager module --> 
+  - Upstream flake installation: Add `inputs.discordo.url = "github:ayn2op/discordo"`. Install using `inputs.discordo.homeModules.default` (`.enable, .package, .settings TOML`).
 - Windows (Scoop):
 
 ```sh

+ 27 - 0
flake.lock

@@ -0,0 +1,27 @@
+{
+  "nodes": {
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1748026106,
+        "narHash": "sha256-6m1Y3/4pVw1RWTsrkAK2VMYSzG4MMIj7sqUy7o8th1o=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "063f43f2dbdef86376cc29ad646c45c46e93234c",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "nixos-unstable",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "root": {
+      "inputs": {
+        "nixpkgs": "nixpkgs"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}

+ 37 - 0
flake.nix

@@ -0,0 +1,37 @@
+{
+  description = "A lightweight, secure, and feature-rich Discord terminal client.";
+
+  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
+
+  outputs = { self, nixpkgs, ... }:
+    let
+      systems = [
+        "x86_64-linux"
+        "aarch64-linux"
+        "x86_64-darwin"
+        "aarch64-darwin"
+      ];
+      forAllSystems = f:
+        nixpkgs.lib.genAttrs systems
+          (system: f {
+            inherit system;
+            pkgs = nixpkgs.legacyPackages.${system};
+            packages' = self.packages.${system};
+          });
+    in
+    {
+      packages = forAllSystems ({ pkgs, packages', ... }: {
+        default = packages'.discordo;
+        discordo = pkgs.callPackage ./nix/package.nix { };
+      });
+      homeModules = {
+        default = self.homeModules.discordo;
+        discordo = import ./nix/module-hm.nix self;
+      };
+      devShells.default = forAllSystems ({ pkgs, packages', ... }: pkgs.mkShell {
+        inputsFrom = [ packages'.discordo ];
+      });
+    };
+}
+  
+

+ 28 - 0
nix/module-hm.nix

@@ -0,0 +1,28 @@
+self: { options, config, lib, pkgs, ... }:
+let
+  cfg = config.programs.discordo;
+  settingsFormat = pkgs.formats.toml { };
+in
+{
+  options.programs.discordo = {
+    enable = lib.mkEnableOption "discordo";
+    package = lib.mkPackageOption self.packages.${pkgs.system} "discordo" { };
+    settings = lib.mkOption {
+      type = settingsFormat.type;
+      description = ''
+        Configuration for discordo.
+        See https://github.com/ayn2op/discordo?tab=readme-ov-file#configuration 
+        for available options and default values.
+      '';
+      default = { };
+    };
+  };
+  config = lib.mkIf cfg.enable {
+    home.packages = [ cfg.package ];
+    xdg.configFile."discordo/config.toml".source = settingsFormat.generate
+      "discordo-config.toml"
+      cfg.settings;
+  };
+}
+      
+

+ 48 - 0
nix/package.nix

@@ -0,0 +1,48 @@
+{ buildGoModule
+, lib
+, makeWrapper
+, xsel
+, wl-clipboard
+
+, xorgClipboardSupport ? true
+, waylandClipboardSupport ? true
+}:
+let
+  anyClipboardSupport = xorgClipboardSupport || waylandClipboardSupport;
+in
+buildGoModule {
+  pname = "discordo";
+  version = "git";
+
+  src = let fs = lib.fileset; in fs.toSource {
+    root = ../.;
+    fileset = fs.unions [
+      ../go.mod
+      ../go.sum
+      ../main.go
+      ../cmd
+      ../internal
+    ];
+  };
+
+  vendorHash = "sha256-gEwTpt/NPN1+YpTBmW8F34UotowrOcA0mfFgBdVFiTA=";
+
+  nativeBuildInputs = lib.optional anyClipboardSupport makeWrapper;
+
+  postInstall = lib.optionalString xorgClipboardSupport ''
+    wrapProgram $out/bin/discordo \
+      --prefix PATH : ${lib.makeBinPath [ xsel ]}
+  '' + lib.optionalString waylandClipboardSupport ''
+    wrapProgram $out/bin/discordo \
+      --prefix PATH : ${lib.makeBinPath [ wl-clipboard ]}
+  '';
+
+  meta = {
+    description = "A lightweight, secure, and feature-rich Discord terminal client";
+    homepage = "https://github.com/ayn2op/discordo";
+    license = lib.licenses.gpl3;
+    maintainers = [ lib.maintainers.arian-d ];
+    mainProgram = "discordo";
+  };
+}
+