diff --git a/config/AutoUpdateSigned.nix b/config/AutoUpdateSigned.nix index cfa7d0e..835cc26 100644 --- a/config/AutoUpdateSigned.nix +++ b/config/AutoUpdateSigned.nix @@ -4,7 +4,6 @@ # to prevent unathorized changes to hosts. { config, - const, lib, pkgs, secret, @@ -40,7 +39,7 @@ in script = '' pushd /tmp rm -rf ./nixos - git clone --depth=1 --single-branch --branch=main ${const.url} ./nixos + git clone --depth=1 --single-branch --branch=main ${config.const.url} ./nixos pushd ./nixos git verify-commit HEAD && git fsck || { echo "Verification failed." diff --git a/flake.nix b/flake.nix index 2442cbf..6a72eeb 100644 --- a/flake.nix +++ b/flake.nix @@ -122,13 +122,6 @@ let lib = nixpkgs.lib; - const = { - droidStateVersion = "24.05"; - stateVersion = "24.11"; - timeZone = "Europe/Moscow"; - url = "https://git.voronind.com/voronind/nix.git"; - }; - __findFile = _: p: ./${p}; ls = @@ -175,9 +168,6 @@ # Make a device hostname match the one from this config. { networking.hostName = hostname; } - # Specify current release version. - { system.stateVersion = const.stateVersion; } - # Add Home Manager module. home-manager.nixosModules.home-manager @@ -203,7 +193,6 @@ { inherit __findFile - const inputs pkgsJobber pkgsMaster @@ -258,7 +247,6 @@ extraSpecialArgs = { inherit __findFile - const inputs pkgsMaster pkgsUnstable diff --git a/home/Android.nix b/home/Android.nix index 5bb0b53..58c52e8 100644 --- a/home/Android.nix +++ b/home/Android.nix @@ -2,7 +2,6 @@ { __findFile, config, - const, inputs, lib, pkgs, @@ -28,8 +27,8 @@ in config = lib.mkIf cfg.enable { environment.packages = package.core; nix.extraOptions = "experimental-features = nix-command flakes pipe-operators"; - system.stateVersion = const.droidStateVersion; - time.timeZone = const.timeZone; + system.stateVersion = config.const.droidStateVersion; + time.timeZone = config.const.timeZone; terminal = { inherit (android) font colors; }; home-manager.config = stylix // { programs = with programs; core; @@ -37,7 +36,7 @@ in home = { inherit (env) sessionVariables; inherit file; - stateVersion = const.droidStateVersion; + stateVersion = config.const.droidStateVersion; }; }; }; diff --git a/home/NixOs.nix b/home/NixOs.nix index 1bfbf39..5e8ae89 100644 --- a/home/NixOs.nix +++ b/home/NixOs.nix @@ -2,7 +2,6 @@ { __findFile, config, - const, lib, pkgs, util, @@ -36,7 +35,7 @@ in // { ${user.username} = { home = { - inherit (const) stateVersion; + inherit (config.const) stateVersion; inherit (env) sessionVariables; inherit (user) username homeDirectory; inherit file; diff --git a/host/x86_64-linux/home/Const.nix b/host/x86_64-linux/home/Const.nix new file mode 100644 index 0000000..3281c6a --- /dev/null +++ b/host/x86_64-linux/home/Const.nix @@ -0,0 +1,7 @@ +{ ... }: { + config.const.host = { + domain = "voronind.com"; + sslCertificate = "/etc/letsencrypt/live/voronind.com/fullchain.pem"; + sslCertificateKey = "/etc/letsencrypt/live/voronind.com/privkey.pem"; + }; +} diff --git a/host/x86_64-linux/home/Davis.nix b/host/x86_64-linux/home/Davis.nix index 2914321..5d0b967 100644 --- a/host/x86_64-linux/home/Davis.nix +++ b/host/x86_64-linux/home/Davis.nix @@ -8,10 +8,7 @@ in adminPasswordFile = "${storage}/Password"; appSecretFile = "${storage}/Secret"; hostname = "dav.voronind.com"; - nginx = { - sslCertificate = "/etc/letsencrypt/live/voronind.com/fullchain.pem"; - sslCertificateKey = "/etc/letsencrypt/live/voronind.com/privkey.pem"; - }; + nginx = { }; mail = { dsnFile = "${storage}/Dsn"; inviteFromAddress = "noreply@voronind.com"; diff --git a/host/x86_64-linux/home/Jobber.nix b/host/x86_64-linux/home/Jobber.nix index 695b79b..465725a 100644 --- a/host/x86_64-linux/home/Jobber.nix +++ b/host/x86_64-linux/home/Jobber.nix @@ -1,7 +1,6 @@ # Use `nixos-container login jobber` as root and empty pw. { __findFile, - const, lib, pkgsJobber, poetry2nixJobber, @@ -48,7 +47,7 @@ in in { boot.isContainer = true; - system.stateVersion = const.stateVersion; + system.stateVersion = "24.11"; users = { users.root.password = ""; mutableUsers = false; diff --git a/host/x86_64-linux/home/Network.nix b/host/x86_64-linux/home/Network.nix index 91dba4b..ab2132c 100644 --- a/host/x86_64-linux/home/Network.nix +++ b/host/x86_64-linux/home/Network.nix @@ -3,7 +3,6 @@ # fd09:8d46:b26::/48 - ULA. { config, - const, lib, util, ... @@ -120,7 +119,7 @@ in PoolOffset = 100; PoolSize = 150; ServerAddress = "${internal}/24"; - Timezone = const.timeZone; + Timezone = config.const.timeZone; UplinkInterface = wan; }; }; diff --git a/host/x86_64-linux/home/nginx/Davis.nix b/host/x86_64-linux/home/nginx/Davis.nix index c18d785..a32a617 100644 --- a/host/x86_64-linux/home/nginx/Davis.nix +++ b/host/x86_64-linux/home/nginx/Davis.nix @@ -1,15 +1,14 @@ -{ lib, ... }: +{ config, ... }: { - "dav.voronind.com" = { - sslCertificate = "/etc/letsencrypt/live/voronind.com/fullchain.pem"; - sslCertificateKey = "/etc/letsencrypt/live/voronind.com/privkey.pem"; - onlySSL = lib.mkForce true; + "dav.${config.const.host.domain}" = { + inherit (config.const.host) sslCertificate sslCertificateKey; locations."/".extraConfig = '' allow 10.0.0.0/8; allow fd09:8d46:b26::/48; deny all; ''; extraConfig = '' + listen 443 ssl; include /etc/letsencrypt/conf/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem; ''; diff --git a/host/x86_64-linux/home/nginx/Deluge.nix b/host/x86_64-linux/home/nginx/Deluge.nix index 4978671..ad5c154 100644 --- a/host/x86_64-linux/home/nginx/Deluge.nix +++ b/host/x86_64-linux/home/nginx/Deluge.nix @@ -1,6 +1,6 @@ -{ ... }: +{ config, ... }: { - "download.voronind.com".extraConfig = '' + "download.${config.const.host.domain}".extraConfig = '' listen 443 ssl; location / { diff --git a/option/Const.nix b/option/Const.nix new file mode 100644 index 0000000..78e94f1 --- /dev/null +++ b/option/Const.nix @@ -0,0 +1,26 @@ +{ lib, ... }: +{ + options.const = { + droidStateVersion = lib.mkOption { + default = "24.05"; + type = lib.types.str; + }; + stateVersion = lib.mkOption { + default = "24.11"; + type = lib.types.str; + }; + timeZone = lib.mkOption { + default = "Europe/Moscow"; + type = lib.types.str; + }; + url = lib.mkOption { + default = "https://git.voronind.com/voronind/nix.git"; + type = lib.types.str; + }; + host = lib.mkOption { + default = { }; + type = lib.types.attrs; + }; + }; +} + diff --git a/system/Locale.nix b/system/Locale.nix index 483949d..259afad 100644 --- a/system/Locale.nix +++ b/system/Locale.nix @@ -1,6 +1,6 @@ -{ const, ... }: +{ config, ... }: { - time.timeZone = const.timeZone; + time.timeZone = config.const.timeZone; i18n = { defaultLocale = "en_US.UTF-8"; extraLocaleSettings = { diff --git a/system/State.nix b/system/State.nix new file mode 100644 index 0000000..cb47642 --- /dev/null +++ b/system/State.nix @@ -0,0 +1,5 @@ +{ config, ... }: { + # Specify current release version. + system.stateVersion = config.const.stateVersion; +} +