I’m attempting to make a wallust integration into home manager that will allow users to have automatic color configuration similar to Stylix using wallust as a backend to generate schemes. I’m new to creating any sort of nix package or new home-manager module and I’ve only been using NixOS for about two months so please be patient and I’d love some help learning more about creating modules and packages and getting better in my Nix skills as a whole.
module.nix
schemeJSON = builtins.trace "Generating..."
pkgs.runCommand "scheme.json" {
HOME = "./";
} ''
echo IS THIS WORKING?
${wallust}/bin/wallust run ${cfg.path}
mkdir $out
cp -v .cache/wallust/*.json $out/scheme.json
'';
What I’m expecting to have happen is that the above pkgs.runCommand will be run and generate a colorscheme json file during home-manager switch --flake .
From what I can tell with changing things around and adding different expressions inside the let in expression nothing is being run. However when messing around with my home.nix
I can see that the walnix
options in the following expression are being set and I can get it to error if I misspell or add something not in the options set in module.nix
.
I’ve included the entirety of my flake.nix
and module.nix
below. I’d love any suggestions on this problem and any good resources on learning how to write my own home-manager modules besides just reading other packages modules.
flake.nix
{
description = "Walnix flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
base16.url = "github:SenchoPens/base16.nix";
# Thank you matthew for example
wallust.url = "git+https://codeberg.org/explosion-mental/wallust.git";
};
outputs = { self, nixpkgs, base16, wallust, ... }@inputs :
{
homeManagerModules = {
walnix = (import ./home-manager/module.nix) {
inherit base16 wallust;
};
default = self.homeManagerModules.walnix;
};
};
}
module.nix
{ wallust, base16, ... }: {
pkgs,
lib,
config,
...
}:
with lib; let
cfg = config.walnix;
schemeJSON = builtins.trace "Generating..."
pkgs.runCommand "scheme.json" {
HOME = "./";
} ''
echo IS THIS WORKING?
${wallust}/bin/wallust run ${cfg.path}
mkdir $out
cp -v .cache/wallust/*.json $out/scheme.json
'';
in {
options.walnix = {
enable = mkEnableOption {
description = "Home manager Wallust integration";
default = false;
};
path = mkOption {
type = types.path;
};
scheme = mkOption {
type = types.oneOf [
types.path
types.attrs
types.lines
];
default = builtins.fromJSON schemeJSON;
};
backend = mkOption {
type = types.nullOr types.enum [
"full"
"resized"
"wal"
"thumb"
"fastresize"
];
description = ''
Use this option to dictate which backend to wallust will use to generate a pallette.
Default is selected by Wallust
'';
};
};
}