feat: proxy nixos modules, remove deprecated overlay attribute
This commit is contained in:
parent
af06876391
commit
b428b981b9
4 changed files with 45 additions and 9 deletions
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
let
|
||||
inherit (builtins) baseNameOf;
|
||||
inherit (core-inputs.nixpkgs.lib) assertMsg foldl mapAttrs;
|
||||
inherit (core-inputs.nixpkgs.lib) assertMsg foldl mapAttrs hasPrefix;
|
||||
|
||||
user-modules-root = snowfall-lib.fs.get-snowfall-file "modules";
|
||||
in
|
||||
|
|
@ -23,13 +23,50 @@ in
|
|||
let
|
||||
user-modules = snowfall-lib.fs.get-default-nix-files-recursive src;
|
||||
create-module-metadata = module: {
|
||||
name = builtins.unsafeDiscardStringContext (snowfall-lib.path.get-parent-directory module);
|
||||
name =
|
||||
let
|
||||
path-name = builtins.replaceStrings [ src "/default.nix" ] [ "" "" ] (builtins.unsafeDiscardStringContext module);
|
||||
in
|
||||
if hasPrefix "/" path-name then
|
||||
builtins.substring 1 ((builtins.stringLength path-name) - 1) path-name
|
||||
else
|
||||
path-name;
|
||||
path = module;
|
||||
};
|
||||
modules-metadata = builtins.map create-module-metadata user-modules;
|
||||
merge-modules = modules: metadata:
|
||||
modules // {
|
||||
${metadata.name} = import metadata.path;
|
||||
${metadata.name} = args:
|
||||
let
|
||||
system = args.system or args.pkgs.system;
|
||||
target = args.target or system;
|
||||
|
||||
format =
|
||||
let
|
||||
virtual-system-type = snowfall-lib.system.get-virtual-system-type target;
|
||||
in
|
||||
if virtual-system-type != "" then
|
||||
virtual-system-type
|
||||
else if snowfall-lib.system.is-darwin target then
|
||||
"darwin"
|
||||
else
|
||||
"linux";
|
||||
|
||||
# Replicates the specialArgs from Snowfall Lib's system builder.
|
||||
modified-args = args // {
|
||||
inherit system target format;
|
||||
virtual = args.virtual or (snowfall-lib.system.get-virtual-system-type target != "");
|
||||
systems = args.systems or { };
|
||||
|
||||
|
||||
lib = snowfall-lib.internal.system-lib;
|
||||
pkgs = user-inputs.self.pkgs.${system}.nixpkgs;
|
||||
|
||||
inputs = snowfall-lib.flake.without-src user-inputs;
|
||||
};
|
||||
user-module = import metadata.path modified-args;
|
||||
in
|
||||
user-module // { _file = metadata.path; };
|
||||
};
|
||||
modules-without-aliases = foldl merge-modules { } modules-metadata;
|
||||
aliased-modules = mapAttrs (name: value: modules-without-aliases.${value}) alias;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue