Skip to content

Commit 33bfb05

Browse files
bors[bot]Pacman99
andauthored
Merge #121
121: Fix default input detection r=blaggacao a=Pacman99 This fixes #413 and the general infinite recursion issues that are happening. Also switch back to upstream flake-utils-plus, the divnix patches. I don't believe the divnix patches actually affect anything. Co-authored-by: Parthiv Seetharaman <[email protected]>
2 parents 70e803c + cd2f106 commit 33bfb05

7 files changed

+32
-35
lines changed

doc/api-reference-channels.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ nix flake
4848

4949
*_Default_*
5050
```
51-
"config.self.inputs.<name>"
51+
"self.inputs.<name>"
5252
```
5353

5454

flake.lock

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
home-manager.inputs.nixpkgs.follows = "nixlib";
2020

2121
devshell.url = "github:numtide/devshell";
22-
# fork with urgent fixes that can't be added quickly upstream in respect of upstream user base
23-
flake-utils-plus.url = "github:divnix/flake-utils-plus";
22+
flake-utils-plus.url = "github:gytis-ivaskevicius/flake-utils-plus";
2423

2524
nixos-generators.url = "github:nix-community/nixos-generators";
2625
nixos-generators.inputs.nixpkgs.follows = "blank";

src/mkFlake/default.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{ self, inputs, ... } @ args:
44
let
55
# avoid infinite recursions w.r.t. using self or inputs in imports
6-
injectedDeps' = injectedDeps // { inherit (args) self inputs; };
6+
injectedDeps' = injectedDeps // { inherit self inputs; };
77

88
options' = import ./options.nix injectedDeps';
99
fupAdapter' = import ./fup-adapter.nix injectedDeps';

src/mkFlake/fup-adapter.nix

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# constructor dependencies
2-
{ lib, flake-utils-plus, internal-modules, ... }:
2+
{ lib, self, inputs, flake-utils-plus, internal-modules, ... }:
33

