diff --git a/darwin/system.nix b/darwin/system.nix index 2679908..f7955da 100644 --- a/darwin/system.nix +++ b/darwin/system.nix @@ -1,4 +1,4 @@ -{config, ...}: +{ config, ... }: # This section apply settings to the system configuration only available on macOS # see for more options { diff --git a/system/flake.nix b/system/flake.nix index c17aee9..8d7c5ae 100644 --- a/system/flake.nix +++ b/system/flake.nix @@ -6,16 +6,15 @@ outputs = inputs@{ nixpkgs, ... }: let - system = "x86_64-linux"; hostName = builtins.abort "You need to fill in your hostName"; # Set this variable equal to your hostName in { nixosConfigurations.${hostName} = nixpkgs.lib.nixosSystem { - inherit system; modules = [ ./configuration.nix + ./options.nix - { networking.hostName = hostName; } + { aux.hostname = hostName; } ]; specialArgs = { diff --git a/system/options.nix b/system/options.nix new file mode 100644 index 0000000..1952bef --- /dev/null +++ b/system/options.nix @@ -0,0 +1,25 @@ +{ config, lib, ... }: +let + inherit (lib.options) mkOption; + inherit (lib.types) str; +in +{ + # More options can be added here. + # Following the module system, any module option added in the `options.aux` attribute set + # will become available under `config.aux` within your configuration. Thus making it + # possible to reference arbitrary internal variables if they have been set here + options.aux = { + hostname = mkOption { + type = str; + default = builtins.throw "hostname is required"; + description = "The hostname for the machine"; + }; + }; + + config = { + # internally set `networking.hostName` to the value of `aux.hostname` + # similarly, you can set the values of nixpkgs module system options + # to the variable options defined under `options.aux` + networking.hostName = config.aux.hostname; + }; +}