Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Nix flake #322

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Add Nix flake #322

wants to merge 17 commits into from

Conversation

emanueljg
Copy link

This PR adds support for the Nix build system.

@ayn2op
Copy link
Owner

ayn2op commented Sep 16, 2023

There is already a NixOS package for discordo: https://search.nixos.org/packages?query=discordo

@Arian-D
Copy link

Arian-D commented Oct 19, 2023

Hey, are there any updates on this?

I was the one who originally packaged discordo for nixpkgs earlier this year, and while I think it makes it more accessible for most people, I think a flake would provide additional benefits.

My biggest gripe at the moment is that I'm either using a version from last month, or if I want to get the most recent changes I'd have to pull and go build . manually. With nix flakes this would be a simple

nix run github:ayn2op/discordo/main

Nix would then run discordo, and if the most recent version is not there, it would pull and rebuild it before running.

@linuxmobile
Copy link

Hi, Does anyone know why the flake was removed?

flake.nix Outdated Show resolved Hide resolved
flake.nix Outdated Show resolved Hide resolved
@epetousis
Copy link

@ayn2op not required obviously but it would be pretty sweet if this could be merged (pending the changes to actually make it work). I understand if you're not interested in extra maintenance burden, however.

@emanueljg
Copy link
Author

emanueljg commented Apr 27, 2024

I'm trying to revive this PR. Got the following error while trying to build it on f272589:

[1/0/1 built] building discordo-20240427 (buildPhase): Building suerror: builder for '/nix/store/20l076j3cgdmlb4m6xzcl1c3d05s3n9z-discordo-20240427.drv' failed with exit code 1;
       last 24 log lines:
       > Running phase: unpackPhase
       > unpacking source archive /nix/store/gl53glqy1k0p645i2rmq0g72i78lynqn-kz20izh44jmjh61wfm1p5458g727gj9x-source
       > source root is kz20izh44jmjh61wfm1p5458g727gj9x-source
       > Running phase: patchPhase
       > Running phase: updateAutotoolsGnuConfigScriptsPhase
       > Running phase: configurePhase
       > Running phase: buildPhase
       > Building subPackage .
       > Building subPackage ./cmd
       > Building subPackage ./internal/config
       > Building subPackage ./internal/constants
       > Building subPackage ./internal/logger
       > Building subPackage ./internal/markdown
       > Building subPackage ./internal/ui
       > Running phase: checkPhase
       > --- FAIL: TestParse (0.00s)
       >     markdown_test.go:23: got Don't [::b]communicate[::B] by sharing memory, share memory by communicating.; want Don't [::b]communicate[::-] by sharing memory, share memory by communicating.
       >     markdown_test.go:23: got [::i]Concurrency[::I] is not parallelism.; want [::i]Concurrency[::-] is not parallelism.
       >     markdown_test.go:23: got Channels [::u]orchestrate[::U]; mutexes [::u]serialize[::U].; want Channels [::u]orchestrate[::-]; mutexes [::u]serialize[::-].
       >     markdown_test.go:23: got [::s]Cgo[::S] is not Go.; want [::s]Cgo[::-] is not Go.
       >     markdown_test.go:23: got Don't just check [::r]errors[::R], handle them [::r]gracefully[::R].; want Don't just check [::r]errors[::-], handle them [::r]gracefully[::-].
       > FAIL
       > FAIL	github.com/ayn2op/discordo/internal/markdown	0.003s
       > FAIL
       For full logs, run 'nix log /nix/store/20l076j3cgdmlb4m6xzcl1c3d05s3n9z-discordo-20240427.drv'.

I'm not a Go expert. Anyone knows how to solve this? @epetousis @linuxmobile @Arian-D @ayn2op
You can obviously just do doCheck = false temporarily but I would rather that the check goes through.

@ayn2op
Copy link
Owner

ayn2op commented Apr 27, 2024

I'm trying to revive this PR. Got the following error while trying to build it on f272589:

