mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 16:21:34 +01:00
wifi: derive networks from sops secrets file
This commit is contained in:
parent
2e3b64860f
commit
2da2cd592e
2 changed files with 27 additions and 14 deletions
|
|
@ -5,15 +5,28 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
let
|
||||||
|
cfg = config.custom.sops;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [ inputs.sops-nix.nixosModules.sops ];
|
imports = [ inputs.sops-nix.nixosModules.sops ];
|
||||||
|
|
||||||
options.custom.sops.enable = lib.mkEnableOption "";
|
options.custom.sops = {
|
||||||
|
enable = lib.mkEnableOption "";
|
||||||
|
defaultSopsFile = lib.mkOption {
|
||||||
|
type = lib.types.path;
|
||||||
|
default = "${self}/hosts/${config.networking.hostName}/secrets.json";
|
||||||
|
};
|
||||||
|
secrets = lib.mkOption {
|
||||||
|
type = lib.types.anything;
|
||||||
|
default = cfg.defaultSopsFile |> builtins.readFile |> builtins.fromJSON;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
config = lib.mkIf config.custom.sops.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
sops = {
|
sops = {
|
||||||
age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
|
age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
|
||||||
defaultSopsFile = "${self}/hosts/${config.networking.hostName}/secrets.json";
|
inherit (cfg) defaultSopsFile;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,18 +5,18 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
networks = [
|
cfg = config.custom.wifi;
|
||||||
"EW90N.psk"
|
|
||||||
"Fairphone4.psk"
|
|
||||||
"WLAN-233151.psk"
|
|
||||||
"DSL_EXT.psk"
|
|
||||||
"eduroam.8021x"
|
|
||||||
];
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.custom.wifi.enable = lib.mkEnableOption "";
|
options.custom.wifi = {
|
||||||
|
enable = lib.mkEnableOption "";
|
||||||
|
networks = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = config.custom.sops.secrets.iwd |> lib.attrNames;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
config = lib.mkIf config.custom.wifi.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
networking.wireless.iwd = {
|
networking.wireless.iwd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
settings = {
|
||||||
|
|
@ -28,7 +28,7 @@ in
|
||||||
environment.systemPackages = [ pkgs.iwgtk ];
|
environment.systemPackages = [ pkgs.iwgtk ];
|
||||||
|
|
||||||
sops.secrets =
|
sops.secrets =
|
||||||
networks
|
cfg.networks
|
||||||
|> lib.map (name: {
|
|> lib.map (name: {
|
||||||
name = "iwd/${name}";
|
name = "iwd/${name}";
|
||||||
value = { };
|
value = { };
|
||||||
|
|
@ -36,7 +36,7 @@ in
|
||||||
|> lib.listToAttrs;
|
|> lib.listToAttrs;
|
||||||
|
|
||||||
systemd.tmpfiles.rules =
|
systemd.tmpfiles.rules =
|
||||||
networks
|
cfg.networks
|
||||||
|> lib.map (name: "C /var/lib/iwd/${name} - - - - ${config.sops.secrets."iwd/${name}".path}");
|
|> lib.map (name: "C /var/lib/iwd/${name} - - - - ${config.sops.secrets."iwd/${name}".path}");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue