Compare commits

...

3 Commits

5 changed files with 68 additions and 4 deletions

View File

@ -129,7 +129,7 @@
useUserPackages = true;
inherit users;
extraSpecialArgs = {
inherit inputs outputs vars nixpkgs;
inherit inputs outputs vars nixpkgs home-manager;
extraPkgs = mkExtraPkgs system;
};
};
@ -173,7 +173,7 @@
})
] ++ extraModules;
specialArgs = {
inherit inputs outputs vars nixpkgs;
inherit inputs outputs vars nixpkgs home-manager;
extraPkgs = mkExtraPkgs system;
};
};

View File

@ -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).";

7
lib/nixfiles/default.nix Normal file
View File

@ -0,0 +1,7 @@
pkgs:
let
inherit (pkgs) lib;
in
{
types = (import ./types.nix) pkgs;
}

13
lib/nixfiles/types.nix Normal file
View File

@ -0,0 +1,13 @@
pkgs:
let
inherit (pkgs) lib;
inherit (lib.types) mkOptionType;
inherit (lib.options) mergeEqualOption;
in
{
flake = mkOptionType {
name="flake";
description="Nix flake";
descriptionClass = "noun";
merge = mergeEqualOption; check = (value: value._type or "" == "flake"); };
}

View File

@ -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";
};
};
}