From 20d330276d1618e5c58e53eda03d25e58e042b2b Mon Sep 17 00:00:00 2001
From: Ethel Morgan <eth@ethulhu.co.uk>
Date: Wed, 1 Jul 2020 19:43:25 +0100
Subject: add an abstraction over location

---
 nixos/modules/location.nix    | 24 ++++++++++++++++++++++++
 nixos/modules/module-list.nix |  1 +
 2 files changed, 25 insertions(+)
 create mode 100644 nixos/modules/location.nix

(limited to 'nixos/modules')

diff --git a/nixos/modules/location.nix b/nixos/modules/location.nix
new file mode 100644
index 0000000..a99aaa7
--- /dev/null
+++ b/nixos/modules/location.nix
@@ -0,0 +1,24 @@
+{ config, lib, pkgs, ... }:
+with lib;
+
+let
+  cfg = config.eth;
+
+  locations = {
+    London = {
+      latitude = 51.5074;
+      longitude = 0.1278;
+    };
+  };
+
+in {
+  options.eth.location = mkOption {
+    type = types.nullOr (types.enum (builtins.attrNames locations));
+    default = null;
+    description = "City name.";
+  };
+
+  config = mkIf (cfg.location != null) {
+    location = locations.${cfg.location};
+  };
+}
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index b0d788c..92b2cf6 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -2,6 +2,7 @@
   ./hardware/keyboard.nix
   ./hardware/linode.nix
   ./hardware/yubikey.nix
+  ./location.nix
   ./nix.nix
   ./programs/dwm.nix
   ./services/ambience.nix
-- 
cgit v1.2.3