[1/0/1 built] building discordo-20240427 (buildPhase): Building suerror: builder for '/nix/store/20l076j3cgdmlb4m6xzcl1c3d05s3n9z-discordo-20240427.drv' failed with exit code 1;
       last 24 log lines:
       > Running phase: unpackPhase
       > unpacking source archive /nix/store/gl53glqy1k0p645i2rmq0g72i78lynqn-kz20izh44jmjh61wfm1p5458g727gj9x-source
       > source root is kz20izh44jmjh61wfm1p5458g727gj9x-source
       > Running phase: patchPhase
       > Running phase: updateAutotoolsGnuConfigScriptsPhase
       > Running phase: configurePhase
       > Running phase: buildPhase
       > Building subPackage .
       > Building subPackage ./cmd
       > Building subPackage ./internal/config
       > Building subPackage ./internal/constants
       > Building subPackage ./internal/logger
       > Building subPackage ./internal/markdown
       > Building subPackage ./internal/ui
       > Running phase: checkPhase
       > --- FAIL: TestParse (0.00s)
       >     markdown_test.go:23: got Don't [::b]communicate[::B] by sharing memory, share memory by communicating.; want Don't [::b]communicate[::-] by sharing memory, share memory by communicating.
       >     markdown_test.go:23: got [::i]Concurrency[::I] is not parallelism.; want [::i]Concurrency[::-] is not parallelism.
       >     markdown_test.go:23: got Channels [::u]orchestrate[::U]; mutexes [::u]serialize[::U].; want Channels [::u]orchestrate[::-]; mutexes [::u]serialize[::-].
       >     markdown_test.go:23: got [::s]Cgo[::S] is not Go.; want [::s]Cgo[::-] is not Go.
       >     markdown_test.go:23: got Don't just check [::r]errors[::R], handle them [::r]gracefully[::R].; want Don't just check [::r]errors[::-], handle them [::r]gracefully[::-].
       > FAIL
       > FAIL	github.com/ayn2op/discordo/internal/markdown	0.003s
       > FAIL
       For full logs, run 'nix log /nix/store/20l076j3cgdmlb4m6xzcl1c3d05s3n9z-discordo-20240427.drv'.

I'm not a Go expert. Anyone knows how to solve this? @epetousis @linuxmobile @Arian-D @ayn2op You can obviously just do doCheck = false temporarily but I would rather that the check goes through.

Fixed in the latest commit.

@ghost
Copy link

ghost commented Apr 27, 2024

oh right, the new changes. [::i]text[::I] is better because [::-] resets all the attributes instead of resetting only the italic attributes.
[::b]BOLD[::i]italic[::-]not BOLD or italic[::-]
[::b]BOLD[::i]italic[::I]BOLD and not italic[::B]

@linuxmobile
Copy link

I'm not a Go expert. Anyone knows how to solve this? @epetousis @linuxmobile @Arian-D @ayn2op

I am using my own flake:
https://github.com/linuxmobile/kaku/blob/main/pkgs/discordo/default.nix

@emanueljg
Copy link
Author

emanueljg commented Apr 28, 2024

I've improved the flake further and now finally consider it ready for review.

  • Taking inspiration from @linuxmobile's flake, a meta attribute has been added and the derivation should now support clipboard actions. I've taken the liberty of adding customizable drv flags for this, should you want a smaller tty-only closure.
  • home-manager support has been added through a homeManagerModule. Here's how I use it in my own flake:
{ config, lib, discordo, ... }: {

  imports = [ discordo.homeManagerModules.default ];

  programs.discordo = {
    enable = true;
    settings = {
      timestamps = true;
      theme.messages_text.author_color = "red";
    };
    tokenCommand =
      let
        passBin = lib.getExe config.programs.password-store.package;
        token = "discord-token";
      in
      "${passBin} ${token}";
  };
}  

Note that installation is still possible without home-manager. Just as before, it's as simple as

{ discordo, pkgs, ... }: {

  environment.systemPackages = [
    discordo.packages.${pkgs.system}.default
  ];
}

though of course you'll lose out on the dotfile management that home-manager is used for.

Please check ./nix/hm-module.nix for implementation details and option reference.
When this PR is merged, we can create a follow-up PR that documents the Nix-related stuff.

PTAL @linuxmobile @ayn2op

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants