Moving this along due to this feature being stalled long enough. Nixpkgs maintainer(s) of discordo are free to provide insight on the packaging method in a future issue.
This commit is contained in:
Emanuel Johnson Godin 2025-05-26 20:11:07 +02:00 • committed by GitHub
commit c30796c405
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 122 additions and 3 deletions

9
.gitignore vendored
View file

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

View file

@ -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
flake.lock generated Normal file
View file

@ -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
flake.nix Normal file
View file

@ -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
nix/module-hm.nix Normal file
View file

@ -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;
};
}

18
nix/package.nix Normal file
View file

@ -0,0 +1,18 @@
{ discordo
, lib
}: discordo.overrideAttrs {
version = "git";
src = let fs = lib.fileset; in fs.toSource {
root = ../.;
fileset = fs.unions [
../go.mod
../go.sum
../main.go
../cmd
../internal
];
};
vendorHash = "sha256-Q9ROPLRP8HSx4P30bSdX30qB2Q1oERz+gZ7Tb23oXbI=";
}