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

gather inspiration from the best flakes #4

Closed
dminca opened this issue Apr 21, 2024 · 6 comments
Closed

gather inspiration from the best flakes #4

dminca opened this issue Apr 21, 2024 · 6 comments
Assignees

Comments

@dminca
Copy link
Owner Author

dminca commented May 25, 2024

Some conversation from the forum of people trying to modularize home-manager configuration

@dminca
Copy link
Owner Author

dminca commented May 30, 2024

 {config, pkgs, lib, ...}:
 
 {
   systemd.services = lib.mkIf (config.networking.hostName == "my-server") {
      ircSession = {
        wantedBy = [ "multi-user.target" ]; 
        after = [ "network.target" ];
        description = "Start the irc client of username.";
        serviceConfig = {
          Type = "forking";
          User = "username";
          ExecStart = ''${pkgs.screen}/bin/screen -dmS irc ${pkgs.irssi}/bin/irssi'';         
          ExecStop = ''${pkgs.screen}/bin/screen -S irc -X quit'';
        };
      };
   };
 
   environment.systemPackages = lib.mkIf (config.networking.hostName == "my-server") [ pkgs.screen ];
 
   # ... usual configuration ...
 }

@dminca
Copy link
Owner Author

dminca commented May 30, 2024

# ./foo.nix
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.programs.foo;
in {
  options.programs.foo = {
    enable = mkEnableOption "the foo program";

    package = mkOption {
      type = types.package;
      default = pkgs.hello;
      defaultText = literalExpression "pkgs.hello";
      description = "foo package to use.";
    };

    extraConfig = mkOption {
      default = "";
      example = ''
        foo bar
      '';
      type = types.lines;
      description = ''
        Extra settings for foo.
      '';
    };
  };

  config = mkIf cfg.enable {
    home.packages = [ cfg.package ];
    xdg.configFile."foo/foorc" = mkIf (cfg.extraConfig != "") {
      text = ''
        # Generated by Home Manager.

        ${cfg.extraConfig}
      '';
    };
  };
}

@dminca
Copy link
Owner Author

dminca commented May 30, 2024

config = if config.services.httpd.enable then {
  environment.systemPackages = [ ... ];
  ...
} else {};

dminca added a commit that referenced this issue May 30, 2024
- prepare to expand this for multiple hosts

Resolves:
Related: #1 #3 #4
Signed-off-by: Daniel Andrei Mincă <[email protected]>
@dminca
Copy link
Owner Author

dminca commented Jun 1, 2024

asked the Discord community for proposals and I've got this

dminca added a commit that referenced this issue Jun 1, 2024
- darwinConfigurations to account for multiple hosts
- homeManagerConfiguration to expand for multiple hosts
- define a common set of dependencies and settings which are imported

Resolves: #1 #4
Related:
Signed-off-by: Daniel Andrei Mincă <[email protected]>
@dminca
Copy link
Owner Author

dminca commented Jun 2, 2024

Solved in #7

@dminca dminca closed this as completed Jun 2, 2024
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

No branches or pull requests

1 participant