44
{
55
# evaluated digga configuration
@@ -24,7 +24,7 @@ let
2424

2525
defaultHostModules = [
2626
(internal-modules.hmNixosDefaults {
27-
specialArgs = config.home.importables // { inherit (config) self inputs; };
27+
specialArgs = config.home.importables // { inherit self inputs; };
2828
modules = config.home.modules ++ config.home.exportedModules;
2929
})
3030
(internal-modules.globalDefaults {
@@ -60,11 +60,9 @@ let
6060

6161
diggaFupArgs = {
6262
inherit (config)
63-
self
64-
inputs
6563
channelsConfig
6664
supportedSystems;
67-
inherit sharedOverlays;
65+
inherit self inputs sharedOverlays;
6866

6967
hosts = builtins.mapAttrs (_: stripHost) config.nixos.hosts;
7068

@@ -79,7 +77,7 @@ let
7977

8078
hostDefaults = flake-utils-plus.lib.mergeAny (stripHost config.nixos.hostDefaults) {
8179
# add `self` & `inputs` as specialargs so their libs can be used in imports
82-
specialArgs = config.nixos.importables // { inherit (config) self inputs; };
80+
specialArgs = config.nixos.importables // { inherit self inputs; };
8381
modules = config.nixos.hostDefaults.exportedModules ++ defaultHostModules;
8482
};
8583

@@ -93,8 +91,8 @@ let
9391
# since we can't detect overlays owned by self
9492
# we have to filter out ones exported by the inputs
9593
# optimally we would want a solution for NixOS/nix#4740
96-
inherit (config.self) pkgs;
97-
inherit (config) inputs;
94+
inherit (self) pkgs;
95+
inherit inputs;
9896
};
9997

10098
outputsBuilder = channels:

src/mkFlake/options.nix

+2-2
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ let
255255
inputOpt = name: {
256256
input = mkOption {
257257
type = flakeType;
258-
default = config.self.inputs.${name};
259-
defaultText = "config.self.inputs.<name>";
258+
default = self.inputs.${name};
259+
defaultText = "self.inputs.<name>";
260260
description = ''
261261
nixpkgs flake input to use for this channel
262262
'';

src/mkFlake/outputs-builder.nix

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# constructor dependencies
2-
{ lib, deploy, devshell, home-manager, flake-utils-plus, tests, ... }:
2+
{ lib, self, inputs, deploy, devshell, home-manager, flake-utils-plus, tests, ... }:
33
config: channels:
44
let
55

@@ -21,7 +21,7 @@ let
2121
inherit username homeDirectory pkgs system;
2222

2323
extraModules = config.home.modules ++ config.home.exportedModules;
24-
extraSpecialArgs = config.home.importables // { inherit (config) self inputs; };
24+
extraSpecialArgs = config.home.importables // { inherit self inputs; };
2525

2626
configuration = {
2727
imports = [ configuration ];
@@ -46,7 +46,7 @@ in
4646

4747
inherit homeConfigurationsPortable;
4848

49-
packages = flake-utils-plus.lib.exportPackages config.self.overlays channels;
49+
packages = flake-utils-plus.lib.exportPackages self.overlays channels;
5050

5151
devShell =
5252
let
@@ -58,21 +58,21 @@ in
5858
in
5959
(eval {
6060
inherit configuration;
61-
extraSpecialArgs = { inherit (config) self inputs; };
61+
extraSpecialArgs = { inherit self inputs; };
6262
}).shell;
6363

6464
checks =
6565
(
66-
# for config.self.homeConfigurations if present & non empty
66+
# for self.homeConfigurations if present & non empty
6767
if (
68-
(builtins.hasAttr "homeConfigurations" config.self) &&
69-
(config.self.homeConfigurations != { })
68+
(builtins.hasAttr "homeConfigurations" self) &&
69+
(self.homeConfigurations != { })
7070
) then
7171
let
7272
seive = _: v: v.system == system; # only test for the appropriate system
7373
collectActivationPackages = n: v: { name = "user-" + n; value = v.activationPackage; };
7474
in
75-
lib.filterAttrs seive (lib.mapAttrs' collectActivationPackages config.self.homeConfigurations)
75+
lib.filterAttrs seive (lib.mapAttrs' collectActivationPackages self.homeConfigurations)
7676
else { }
7777
)
7878
//
@@ -89,28 +89,28 @@ in
8989
)
9090
//
9191
(
92-
# for config.self.deploy if present & non-empty
92+
# for self.deploy if present & non-empty
9393
if (
94-
(builtins.hasAttr "deploy" config.self) &&
95-
(config.self.deploy != { })
94+
(builtins.hasAttr "deploy" self) &&
95+
(self.deploy != { })
9696
) then
9797
let
98-
deployChecks = deploy.lib.${system}.deployChecks config.self.deploy;
98+
deployChecks = deploy.lib.${system}.deployChecks self.deploy;
9999
renameOp = n: v: { name = "deploy-" + n; value = deployChecks.${n}; };
100100
in
101101
lib.mapAttrs' renameOp deployChecks
102102
else { }
103103
)
104104
//
105105
(
106-
# for config.self.nixosConfigurations if present & non-empty
106+
# for self.nixosConfigurations if present & non-empty
107107
if (
108-
(builtins.hasAttr "nixosConfigurations" config.self) &&
109-
(config.self.nixosConfigurations != { })
108+
(builtins.hasAttr "nixosConfigurations" self) &&
109+
(self.nixosConfigurations != { })
110110
) then
111111
let
112112
systemSieve = _: host: host.config.nixpkgs.system == system;
113-
hostConfigsOnThisSystem = lib.filterAttrs systemSieve config.self.nixosConfigurations;
113+
hostConfigsOnThisSystem = lib.filterAttrs systemSieve self.nixosConfigurations;
114114

115115
createCustomTestOp = n: host: test:
116116
lib.warnIf (!(test ? name)) ''

0 commit comments

Comments
 (0)