mirror of
https://github.com/donovanglover/nix-config.git
synced 2024-11-24 17:23:09 +01:00
feat: Pass nix-config as self to avoid infinite recursion
This change makes it possible to use this nix-config in all the different ways imaginable (containers, bare metal, tests, and as a separate flake input) *without* running into infinite recursion issues with self. It does this by using a trick similar to JavaScript in which `var self = this;`, thus enabling the usage of "this" (or self, in Nix's case) where it wouldn't otherwise be possible. Note that this *only* works if the input for this repository is named nix-config. This makes it impractical to combine with multiple configurations that employ the same strategy.
This commit is contained in:
parent
b368817c52
commit
59f557a3e5
@ -40,7 +40,7 @@
|
|||||||
nixosConfigurations = {
|
nixosConfigurations = {
|
||||||
nixos = nixosSystem {
|
nixos = nixosSystem {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
specialArgs = attrs;
|
specialArgs = attrs // { nix-config = self; };
|
||||||
modules = [
|
modules = [
|
||||||
./hardware/laptop.nix
|
./hardware/laptop.nix
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ config, stylix, home-manager, sakaya, ... }:
|
{ config, nix-config, sakaya, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (config.modules.system) username;
|
inherit (config.modules.system) username;
|
||||||
@ -39,8 +39,7 @@ let
|
|||||||
];
|
];
|
||||||
|
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit home-manager;
|
inherit nix-config;
|
||||||
inherit stylix;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ home-manager, stylix, pkgs, config, lib, ... }:
|
{ nix-config, pkgs, config, lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (lib) mkEnableOption mkIf mkMerge;
|
inherit (lib) mkEnableOption mkIf mkMerge;
|
||||||
@ -14,8 +14,8 @@ let
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = attrValues {
|
imports = attrValues {
|
||||||
inherit (home-manager.nixosModules) home-manager;
|
inherit (nix-config.inputs.home-manager.nixosModules) home-manager;
|
||||||
inherit (stylix.nixosModules) stylix;
|
inherit (nix-config.inputs.stylix.nixosModules) stylix;
|
||||||
};
|
};
|
||||||
|
|
||||||
options.modules.desktop = {
|
options.modules.desktop = {
|
||||||
|
@ -1,14 +1,19 @@
|
|||||||
{ pkgs, lib, config, ... }:
|
{ nix-config, pkgs, lib, config, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption;
|
inherit (lib) mkOption;
|
||||||
inherit (lib.types) str listOf;
|
inherit (lib.types) str listOf;
|
||||||
inherit (pkgs.nixVersions) nix_2_19;
|
inherit (pkgs.nixVersions) nix_2_19;
|
||||||
inherit (cfg) username;
|
inherit (cfg) username;
|
||||||
|
inherit (builtins) attrValues;
|
||||||
|
|
||||||
cfg = config.modules.system;
|
cfg = config.modules.system;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
imports = attrValues {
|
||||||
|
inherit (nix-config.inputs.home-manager.nixosModules) home-manager;
|
||||||
|
};
|
||||||
|
|
||||||
options.modules.system = {
|
options.modules.system = {
|
||||||
username = mkOption {
|
username = mkOption {
|
||||||
type = str;
|
type = str;
|
||||||
|
@ -8,6 +8,7 @@ in
|
|||||||
defaults.documentation.enable = lib.mkDefault false;
|
defaults.documentation.enable = lib.mkDefault false;
|
||||||
node.specialArgs = {
|
node.specialArgs = {
|
||||||
inherit self;
|
inherit self;
|
||||||
|
nix-config = self;
|
||||||
};
|
};
|
||||||
imports = [ test ];
|
imports = [ test ];
|
||||||
}).config.result
|
}).config.result
|
||||||
|
Loading…
Reference in New Issue
Block a user