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

nixcord: init module #767

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

nixcord: init module #767

wants to merge 12 commits into from

Conversation

ari-rs
Copy link

@ari-rs ari-rs commented Jan 9, 2025

Nixcord is a way to do "Declarative Vencord plugins + options " for vesktop (vencord) https://github.com/KaylorBen/nixcord

This references the same template as vesktop

@ari-rs
Copy link
Author

ari-rs commented Jan 10, 2025

This will resolve #684

Copy link
Collaborator

@trueNAHO trueNAHO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error: The option `virtualisation.vmVariant.home-manager.users.guest.programs.nixcord' does not exist. Definition values:
       - In `/nix/store/5ylf1lb92hkw0zq103cli5l86hd7lnnw-source/modules/nixcord/hm.nix':

I assume the Home Manager input needs to be updated.

modules/nixcord/hm.nix Outdated Show resolved Hide resolved
modules/nixcord/hm.nix Outdated Show resolved Hide resolved
Copy link
Owner

@danth danth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Nixcord is not a regular part of Home Manager, the Stylix module should check whether the programs.nixcord option exists, rather than installing Nixcord itself.

This avoids Nixcord being installed for all Stylix users, as some may not want it.

See the Nixvim module for an example:

lib.mkIf (config.stylix.enable && cfg.enable && (config.programs ? nixvim))

@danth
Copy link
Owner

danth commented Jan 14, 2025

The build failure is because the template was renamed in 934e2bf

@ari-rs
Copy link
Author

ari-rs commented Jan 14, 2025

Not exactly sure what the build issue is but im lookin

@danth
Copy link
Owner

danth commented Jan 15, 2025

Oops, I should have made the example longer - the part which actually prevents this issue is just below the line I linked to:

lib.optionalAttrs (builtins.hasAttr "nixvim" options.programs) (

Basically, the definition needs to be wrapped in something which uses a hard if statement (which optionalAttrs does) rather than mkIf. Otherwise, the module system will require the options to exist even if mkIf disables the settings in the end.

hasAttr "nixvim" options.programs is basically the same as options.programs ? nixvim.

Copy link
Owner

@danth danth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@danth danth requested a review from trueNAHO January 16, 2025 22:19
Copy link
Collaborator

@trueNAHO trueNAHO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ari-rs, since I am unable to push the following commits to your master branch, please apply them in order for the CI to pass:

  • From a02d66430bb24cc9e14fd3e351d2aac5cd39d3df Mon Sep 17 00:00:00 2001
    From: NAHO <[email protected]>
    Date: Sat, 18 Jan 2025 13:27:56 +0100
    Subject: [PATCH 1/2] nixcord: apply nixfmt-rfc-style
    
    ---
     modules/nixcord/hm.nix | 17 ++++++++++-------
     1 file changed, 10 insertions(+), 7 deletions(-)
    
    diff --git a/modules/nixcord/hm.nix b/modules/nixcord/hm.nix
    index 6ddb631..325d20e 100644
    --- a/modules/nixcord/hm.nix
    +++ b/modules/nixcord/hm.nix
    @@ -1,4 +1,9 @@
    -{ config, lib, options, ... }:
    +{
    +  config,
    +  lib,
    +  options,
    +  ...
    +}:
     let
       themeFile = config.lib.stylix.colors {
         template = ../vencord/template.mustache;
    @@ -13,12 +18,10 @@ in
    
       config =
         lib.mkIf (config.stylix.enable && cfg.enable && (config.programs ? nixcord))
    -    (
    -      lib.optionalAttrs (builtins.hasAttr "nixcord" options.programs) (
    -        {
    +      (
    +        lib.optionalAttrs (builtins.hasAttr "nixcord" options.programs) ({
               xdg.configFile."Vencord/themes/stylix.theme.css".source = themeFile;
               programs.nixcord.config.enabledThemes = [ themeFileName ];
    -        }
    -      )
    -    );
    +        })
    +      );
     }
    --
  • From e1b92ee220b3ac336c3103c79f6476090ce75b0d Mon Sep 17 00:00:00 2001
    From: NAHO <[email protected]>
    Date: Sat, 18 Jan 2025 13:28:24 +0100
    Subject: [PATCH 2/2] nixcord: satisfy statix
    
    ---
     modules/nixcord/hm.nix | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/modules/nixcord/hm.nix b/modules/nixcord/hm.nix
    index 325d20e..0a1ccb0 100644
    --- a/modules/nixcord/hm.nix
    +++ b/modules/nixcord/hm.nix
    @@ -19,9 +19,9 @@ in
       config =
         lib.mkIf (config.stylix.enable && cfg.enable && (config.programs ? nixcord))
           (
    -        lib.optionalAttrs (builtins.hasAttr "nixcord" options.programs) ({
    +        lib.optionalAttrs (builtins.hasAttr "nixcord" options.programs) {
               xdg.configFile."Vencord/themes/stylix.theme.css".source = themeFile;
               programs.nixcord.config.enabledThemes = [ themeFileName ];
    -        })
    +        }
           );
     }
    --

flake.lock Outdated Show resolved Hide resolved
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.

3 participants