refactor(configurations): add default nixos module
This commit is contained in:
parent
aef828b713
commit
95fea9184e
7 changed files with 36 additions and 46 deletions
14
README.md
14
README.md
|
@ -7,10 +7,18 @@ The list of generated files are:
|
|||
- [docs/cheatsheet.md](docs/cheatsheet.md)
|
||||
- [README.md](README.md)
|
||||
## Structure
|
||||
The system configurations are defined in [`flake.manifest`](nix/manifest.nix).
|
||||
The attribute `flake.modules.nixos.common` provides options that will be applied to every system.
|
||||
The system configurations are defined in [`flake.manifest`](nix/manifest.nix).
|
||||
`flake.manifest.owner` provides the attributes for the administrator user, including username and pubkey.
|
||||
`flake.manifest.hosts` provides the specifications for the system configurations that should be exposed by the flake as nixosConfigurations.
|
||||
`flake.modules.nixos.*` provide NixOS options and configurations.
|
||||
The attribute `flake.modules.nixos.default` provides options that will be applied to every system of that class.
|
||||
You can use it as seen [here](nix/modules/flake/home-manager.nix):
|
||||
|
||||
```nix
|
||||
flake.modules.nixos.common.imports = [ inputs.home-manager.nixosModules.default ];
|
||||
flake.modules.nixos.default.imports = [ inputs.home-manager.nixosModules.default ];
|
||||
```
|
||||
|
||||
The other attributes under `flake.modules.nixos` should be opt-in, i.e. provide options that will be set in the profiles.
|
||||
`flake.profiles.nixos` provides profiles which use the options defined in `flake.modules.nixos` to define different roles for each system, such as graphical, laptop, headless, etc.
|
||||
Options should not be defined here.
|
||||
`flake.contracts.nixos.*` will provide contracts, such as reverse proxies or databases, which will configure options on the provider and receiver host.
|
||||
|
|
|
@ -8,13 +8,21 @@
|
|||
'';
|
||||
parts."Structure" = # markdown
|
||||
''
|
||||
The system configurations are defined in [`flake.manifest`](nix/manifest.nix).
|
||||
The attribute `flake.modules.nixos.common` provides options that will be applied to every system.
|
||||
The system configurations are defined in [`flake.manifest`](nix/manifest.nix).
|
||||
`flake.manifest.owner` provides the attributes for the administrator user, including username and pubkey.
|
||||
`flake.manifest.hosts` provides the specifications for the system configurations that should be exposed by the flake as nixosConfigurations.
|
||||
`flake.modules.nixos.*` provide NixOS options and configurations.
|
||||
The attribute `flake.modules.nixos.default` provides options that will be applied to every system of that class.
|
||||
You can use it as seen [here](nix/modules/flake/home-manager.nix):
|
||||
|
||||
```nix
|
||||
flake.modules.nixos.common.imports = [ inputs.home-manager.nixosModules.default ];
|
||||
flake.modules.nixos.default.imports = [ inputs.home-manager.nixosModules.default ];
|
||||
```
|
||||
|
||||
The other attributes under `flake.modules.nixos` should be opt-in, i.e. provide options that will be set in the profiles.
|
||||
`flake.profiles.nixos` provides profiles which use the options defined in `flake.modules.nixos` to define different roles for each system, such as graphical, laptop, headless, etc.
|
||||
Options should not be defined here.
|
||||
`flake.contracts.nixos.*` will provide contracts, such as reverse proxies or databases, which will configure options on the provider and receiver host.
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.flake;
|
||||
inherit (lib.trivial) pipe;
|
||||
inherit (lib.strings) removePrefix hasPrefix;
|
||||
inherit (lib.attrsets)
|
||||
|
@ -42,7 +43,7 @@ in
|
|||
;
|
||||
};
|
||||
modules = [
|
||||
config.flake.profiles.nixos.common
|
||||
(flattenAttrs cfg.modules.nixos)
|
||||
(mkProfileCfg (value.profiles or [ ]))
|
||||
(value.extraCfg or { })
|
||||
];
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
let
|
||||
testCfg = {
|
||||
fileSystems."/" = {
|
||||
device = "/dev/sda1";
|
||||
fsType = "ext4";
|
||||
testCfg =
|
||||
{ hostName, ... }:
|
||||
{
|
||||
fileSystems."/" = {
|
||||
device = "/dev/sda1";
|
||||
fsType = "ext4";
|
||||
};
|
||||
nixpkgs.hostPlatform = "x86_64-linux";
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
system.stateVersion = "25.05";
|
||||
networking = { inherit hostName; };
|
||||
};
|
||||
nixpkgs.hostPlatform = "x86_64-linux";
|
||||
};
|
||||
in
|
||||
{
|
||||
flake.manifest = {
|
||||
|
@ -16,7 +21,6 @@ in
|
|||
pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILdsZyY3gu8IGB8MzMnLdh+ClDxQQ2RYG9rkeetIKq8n rafiq";
|
||||
};
|
||||
hosts = {
|
||||
"nixos/test".extraCfg = testCfg;
|
||||
"nixos/nemesis" = {
|
||||
machine = {
|
||||
platform = "amd";
|
||||
|
@ -31,15 +35,6 @@ in
|
|||
}
|
||||
];
|
||||
};
|
||||
# profiles = with config.flake.profiles.nixos; [
|
||||
# graphical
|
||||
# development
|
||||
# ];
|
||||
# extraModules = with config.flakes.modules.nixos; [
|
||||
# sunshine
|
||||
# sd-webui-forge
|
||||
# comfy-ui
|
||||
# ];
|
||||
extraCfg = testCfg;
|
||||
};
|
||||
"nixos/apollo" = {
|
||||
|
@ -47,12 +42,6 @@ in
|
|||
platform = "intel";
|
||||
root.drive = "/dev/disk/by-id/nvme-eui.002538d221b47b01";
|
||||
};
|
||||
# profiles = with config.flake.profiles.nixos; [ headless ];
|
||||
# extraModules = with config.flakes.modules.nixos; [
|
||||
# librechat
|
||||
# forgejo
|
||||
# rrv-sh
|
||||
# ];
|
||||
extraCfg = testCfg;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -9,5 +9,5 @@ let
|
|||
in
|
||||
{
|
||||
imports = [ hm.flakeModules.home-manager ];
|
||||
flake.modules.nixos.common = globalCfg;
|
||||
flake.modules.nixos.default = globalCfg;
|
||||
}
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
flake.modules.nixos.networking =
|
||||
{ hostName, ... }:
|
||||
{
|
||||
networking = { inherit hostName; };
|
||||
};
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
flake.profiles.nixos.common =
|
||||
{ hostName, ... }:
|
||||
{
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
system.stateVersion = "25.05";
|
||||
networking = { inherit hostName; };
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue