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,
|
||||
snow,
|
||||
config,
|
||||
_snowFlake,
|
||||
...
|
||||
}: let
|
||||
inherit
|
||||
(lib)
|
||||
mkOption
|
||||
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;
|
||||
}
|
||||
}: {
|
||||
outputs.checks =
|
||||
_snowFlake.inputs.deploy-rs.lib
|
||||
|> builtins.mapAttrs (system: deployLib:
|
||||
deployLib.deployChecks config.outputs.deploy);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,7 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
./outputs.nix
|
||||
|
||||
./apps.nix
|
||||
./checks.nix
|
||||
./devShells.nix
|
||||
./formatter.nix
|
||||
./legacyPackages.nix
|
||||
./deploy.nix
|
||||
./nixosConfigurations.nix
|
||||
./nixosModules.nix
|
||||
./overlays.nix
|
||||
./packages.nix
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +1,84 @@
|
|||
{lib, ...}: let
|
||||
{
|
||||
_snowFlake,
|
||||
snow,
|
||||
config,
|
||||
systems,
|
||||
root,
|
||||
...
|
||||
}: let
|
||||
inherit
|
||||
(lib)
|
||||
mkOption
|
||||
types
|
||||
literalExpression
|
||||
(builtins)
|
||||
all
|
||||
attrNames
|
||||
warn
|
||||
;
|
||||
|
||||
inherit
|
||||
(config)
|
||||
nodes
|
||||
;
|
||||
in {
|
||||
options = {
|
||||
outputs.nixosConfigurations = mkOption {
|
||||
type = types.lazyAttrsOf types.raw;
|
||||
default = {};
|
||||
description = ''
|
||||
Instantiated NixOS configurations. Used by `nixos-rebuild`.
|
||||
outputs.nixosConfigurations = let
|
||||
groups = snow.lib.parseGroupDecls root config.nodes.groups;
|
||||
in
|
||||
snow.lib.mapNodes nodes (
|
||||
{
|
||||
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
|
||||
reusable configurations, add them to [`nixosModules`](#opt-flake.nixosModules)
|
||||
in the form of modules (no `lib.nixosSystem`), so that you can reference
|
||||
them in this or another flake's `nixosConfigurations`.
|
||||
'';
|
||||
example = literalExpression ''
|
||||
{
|
||||
my-machine = inputs.nixpkgs.lib.nixosSystem {
|
||||
# system is not needed with freshly generated hardware-configuration.nix
|
||||
# system = "x86_64-linux"; # or set nixpkgs.hostPlatform in a module.
|
||||
modules = [
|
||||
./my-machine/nixos-configuration.nix
|
||||
config.nixosModules.my-module
|
||||
];
|
||||
homeManager =
|
||||
if node.homeManager != null
|
||||
then node.homeManager
|
||||
else if nodes.homeManager != null
|
||||
then nodes.homeManager
|
||||
else
|
||||
warn ''
|
||||
[snowflake] Neither `nodes.homeManager` nor `nodes.nodes.${name}.homeManager` were specified!
|
||||
[snowflake] home-manager will NOT be used! User configuration will be ignored!
|
||||
''
|
||||
null;
|
||||
|
||||
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,
|
||||
_snowFlake,
|
||||
lib,
|
||||
snow,
|
||||
...
|
||||
}: {
|
||||
outputs.checks =
|
||||
_snowFlake.inputs.deploy-rs.lib
|
||||
|> builtins.mapAttrs (system: deployLib:
|
||||
deployLib.deployChecks config.outputs.deploy);
|
||||
}
|
||||
}: let
|
||||
inherit
|
||||
(lib)
|
||||
mkOption
|
||||
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 = [
|
||||
./outputs.nix
|
||||
|
||||
./apps.nix
|
||||
./checks.nix
|
||||
./deploy.nix
|
||||
./devShells.nix
|
||||
./formatter.nix
|
||||
./legacyPackages.nix
|
||||
./nixosConfigurations.nix
|
||||
./nixosModules.nix
|
||||
./overlays.nix
|
||||
./packages.nix
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,84 +1,35 @@
|
|||
{
|
||||
_snowFlake,
|
||||
snow,
|
||||
config,
|
||||
systems,
|
||||
root,
|
||||
...
|
||||
}: let
|
||||
{lib, ...}: let
|
||||
inherit
|
||||
(builtins)
|
||||
all
|
||||
attrNames
|
||||
warn
|
||||
;
|
||||
|
||||
inherit
|
||||
(config)
|
||||
nodes
|
||||
(lib)
|
||||
mkOption
|
||||
types
|
||||
literalExpression
|
||||
;
|
||||
in {
|
||||
outputs.nixosConfigurations = let
|
||||
groups = snow.lib.parseGroupDecls root config.nodes.groups;
|
||||
in
|
||||
snow.lib.mapNodes nodes (
|
||||
{
|
||||
base,
|
||||
lib,
|
||||
name,
|
||||
node,
|
||||
...
|
||||
}: let
|
||||
nodeGroups =
|
||||
(node.groups groups)
|
||||
|> snow.lib.resolveGroupsInheritance
|
||||
|> snow.lib.groupModules;
|
||||
options = {
|
||||
outputs.nixosConfigurations = mkOption {
|
||||
type = types.lazyAttrsOf types.raw;
|
||||
default = {};
|
||||
description = ''
|
||||
Instantiated NixOS configurations. Used by `nixos-rebuild`.
|
||||
|
||||
homeManager =
|
||||
if node.homeManager != null
|
||||
then node.homeManager
|
||||
else if nodes.homeManager != null
|
||||
then nodes.homeManager
|
||||
else
|
||||
warn ''
|
||||
[snowflake] Neither `nodes.homeManager` nor `nodes.nodes.${name}.homeManager` were specified!
|
||||
[snowflake] home-manager will NOT be used! User configuration will be ignored!
|
||||
''
|
||||
null;
|
||||
|
||||
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;
|
||||
`nixosConfigurations` is for specific machines. If you want to expose
|
||||
reusable configurations, add them to [`nixosModules`](#opt-flake.nixosModules)
|
||||
in the form of modules (no `lib.nixosSystem`), so that you can reference
|
||||
them in this or another flake's `nixosConfigurations`.
|
||||
'';
|
||||
example = literalExpression ''
|
||||
{
|
||||
my-machine = inputs.nixpkgs.lib.nixosSystem {
|
||||
# system is not needed with freshly generated hardware-configuration.nix
|
||||
# system = "x86_64-linux"; # or set nixpkgs.hostPlatform in a module.
|
||||
modules = [
|
||||
./my-machine/nixos-configuration.nix
|
||||
config.nixosModules.my-module
|
||||
];
|
||||
};
|
||||
};
|
||||
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