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

Home manager module #65

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,10 @@ in {
}
```

This flake also provides a NixOS/Home Manager module, which can be imported by
This flake also provides a Home Manager module, which can be imported by
adding this in your configuration:
```nix
# home.nix
{pkgs, inputs, ...}: {
imports = [
inputs.matugen.nixosModules.default
Expand All @@ -177,12 +178,6 @@ adding this in your configuration:
}
```

The module does NOT automatically symlink the files. For an example of using this module with Home Manager, see https://github.com/InioX/matugen/issues/28

Option details can be found by reading the [module](./module.nix). A
[search.nixos.org](https://search.nixos.org/options)-like option viewer is
planned.

</p>
</details>

Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,26 @@
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
systems.url = "github:nix-systems/default-linux";
};
outputs = { self, nixpkgs, systems }:
outputs =
{
self,
nixpkgs,
systems,
}:
let
forAllSystems = nixpkgs.lib.genAttrs (import systems);
pkgsFor = nixpkgs.legacyPackages;
in {
in
{
packages = forAllSystems (system: {
default = pkgsFor.${system}.callPackage ./. { };
});
devShells = forAllSystems (system: {
default = pkgsFor.${system}.callPackage ./shell.nix { };
});
nixosModules = {
matugen = import ./module.nix self;
default = self.nixosModules.matugen;
homeManagerModules = rec {
matugen = import ./hm-module.nix self;
default = matugen;
};
};
}
24 changes: 24 additions & 0 deletions hm-module.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
self:
{
config,
pkgs,
lib,
...
}:
let
cfg = config.programs.matugen;
in
{
options.programs.matugen = {
enable = lib.mkEnableOption "matugen";
package = lib.mkPackageOption pkgs "matugen" { };
settings = lib.mkOption { type = lib.types.attrs; };
};

config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile."matugen/config.toml".source = lib.mkIf (cfg.settings != null) (
(pkgs.formats.toml { }).generate "matugen" cfg.settings
);
};
}
139 changes: 0 additions & 139 deletions module.nix

This file was deleted.