dotfiles icon indicating copy to clipboard operation
dotfiles copied to clipboard

Ask about garden

Open jsiaxx opened this issue 7 months ago • 9 comments

When you use inherit (config.garden.profiles.workstation), I wonder where you declare garden

jsiaxx avatar May 10 '25 16:05 jsiaxx

There are several garden's scattered around, since that's just the name space I choose. But based on profiles your looking for https://github.com/isabelroses/dotfiles/blob/main/modules/generic/profiles.nix

isabelroses avatar May 10 '25 16:05 isabelroses

There are several garden's scattered around

Thx I mean how you use inherit (config.garden.profiles.workstation) instead

let
  cfg = config.${namespace}.module;
in
{
  options.${namespace}.module = with types; {
    enable = mkBoolOpt false "Enable module";
  };

  config = mkIf cfg.enable { };
}

jsiaxx avatar May 10 '25 17:05 jsiaxx

Anything for the module is configured per-host, for example https://github.com/isabelroses/dotfiles/blob/c4e94369e2792c040c5005c4b145611dcf17eede/systems/athena/default.nix

isabelroses avatar May 10 '25 17:05 isabelroses

Anything for the module is configured per-host, for example https://github.com/isabelroses/dotfiles/blob/c4e94369e2792c040c5005c4b145611dcf17eede/systems/athena/default.nix

No this it what I'm looking for modules/generic/profiles.nix and modules/home/profiles.nix, which is how to declare config.garden

jsiaxx avatar May 10 '25 17:05 jsiaxx

The options part of the module system is a bit magic in that it will "create" for a lack of better words the attrsets prior for you. For example

{
  options.foo.bar.baz = {
    enable = mkBoolOpt false "Enable module";
  };
}

which will create config.foo and config.foo.baz and so on for you. So you don't need to declare them anywhere special.

isabelroses avatar May 10 '25 20:05 isabelroses

The options part of the module system is a bit magic in that it will "create" for a lack of better words the attrsets prior for you. For example

{ options.foo.bar.baz = { enable = mkBoolOpt false "Enable module"; }; } which will create config.foo and config.foo.baz and so on for you. So you don't need to declare them anywhere special.

I know, I'm sorry because not good in English. I mean I don't see any

options.foo.bar.baz = {
     enable = mkBoolOpt false "Enable module";

In your dotfiles

jsiaxx avatar May 11 '25 02:05 jsiaxx

I know, I'm sorry because not good in English. I mean I don't see any

options.foo.bar.baz = {
     enable = mkBoolOpt false "Enable module";

In your dotfiles

the profiles are declared right here: https://github.com/isabelroses/dotfiles/blob/main/modules/generic/profiles.nix#L6

comfysage avatar May 11 '25 06:05 comfysage

I use this

{lib,config, ...}: {
  options.garden.profiles = {
    workstation.enable = lib.mkEnableOption "workstation";
  };
  programs.fzf = {
    inherit (config.garden.profiles.workstation) enable;
    enableZshIntegration = true;
    enableFishIntegration = true;
    # enableNushellIntegration = true;
    defaultOptions = [
      "--height 40%"
      "--border"
    ];
  };
}

and error:

error: Module `/nix/store/s5yh3qqq871kr1scw2nqyclyq4vjj5xq-source/modules/home/cli-tui/fzf.nix' has an unsupported attribute `programs'. This is caused by introducing a top-level `config' or `options' attribute. Add configuration attributes immediately on the top level instead, or move all of them (namely: programs) into the explicit `config' attribute.

phucisstupid avatar May 11 '25 06:05 phucisstupid

the profiles are declared right here: main/modules%2Fgeneric%2Fprofiles.nix#L6

I think this can be write shorter with:

{ lib, ... }:

with lib;

let
  enableOptions = names:
    builtins.listToAttrs (map (name: {
      inherit name;
      value = mkEnableOption name;
    }) names);
in
{
  options.garden.profiles =
    enableOptions [
      "graphical" "headless" "workstation" "gaming" "laptop"
    ] // {
      server = {
        enable = mkEnableOption "server";
      } // enableOptions [ "oracle" "hetzner" ];
    };
}

phucisstupid avatar May 11 '25 06:05 phucisstupid