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)
|
- [docs/cheatsheet.md](docs/cheatsheet.md)
|
||||||
- [README.md](README.md)
|
- [README.md](README.md)
|
||||||
## Structure
|
## Structure
|
||||||
The system configurations are defined in [`flake.manifest`](nix/manifest.nix).
|
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.
|
`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):
|
You can use it as seen [here](nix/modules/flake/home-manager.nix):
|
||||||
|
|
||||||
```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
|
parts."Structure" = # markdown
|
||||||
''
|
''
|
||||||
The system configurations are defined in [`flake.manifest`](nix/manifest.nix).
|
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.
|
`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):
|
You can use it as seen [here](nix/modules/flake/home-manager.nix):
|
||||||
|
|
||||||
```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
|
let
|
||||||
|
cfg = config.flake;
|
||||||
inherit (lib.trivial) pipe;
|
inherit (lib.trivial) pipe;
|
||||||
inherit (lib.strings) removePrefix hasPrefix;
|
inherit (lib.strings) removePrefix hasPrefix;
|
||||||
inherit (lib.attrsets)
|
inherit (lib.attrsets)
|
||||||
|
@ -42,7 +43,7 @@ in
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
modules = [
|
modules = [
|
||||||
config.flake.profiles.nixos.common
|
(flattenAttrs cfg.modules.nixos)
|
||||||
(mkProfileCfg (value.profiles or [ ]))
|
(mkProfileCfg (value.profiles or [ ]))
|
||||||
(value.extraCfg or { })
|
(value.extraCfg or { })
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
let
|
let
|
||||||
testCfg = {
|
testCfg =
|
||||||
fileSystems."/" = {
|
{ hostName, ... }:
|
||||||
device = "/dev/sda1";
|
{
|
||||||
fsType = "ext4";
|
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
|
in
|
||||||
{
|
{
|
||||||
flake.manifest = {
|
flake.manifest = {
|
||||||
|
@ -16,7 +21,6 @@ in
|
||||||
pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILdsZyY3gu8IGB8MzMnLdh+ClDxQQ2RYG9rkeetIKq8n rafiq";
|
pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILdsZyY3gu8IGB8MzMnLdh+ClDxQQ2RYG9rkeetIKq8n rafiq";
|
||||||
};
|
};
|
||||||
hosts = {
|
hosts = {
|
||||||
"nixos/test".extraCfg = testCfg;
|
|
||||||
"nixos/nemesis" = {
|
"nixos/nemesis" = {
|
||||||
machine = {
|
machine = {
|
||||||
platform = "amd";
|
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;
|
extraCfg = testCfg;
|
||||||
};
|
};
|
||||||
"nixos/apollo" = {
|
"nixos/apollo" = {
|
||||||
|
@ -47,12 +42,6 @@ in
|
||||||
platform = "intel";
|
platform = "intel";
|
||||||
root.drive = "/dev/disk/by-id/nvme-eui.002538d221b47b01";
|
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;
|
extraCfg = testCfg;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,5 +9,5 @@ let
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [ hm.flakeModules.home-manager ];
|
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