feat: proxy nixos modules, remove deprecated overlay attribute

This commit is contained in:
Jake Hamilton 2023-02-21 17:41:34 -08:00
parent af06876391
commit b428b981b9
No known key found for this signature in database
GPG key ID: 9762169A1B35EA68
4 changed files with 45 additions and 9 deletions

8
flake.lock generated
View file

@ -51,16 +51,16 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1665216225, "lastModified": 1677028070,
"narHash": "sha256-SUuvJXGEXhmyaGJlDlptbc9I2Wai9tUx83QYIqvipfE=", "narHash": "sha256-sUKqd8HYBrtPxCRXFWvsnQDnwqnw1uIDwu4khcZuL2k=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "1a9935bf90e0f4225756f99e772f06d5fea9edb6", "rev": "d3a15cd8dc917f4364ba0b332a1c389dc3177603",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nixos", "owner": "nixos",
"ref": "release-22.05", "ref": "release-22.11",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }

View file

@ -2,7 +2,7 @@
description = "Snowfall Lib"; description = "Snowfall Lib";
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/release-22.05"; nixpkgs.url = "github:nixos/nixpkgs/release-22.11";
flake-utils-plus.url = "github:gytis-ivaskevicius/flake-utils-plus"; flake-utils-plus.url = "github:gytis-ivaskevicius/flake-utils-plus";
flake-compat = { flake-compat = {

View file

@ -138,7 +138,6 @@ rec {
flake-outputs = flake-outputs =
flake-utils-plus-outputs // { flake-utils-plus-outputs // {
inherit overlays; inherit overlays;
overlay = overlays.default;
}; };
in in
flake-outputs; flake-outputs;

View file

@ -5,7 +5,7 @@
let let
inherit (builtins) baseNameOf; 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"; user-modules-root = snowfall-lib.fs.get-snowfall-file "modules";
in in
@ -23,13 +23,50 @@ in
let let
user-modules = snowfall-lib.fs.get-default-nix-files-recursive src; user-modules = snowfall-lib.fs.get-default-nix-files-recursive src;
create-module-metadata = module: { 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; path = module;
}; };
modules-metadata = builtins.map create-module-metadata user-modules; modules-metadata = builtins.map create-module-metadata user-modules;
merge-modules = modules: metadata: merge-modules = modules: metadata:
modules // { 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; modules-without-aliases = foldl merge-modules { } modules-metadata;
aliased-modules = mapAttrs (name: value: modules-without-aliases.${value}) alias; aliased-modules = mapAttrs (name: value: modules-without-aliases.${value}) alias;