From 7fb16160f7170a580d6791d0f26736ff68cceb3c Mon Sep 17 00:00:00 2001 From: Nathan Date: Wed, 22 Apr 2026 14:50:13 -0500 Subject: [PATCH] add home manager module --- flake.nix | 48 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/flake.nix b/flake.nix index f3a607f..fb69bef 100644 --- a/flake.nix +++ b/flake.nix @@ -3,23 +3,26 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager.url = "github:nix-community/home-manager"; nixvim.url = "github:nix-community/nixvim"; flake-parts.url = "github:hercules-ci/flake-parts"; }; outputs = - { nixvim, flake-parts, ... }@inputs: - flake-parts.lib.mkFlake { inherit inputs; } { - systems = [ - "x86_64-linux" - "aarch64-linux" - "x86_64-darwin" - "aarch64-darwin" - ]; + { self, nixvim, flake-parts, ... }@inputs: + flake-parts.lib.mkFlake { inherit self; inherit inputs; } { + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; - perSystem = - { pkgs, system, ... }: - let + imports = [ + inputs.home-manager.flakeModules.home-manager + ]; + + perSystem = { pkgs, system, ... }: let nixvimLib = nixvim.lib.${system}; nixvim' = nixvim.legacyPackages.${system}; nixvimModule = { opts }: { @@ -32,8 +35,7 @@ }; }; nvim = { opts }: nixvim'.makeNixvimWithModule (nixvimModule { inherit opts; }); - in - { + in { checks = { # Run `nix flake check .` to verify that your config is not broken default = nixvimLib.check.mkTestDerivationFromNixvimModule (nixvimModule { opts = { pywal = false; }; }); @@ -54,5 +56,25 @@ }; }; }; + + flake.homeModules.default = { config, lib, pkgs, ... }: { + + options.programs.moirai = { + enable = lib.mkEnableOption "Moirai"; + defaultEditor = lib.mkEnableOption "default editor"; + pywal = lib.mkEnableOption "pywal support"; + }; + + config = lib.mkIf config.programs.moirai.enable { + + home.packages = with self.packages.${pkgs.stdenv.hostPlatform.system}; lib.mkMerge [ + (lib.mkIf config.programs.moirai.pywal [ pywal ]) + (lib.mkIf (!config.programs.moirai.pywal) [ default ]) + ]; + + home.sessionVariables.EDITOR = lib.mkIf config.programs.moirai.defaultEditor "nvim"; + }; + }; + }; }