diff --git a/nixos/bootstrap/flake.nix b/nixos/bootstrap/flake.nix index 3c4a0c1c..4d34487e 100644 --- a/nixos/bootstrap/flake.nix +++ b/nixos/bootstrap/flake.nix @@ -43,6 +43,7 @@ inherit system; modules = baseModules ++ modules; specialArgs = { inherit inputs; } // specialArgs; + makeEnable = (import ../make-enable.nix) nixpkgs.lib; }); machinesPath = ../machines; machineFilenames = builtins.attrNames (builtins.readDir machinesPath); diff --git a/nixos/desktop.nix b/nixos/desktop.nix index 594e11ed..f80f9e9a 100644 --- a/nixos/desktop.nix +++ b/nixos/desktop.nix @@ -2,7 +2,6 @@ { imports = [ ./fonts.nix - inputs.home-manager.nixosModule ]; services.xserver = { diff --git a/nixos/environment.nix b/nixos/environment.nix index 1db32a47..76bc110e 100644 --- a/nixos/environment.nix +++ b/nixos/environment.nix @@ -1,4 +1,6 @@ { config, pkgs, options, lib, inputs, ... }: +let libDir = "${config.dotfiles-directory}/dotfiles/lib"; +in with lib; { options = { @@ -8,8 +10,7 @@ with lib; }; }; - config = let libDir = "${config.dotfiles-directory}/dotfiles/lib"; - in { + config = { # Shell configuration programs.zsh = { enable = true; diff --git a/nixos/flake.nix b/nixos/flake.nix index 51b7f58e..61d27e1e 100644 --- a/nixos/flake.nix +++ b/nixos/flake.nix @@ -131,6 +131,7 @@ myPackages = { taffybar = inputs.imalison-taffybar.defaultPackage."${system}"; }; + makeEnable = (import ./make-enable.nix) nixpkgs.lib; } // specialArgs; }); machinesFilepath = ./machines; diff --git a/nixos/home-manager.nix b/nixos/home-manager.nix index 78b96e67..21940d63 100644 --- a/nixos/home-manager.nix +++ b/nixos/home-manager.nix @@ -1,4 +1,4 @@ -inputs: { pkgs, config, ... }: { +{ pkgs, config, specialArgs, ... }: { xsession = { enable = true; preferStatusNotifierItems = true; @@ -33,7 +33,7 @@ inputs: { pkgs, config, ... }: { services.taffybar = { enable = true; - package = inputs.imalison-taffybar.defaultPackage."${pkgs.system}"; + package = specialArgs.nixos.specialArgs.inputs.imalison-taffybar.defaultPackage."${pkgs.system}"; }; services.notify-osd = { diff --git a/nixos/make-enable.nix b/nixos/make-enable.nix new file mode 100644 index 00000000..5dbecd44 --- /dev/null +++ b/nixos/make-enable.nix @@ -0,0 +1,26 @@ +lib: config: pathStr: default: configAttrs: +let + + pathToAttrSet = str: value: + let + parts = lib.splitString "." str; + in + if lib.length parts == 1 then + { ${lib.head parts} = value; } + else + { ${lib.head parts} = pathToAttrSet (lib.concatStringsSep "." (lib.tail parts)) value; }; + + optionsSet = pathToAttrSet pathStr { + enable = lib.mkOption { + inherit default; + type = lib.types.bool; + }; + }; + + cfg = lib.attrByPath (lib.splitString "." pathStr) { enable = false; defaulted = true; } config; + +in +{ + options = optionsSet; + config = lib.mkIf cfg.enable configAttrs; +} diff --git a/nixos/nix.nix b/nixos/nix.nix index f7237133..52806c8d 100644 --- a/nixos/nix.nix +++ b/nixos/nix.nix @@ -1,5 +1,16 @@ -{ inputs, ... }: +{ inputs, specialArgs, config, ... }: { + imports = [ + inputs.home-manager.nixosModule + ]; + home-manager.extraSpecialArgs = { + nixos = { + inherit specialArgs config; + }; + }; + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + nix = { extraOptions = '' experimental-features = nix-command flakes diff --git a/nixos/xmonad.nix b/nixos/xmonad.nix index 516ecc7f..41559bdb 100644 --- a/nixos/xmonad.nix +++ b/nixos/xmonad.nix @@ -1,5 +1,5 @@ -{ config, pkgs, options, inputs, ... }: -{ +{ config, pkgs, options, inputs, specialArgs, ... }: +specialArgs.makeEnable config "modules.xmonad" true { nixpkgs.overlays = with inputs; [ xmonad.overlay xmonad-contrib.overlay @@ -31,7 +31,5 @@ haskellPackages.dbus-hslogger ]; - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.imalison = (import ./home-manager.nix) inputs; + home-manager.users.imalison = (import ./home-manager.nix); }