switch modules/outputs names
This commit is contained in:
parent
e7fdbf416c
commit
482cbf67cd
16 changed files with 147 additions and 147 deletions
|
|
@ -1,26 +1,10 @@
|
||||||
{
|
{
|
||||||
lib,
|
config,
|
||||||
snow,
|
_snowFlake,
|
||||||
...
|
...
|
||||||
}: let
|
}: {
|
||||||
inherit
|
outputs.checks =
|
||||||
(lib)
|
_snowFlake.inputs.deploy-rs.lib
|
||||||
mkOption
|
|> builtins.mapAttrs (system: deployLib:
|
||||||
types
|
deployLib.deployChecks config.outputs.deploy);
|
||||||
;
|
}
|
||||||
inherit
|
|
||||||
(snow.lib)
|
|
||||||
mkPerSystemFlakeOutput
|
|
||||||
;
|
|
||||||
in
|
|
||||||
mkPerSystemFlakeOutput {
|
|
||||||
name = "checks";
|
|
||||||
option = mkOption {
|
|
||||||
type = types.lazyAttrsOf types.package;
|
|
||||||
default = {};
|
|
||||||
description = ''
|
|
||||||
Derivations to be built by [`nix flake check`](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake-check.html).
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
file = ./checks.nix;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,7 @@
|
||||||
{...}: {
|
{...}: {
|
||||||
imports = [
|
imports = [
|
||||||
./outputs.nix
|
|
||||||
|
|
||||||
./apps.nix
|
|
||||||
./checks.nix
|
./checks.nix
|
||||||
./devShells.nix
|
./deploy.nix
|
||||||
./formatter.nix
|
|
||||||
./legacyPackages.nix
|
|
||||||
./nixosConfigurations.nix
|
./nixosConfigurations.nix
|
||||||
./nixosModules.nix
|
|
||||||
./overlays.nix
|
|
||||||
./packages.nix
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,84 @@
|
||||||
{lib, ...}: let
|
{
|
||||||
|
_snowFlake,
|
||||||
|
snow,
|
||||||
|
config,
|
||||||
|
systems,
|
||||||
|
root,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
inherit
|
inherit
|
||||||
(lib)
|
(builtins)
|
||||||
mkOption
|
all
|
||||||
types
|
attrNames
|
||||||
literalExpression
|
warn
|
||||||
|
;
|
||||||
|
|
||||||
|
inherit
|
||||||
|
(config)
|
||||||
|
nodes
|
||||||
;
|
;
|
||||||
in {
|
in {
|
||||||
options = {
|
outputs.nixosConfigurations = let
|
||||||
outputs.nixosConfigurations = mkOption {
|
groups = snow.lib.parseGroupDecls root config.nodes.groups;
|
||||||
type = types.lazyAttrsOf types.raw;
|
in
|
||||||
default = {};
|
snow.lib.mapNodes nodes (
|
||||||
description = ''
|
{
|
||||||
Instantiated NixOS configurations. Used by `nixos-rebuild`.
|
base,
|
||||||
|
lib,
|
||||||
|
name,
|
||||||
|
node,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
nodeGroups =
|
||||||
|
(node.groups groups)
|
||||||
|
|> snow.lib.resolveGroupsInheritance
|
||||||
|
|> snow.lib.groupModules;
|
||||||
|
|
||||||
`nixosConfigurations` is for specific machines. If you want to expose
|
homeManager =
|
||||||
reusable configurations, add them to [`nixosModules`](#opt-flake.nixosModules)
|
if node.homeManager != null
|
||||||
in the form of modules (no `lib.nixosSystem`), so that you can reference
|
then node.homeManager
|
||||||
them in this or another flake's `nixosConfigurations`.
|
else if nodes.homeManager != null
|
||||||
'';
|
then nodes.homeManager
|
||||||
example = literalExpression ''
|
else
|
||||||
{
|
warn ''
|
||||||
my-machine = inputs.nixpkgs.lib.nixosSystem {
|
[snowflake] Neither `nodes.homeManager` nor `nodes.nodes.${name}.homeManager` were specified!
|
||||||
# system is not needed with freshly generated hardware-configuration.nix
|
[snowflake] home-manager will NOT be used! User configuration will be ignored!
|
||||||
# system = "x86_64-linux"; # or set nixpkgs.hostPlatform in a module.
|
''
|
||||||
modules = [
|
null;
|
||||||
./my-machine/nixos-configuration.nix
|
|
||||||
config.nixosModules.my-module
|
userArgs = nodes.args // node.args;
|
||||||
];
|
snowArgs = {
|
||||||
|
inherit systems snow root base nodes node;
|
||||||
|
inherit (node) system;
|
||||||
|
hostname = name;
|
||||||
|
|
||||||
|
_snow = {
|
||||||
|
inherit (_snowFlake) inputs;
|
||||||
|
inherit userArgs snowArgs homeManager;
|
||||||
|
specialArgs = userArgs // snowArgs;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
specialArgs = assert (userArgs
|
||||||
|
|> attrNames
|
||||||
|
|> all (argName:
|
||||||
|
! snowArgs ? argName
|
||||||
|
|| abort ''
|
||||||
|
`specialArgs` are like super important to Snow my love... </3
|
||||||
|
But `args.${argName}` is a reserved argument name :(
|
||||||
|
''));
|
||||||
|
snowArgs._snow.specialArgs;
|
||||||
|
in
|
||||||
|
lib.nixosSystem {
|
||||||
|
inherit (node) system;
|
||||||
|
inherit specialArgs;
|
||||||
|
modules =
|
||||||
|
[
|
||||||
|
_snowFlake.self.nixosModules.default
|
||||||
|
(snow.lib.findImport /${root}/hosts/${name})
|
||||||
|
]
|
||||||
|
++ nodeGroups
|
||||||
|
++ node.modules
|
||||||
|
++ nodes.modules;
|
||||||
}
|
}
|
||||||
'';
|
);
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,26 @@
|
||||||
{
|
{
|
||||||
config,
|
lib,
|
||||||
_snowFlake,
|
snow,
|
||||||
...
|
...
|
||||||
}: {
|
}: let
|
||||||
outputs.checks =
|
inherit
|
||||||
_snowFlake.inputs.deploy-rs.lib
|
(lib)
|
||||||
|> builtins.mapAttrs (system: deployLib:
|
mkOption
|
||||||
deployLib.deployChecks config.outputs.deploy);
|
types
|
||||||
}
|
;
|
||||||
|
inherit
|
||||||
|
(snow.lib)
|
||||||
|
mkPerSystemFlakeOutput
|
||||||
|
;
|
||||||
|
in
|
||||||
|
mkPerSystemFlakeOutput {
|
||||||
|
name = "checks";
|
||||||
|
option = mkOption {
|
||||||
|
type = types.lazyAttrsOf types.package;
|
||||||
|
default = {};
|
||||||
|
description = ''
|
||||||
|
Derivations to be built by [`nix flake check`](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake-check.html).
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
file = ./checks.nix;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,15 @@
|
||||||
{...}: {
|
{...}: {
|
||||||
imports = [
|
imports = [
|
||||||
|
./outputs.nix
|
||||||
|
|
||||||
|
./apps.nix
|
||||||
./checks.nix
|
./checks.nix
|
||||||
./deploy.nix
|
./devShells.nix
|
||||||
|
./formatter.nix
|
||||||
|
./legacyPackages.nix
|
||||||
./nixosConfigurations.nix
|
./nixosConfigurations.nix
|
||||||
|
./nixosModules.nix
|
||||||
|
./overlays.nix
|
||||||
|
./packages.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,84 +1,35 @@
|
||||||
{
|
{lib, ...}: let
|
||||||
_snowFlake,
|
|
||||||
snow,
|
|
||||||
config,
|
|
||||||
systems,
|
|
||||||
root,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
inherit
|
inherit
|
||||||
(builtins)
|
(lib)
|
||||||
all
|
mkOption
|
||||||
attrNames
|
types
|
||||||
warn
|
literalExpression
|
||||||
;
|
|
||||||
|
|
||||||
inherit
|
|
||||||
(config)
|
|
||||||
nodes
|
|
||||||
;
|
;
|
||||||
in {
|
in {
|
||||||
outputs.nixosConfigurations = let
|
options = {
|
||||||
groups = snow.lib.parseGroupDecls root config.nodes.groups;
|
outputs.nixosConfigurations = mkOption {
|
||||||
in
|
type = types.lazyAttrsOf types.raw;
|
||||||
snow.lib.mapNodes nodes (
|
default = {};
|
||||||
{
|
description = ''
|
||||||
base,
|
Instantiated NixOS configurations. Used by `nixos-rebuild`.
|
||||||
lib,
|
|
||||||
name,
|
|
||||||
node,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
nodeGroups =
|
|
||||||
(node.groups groups)
|
|
||||||
|> snow.lib.resolveGroupsInheritance
|
|
||||||
|> snow.lib.groupModules;
|
|
||||||
|
|
||||||
homeManager =
|
`nixosConfigurations` is for specific machines. If you want to expose
|
||||||
if node.homeManager != null
|
reusable configurations, add them to [`nixosModules`](#opt-flake.nixosModules)
|
||||||
then node.homeManager
|
in the form of modules (no `lib.nixosSystem`), so that you can reference
|
||||||
else if nodes.homeManager != null
|
them in this or another flake's `nixosConfigurations`.
|
||||||
then nodes.homeManager
|
'';
|
||||||
else
|
example = literalExpression ''
|
||||||
warn ''
|
{
|
||||||
[snowflake] Neither `nodes.homeManager` nor `nodes.nodes.${name}.homeManager` were specified!
|
my-machine = inputs.nixpkgs.lib.nixosSystem {
|
||||||
[snowflake] home-manager will NOT be used! User configuration will be ignored!
|
# system is not needed with freshly generated hardware-configuration.nix
|
||||||
''
|
# system = "x86_64-linux"; # or set nixpkgs.hostPlatform in a module.
|
||||||
null;
|
modules = [
|
||||||
|
./my-machine/nixos-configuration.nix
|
||||||
userArgs = nodes.args // node.args;
|
config.nixosModules.my-module
|
||||||
snowArgs = {
|
];
|
||||||
inherit systems snow root base nodes node;
|
|
||||||
inherit (node) system;
|
|
||||||
hostname = name;
|
|
||||||
|
|
||||||
_snow = {
|
|
||||||
inherit (_snowFlake) inputs;
|
|
||||||
inherit userArgs snowArgs homeManager;
|
|
||||||
specialArgs = userArgs // snowArgs;
|
|
||||||
};
|
};
|
||||||
};
|
|
||||||
specialArgs = assert (userArgs
|
|
||||||
|> attrNames
|
|
||||||
|> all (argName:
|
|
||||||
! snowArgs ? argName
|
|
||||||
|| abort ''
|
|
||||||
`specialArgs` are like super important to Snow my love... </3
|
|
||||||
But `args.${argName}` is a reserved argument name :(
|
|
||||||
''));
|
|
||||||
snowArgs._snow.specialArgs;
|
|
||||||
in
|
|
||||||
lib.nixosSystem {
|
|
||||||
inherit (node) system;
|
|
||||||
inherit specialArgs;
|
|
||||||
modules =
|
|
||||||
[
|
|
||||||
_snowFlake.self.nixosModules.default
|
|
||||||
(snow.lib.findImport /${root}/hosts/${name})
|
|
||||||
]
|
|
||||||
++ nodeGroups
|
|
||||||
++ node.modules
|
|
||||||
++ nodes.modules;
|
|
||||||
}
|
}
|
||||||
);
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue