From df7061f558858acc0a77f72b6534f147ac87706b Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 3 Oct 2024 16:11:24 -0700 Subject: flake: move kansai-pkgs and overlays to lib --- flake.nix | 33 +++------------------------------ lib/kansai-pkgs.nix | 25 +++++++++++++++++++++++++ lib/overlays.nix | 10 ++++++++++ 3 files changed, 38 insertions(+), 30 deletions(-) create mode 100644 lib/kansai-pkgs.nix create mode 100644 lib/overlays.nix diff --git a/flake.nix b/flake.nix index b64e245..b619540 100644 --- a/flake.nix +++ b/flake.nix @@ -15,36 +15,9 @@ secrets = builtins.fromTOML (builtins.readFile "${self}/secrets/secrets.toml"); systemsAttributes = lib.genAttrs (import systems); - kansaiPkgs = - { - nixpkgsAllowUnfree ? false, - nixpkgsCudaSupport ? false, - nixpkgsAllowUnfreePredicate ? [ ], - nixpkgsExtraConfig ? { }, - }: - (systemsAttributes ( - system: - import inputs.nixpkgs { - inherit system; - - config = { - allowUnfree = nixpkgsAllowUnfree; - cudaSupport = nixpkgsCudaSupport; - allowUnfreePredicate = nixpkgsAllowUnfreePredicate; - } // nixpkgsExtraConfig; - - overlays = - let - path = "${self}/overlays"; - in - with builtins; - map (n: import (path + ("/" + n))) ( - filter (n: match ".*\\.nix" n != null || pathExists (path + ("/" + n + "/default.nix"))) ( - attrNames (readDir path) - ) - ); - } - )); + kansaiPkgs = import "${self}/lib/kansai-pkgs.nix" { + inherit systemsAttributes nixpkgs self; + }; in flake-parts.lib.mkFlake { inherit inputs; } { systems = builtins.attrNames (systemsAttributes (system: system)); diff --git a/lib/kansai-pkgs.nix b/lib/kansai-pkgs.nix new file mode 100644 index 0000000..dd189b8 --- /dev/null +++ b/lib/kansai-pkgs.nix @@ -0,0 +1,25 @@ +{ + systemsAttributes, + nixpkgs, + self, +}: +{ + nixpkgsAllowUnfree ? false, + nixpkgsCudaSupport ? false, + nixpkgsAllowUnfreePredicate ? [ ], + nixpkgsExtraConfig ? { }, +}: +(systemsAttributes ( + system: + import nixpkgs { + inherit system; + + overlays = import "${self}/lib/overlays.nix" { inherit self; }; + + config = { + allowUnfree = nixpkgsAllowUnfree; + cudaSupport = nixpkgsCudaSupport; + allowUnfreePredicate = nixpkgsAllowUnfreePredicate; + } // nixpkgsExtraConfig; + } +)) diff --git a/lib/overlays.nix b/lib/overlays.nix new file mode 100644 index 0000000..add8fc4 --- /dev/null +++ b/lib/overlays.nix @@ -0,0 +1,10 @@ +{ self }: +let + path = "${self}/overlays"; +in +with builtins; +map (n: import (path + ("/" + n))) ( + filter (n: match ".*\\.nix" n != null || pathExists (path + ("/" + n + "/default.nix"))) ( + attrNames (readDir path) + ) +) -- cgit v1.2.3