diff --git a/doctrine/lib/default.nix b/doctrine/lib/default.nix index 116bbb8..1b03fe1 100644 --- a/doctrine/lib/default.nix +++ b/doctrine/lib/default.nix @@ -3,18 +3,8 @@ doctrine, pkgs, }: let - close = vars: f: args: - ( - if builtins.isPath f - then import f - else f - ) - (args // {inherit lib pkgs doctrine;}); - - closeLib = close {inherit lib;}; - closeFull = close {inherit lib pkgs doctrine;}; + close = f: args: f (args // {inherit lib pkgs doctrine;}); in { - inherit close; - importAll = closeLib ./import-all.nix; - mkModule = closeFull ./mk-module.nix; + importAll = pkgs.callPackage ./importAll.nix {}; + mkModule = close (import ./mk-module.nix); } diff --git a/doctrine/lib/import-all.nix b/doctrine/lib/importAll.nix similarity index 83% rename from doctrine/lib/import-all.nix rename to doctrine/lib/importAll.nix index 423dd9c..6acabe9 100644 --- a/doctrine/lib/import-all.nix +++ b/doctrine/lib/importAll.nix @@ -1,7 +1,6 @@ -{ - lib, +{lib}: { root, - exclude ? ["default"], + exclude ? [], }: with builtins; with lib; @@ -11,7 +10,7 @@ with lib; isMatch = name: type: (hasSuffix ".nix" name || type == "directory") - && ! elem (basename name) exclude; + && ! elem name (map basename exclude); entry = name: _: { name = basename name; diff --git a/doctrine/lib/mk-module.nix b/doctrine/lib/mk-module.nix index e72ca08..79c24c5 100644 --- a/doctrine/lib/mk-module.nix +++ b/doctrine/lib/mk-module.nix @@ -1,22 +1,18 @@ { - # The first few arguments are implicitly passed by the 'close' helper - lib, - pkgs, - doctrine, name, - config, hm ? null, sys ? null, options ? null, - requires ? [], - prefix ? doctrine.prefix, - namespace ? doctrine.namespace, + lib, + config, + pkgs, + doctrine, }: let optionsSet = import options { inherit config lib pkgs cfg name doctrine; }; - configSet = import configFiles.${namespace} { + configSet = import configFiles.${doctrine.namespace} { inherit config lib pkgs doctrine cfg; }; @@ -24,27 +20,17 @@ inherit sys hm; }; - cfg = config.${prefix}.${name}; + cfg = config.${doctrine.prefix}.${name}; in { config = - lib.optionalAttrs (configFiles ? ${namespace}) - (lib.mkIf cfg.enable (lib.mkMerge [ - configSet - { - assertions = - map (dependency: { - assertion = cfg.enable -> config.${prefix}.${dependency}.enable; - message = "${prefix}.${name}.enable requires ${prefix}.${dependency}.enable"; - }) - requires; - } - ])); + lib.optionalAttrs (configFiles ? ${doctrine.namespace}) + (lib.mkIf cfg.enable configSet); options = lib.optionalAttrs (options != null - && optionsSet ? ${namespace}) { - ${prefix}.${name} = - optionsSet.${namespace} + && optionsSet ? ${doctrine.namespace}) { + ${doctrine.prefix}.${name} = + optionsSet.${doctrine.namespace} // { enable = lib.mkEnableOption name; }; diff --git a/modules/default.nix b/modules/default.nix index 0c0fd4c..bd5d292 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,3 +1,5 @@ -{doctrine, ...}: { - imports = builtins.attrValues (doctrine.lib.importAll {root = ./.;}); +{ + imports = [ + ./sway + ]; } diff --git a/modules/laptop/default.nix b/modules/laptop/default.nix deleted file mode 100644 index b908d47..0000000 --- a/modules/laptop/default.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ - config, - doctrine, - ... -}: -doctrine.lib.mkModule { - inherit config; - name = "laptop"; - sys = ./sys.nix; -} diff --git a/modules/laptop/sys.nix b/modules/laptop/sys.nix deleted file mode 100644 index 252f49c..0000000 --- a/modules/laptop/sys.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: { - services = { - tlp.enable = lib.mkDefault true; - upower.enable = lib.mkDefault true; - }; -} diff --git a/modules/thinkpad/default.nix b/modules/thinkpad/default.nix deleted file mode 100644 index e210947..0000000 --- a/modules/thinkpad/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ - config, - doctrine, - ... -}: -doctrine.lib.mkModule { - inherit config; - name = "thinkpad"; - sys = ./sys.nix; - requires = ["laptop"]; -} diff --git a/modules/thinkpad/sys.nix b/modules/thinkpad/sys.nix deleted file mode 100644 index bc96146..0000000 --- a/modules/thinkpad/sys.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ - config, - pkgs, - lib, - ... -}: { - # For suspending to RAM to work, set Config -> Power -> Sleep State to "Linux" in EFI. - # See https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_6)#Suspend_issues - # Fingerprint sensor requires a firmware-update to work. - - boot = { - extraModulePackages = with config.boot.kernelPackages; [acpi_call]; - extraModprobeConfig = "options iwlwifi 11n_disable=1 wd_disable=1"; - - # acpi_call makes tlp work for newer thinkpads - kernelModules = ["acpi_call"]; - - # Force use of the thinkpad_acpi driver for backlight control. - # This allows the backlight save/load systemd service to work. - kernelParams = ["acpi_backlight=native"]; - }; - - hardware.firmware = [pkgs.sof-firmware]; - - services = { - fprintd.enable = lib.mkDefault true; - thinkfan.enable = lib.mkDefault true; - tp-auto-kbbl.enable = lib.mkDefault true; - }; -} diff --git a/modules/yubico/default.nix b/modules/yubico/default.nix deleted file mode 100644 index 71bed70..0000000 --- a/modules/yubico/default.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ - config, - lib, - pkgs, - doctrine, - ... -}: -doctrine.lib.mkModule { - inherit config; - name = "yubico"; - hm = ./hm.nix; - sys = ./sys.nix; -} diff --git a/modules/yubico/hm.nix b/modules/yubico/hm.nix deleted file mode 100644 index 8d06368..0000000 --- a/modules/yubico/hm.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ - pkgs, - lib, - ... -}: { - home.packages = [ - pkgs.yubikey-manager - ]; -} diff --git a/modules/yubico/sys.nix b/modules/yubico/sys.nix deleted file mode 100644 index 3cd009f..0000000 --- a/modules/yubico/sys.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ - pkgs, - lib, - ... -}: { - environment.etc."pkcs11/modules/ykcs11".text = '' - module: ${pkgs.yubico-piv-tool}/lib/libykcs11.so - ''; - - services = { - pcscd.enable = true; - udev.packages = [pkgs.yubikey-personalization]; - }; -}