From b2da82bff18edf73729867bf5aa9257c71ae4df2 Mon Sep 17 00:00:00 2001 From: derped Date: Mon, 28 Aug 2023 21:52:46 +0200 Subject: [PATCH] Move fn functions to system specialArgs. --- flake.nix | 2 +- options/machine.nix | 3 +-- pkgs/systemPackages.nix | 3 +-- pkgsets/emacs.nix | 3 +-- pkgsets/haskell.nix | 6 ++---- pkgsets/php.nix | 6 ++---- pkgsets/python3.nix | 7 ++----- services/acme.nix | 3 +-- services/bind.nix | 3 +-- 9 files changed, 12 insertions(+), 24 deletions(-) diff --git a/flake.nix b/flake.nix index 909392f..6547326 100644 --- a/flake.nix +++ b/flake.nix @@ -26,7 +26,7 @@ machineFiles = lib.filter (name: lib.strings.hasSuffix ".nix" name) (fn.lst { p = machinePath; b = true; }); in nixpkgs.lib.nixosSystem { inherit system; - specialArgs = attrs; + specialArgs = attrs // { fn = fn; }; modules = [ (toString ./options/machine.nix) sops-nix.nixosModules.sops diff --git a/options/machine.nix b/options/machine.nix index c49d20b..1362671 100644 --- a/options/machine.nix +++ b/options/machine.nix @@ -1,11 +1,10 @@ -{ config, lib, ... }: +{ config, lib, fn, ... }: with builtins; with lib; let cfg = config.machine; - fn = import (toString ../fn.nix) { inherit lib; }; metapkgs = let pPath = (toString ../pkgsets); in (lists.forEach (fn.lsfRec pPath true) (v: replaceStrings [ "${pPath}/" "/" ".nix" ] [ "" "::" "" ] v)); diff --git a/pkgs/systemPackages.nix b/pkgs/systemPackages.nix index f50ba3e..56843df 100644 --- a/pkgs/systemPackages.nix +++ b/pkgs/systemPackages.nix @@ -1,10 +1,9 @@ -{ config, lib, pkgs, ... }: +{ config, lib, fn, pkgs, ... }: with lib; let cfg = config.machine; - fn = import (toString ../fn.nix) { inherit lib; }; pkgsets = fn.lst { p = (toString ../pkgsets); b = true;}; in { imports = pkgsets; diff --git a/pkgsets/emacs.nix b/pkgsets/emacs.nix index 74024f1..4623150 100644 --- a/pkgsets/emacs.nix +++ b/pkgsets/emacs.nix @@ -1,9 +1,8 @@ -{ config, lib, pkgs, ... }: +{ config, lib, fn, pkgs, ... }: with lib; let - fn = import (toString ../fn.nix) { inherit lib; }; modefiles = fn.lst { p = (toString ./emacs); b = true; }; in rec { imports = [ diff --git a/pkgsets/haskell.nix b/pkgsets/haskell.nix index 46d2174..bf8b684 100644 --- a/pkgsets/haskell.nix +++ b/pkgsets/haskell.nix @@ -1,8 +1,6 @@ -{ config, lib, pkgs, ... }: +{ config, lib, fn, pkgs, ... }: -let - fn = import ../fn.nix { inherit lib; }; -in { +{ config.machine.pkgsets.haskell.pkgwrap = (pkgs.haskellPackages.ghcWithPackages (pkgs: (fn.pkgFilter config.machine.pkgsets.haskell.pkgs))); config.machine.pkgsets.haskell.pkgs = with pkgs.haskellPackages; [ hindent diff --git a/pkgsets/php.nix b/pkgsets/php.nix index 06f12c5..e04e462 100644 --- a/pkgsets/php.nix +++ b/pkgsets/php.nix @@ -1,8 +1,6 @@ -{ config, lib, pkgs, ... }: +{ config, lib, fn, pkgs, ... }: -let - fn = import ../fn.nix { inherit lib; }; -in { +{ config.machine.pkgsets.php.pkgwrap = (fn.pkgFilter config.machine.pkgsets.php.pkgs); config.machine.pkgsets.php.pkgs = (with pkgs.php82Packages; [ composer diff --git a/pkgsets/python3.nix b/pkgsets/python3.nix index 975eda0..8fb3776 100644 --- a/pkgsets/python3.nix +++ b/pkgsets/python3.nix @@ -1,11 +1,8 @@ -{ config, lib, pkgs, ... }: +{ config, lib, fn, pkgs, ... }: with lib; -let - fn = import ../fn.nix { inherit lib; }; - # ocv3 = pkgs.python38Packages.opencv3.override { enableGtk2 = true; enableFfmpeg = true; enableGStreamer = true; }; -in { +{ config.machine.pkgsets.python3.pkgwrap = (pkgs.python310.withPackages (ps: (fn.pkgFilter config.machine.pkgsets.python3.pkgs))); config.machine.pkgsets.python3.pkgs = with pkgs.python310Packages; [ GitPython diff --git a/services/acme.nix b/services/acme.nix index 6fd29f6..d7016d8 100644 --- a/services/acme.nix +++ b/services/acme.nix @@ -1,10 +1,9 @@ -{ options, config, lib, pkgs, ... }: +{ options, config, lib, fn, pkgs, ... }: with builtins; with lib; let - fn = import (../. + (toPath "/fn.nix")) { inherit lib; }; cfg = config.machine; in mkIf (elem "acme" cfg.services) { security.acme = { diff --git a/services/bind.nix b/services/bind.nix index 885e80d..2408620 100644 --- a/services/bind.nix +++ b/services/bind.nix @@ -1,11 +1,10 @@ # This Configuration is meant for local DNS setups only! -{ options, config, lib, pkgs, ... }: +{ options, config, lib, fn, pkgs, ... }: with builtins; with lib; let - fn = import (../. + (toPath "/fn.nix")) { inherit lib; }; cfg = config.machine; in mkIf (elem "bind" cfg.services) { services.bind = {