From d23b9d4bd2e41790fa6f85e66c8fb8f2923bbcec Mon Sep 17 00:00:00 2001 From: NullBite Date: Thu, 14 Mar 2024 20:44:37 +0000 Subject: [PATCH] Add nixfiles lib and create flake options --- home/default.nix | 24 +++++++++++++++++++++++- system/default.nix | 24 +++++++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/home/default.nix b/home/default.nix index 6f3027e..5915139 100644 --- a/home/default.nix +++ b/home/default.nix @@ -1,7 +1,8 @@ -{ pkgs, config, lib, options, osConfig ? { }, ... }@args: +{ pkgs, config, lib, options, osConfig ? { }, nixpkgs, home-manager, ... }@args: let isStandalone = with builtins; !( (typeOf osConfig == "set") && hasAttr "home-manager" osConfig ); cfg = config.nixfiles; + flakeType = cfg.lib.types.flake; in { imports = [ @@ -18,6 +19,27 @@ in default = options; readOnly = true; }; + + lib = lib.mkOption { + description = "nixfiles library"; + default = (import ../lib/nixfiles) pkgs; + readOnly = true; + }; + + nixpkgs = lib.mkOption { + description = "nixpkgs flake"; + type = flakeType; + default = nixpkgs; + example = "inputs.nixpkgs"; + }; + + home-manager = lib.mkOption { + description = "home-manager flake"; + type = flakeType; + default = home-manager; + example = "inputs.home-manager"; + }; + meta.standalone = lib.mkOption { default = isStandalone; description = "Whether or not the home-manager installation is standalone (standalone installations don't have access to osConfig)."; diff --git a/system/default.nix b/system/default.nix index f4aa1a7..16df6a5 100644 --- a/system/default.nix +++ b/system/default.nix @@ -1,6 +1,7 @@ -{ pkgs, config, lib, options, ... }@args: +{ pkgs, config, lib, options, nixpkgs, home-manager, ... }@args: let cfg = config.nixfiles; + flakeType = cfg.lib.types.flake; in { imports = [ @@ -21,5 +22,26 @@ in example = true; type = lib.types.bool; }; + + lib = lib.mkOption { + description = "nixfiles library"; + default = (import ../lib/nixfiles) pkgs; + readOnly = true; + type = lib.types.attrs; + }; + + nixpkgs = lib.mkOption { + description = "nixpkgs flake"; + default = nixpkgs; + type = flakeType; + example = "nixpkgs"; + }; + + home-manager = lib.mkOption { + description = "home-manager flake"; + default = home-manager; + type = flakeType; + example = "home-manager"; + }; }; }