wip: initial frost support
This commit is contained in:
parent
6b09a4b7b5
commit
116971f60d
18 changed files with 91 additions and 30 deletions
27
flake.nix
27
flake.nix
|
|
@ -22,7 +22,7 @@
|
|||
# `lib.flake-utils-plus.mkApp`.
|
||||
# Usage: mkLib { inherit inputs; src = ./.; }
|
||||
# result: lib
|
||||
mkLib = import ./lib core-inputs;
|
||||
mkLib = import ./snowfall-lib core-inputs;
|
||||
|
||||
# A convenience wrapper to create the library and then call `lib.mkFlake`.
|
||||
# Usage: mkFlake { inherit inputs; src = ./.; ... }
|
||||
|
|
@ -50,5 +50,30 @@
|
|||
homeModules = {
|
||||
user = ./modules/home/user/default.nix;
|
||||
};
|
||||
|
||||
_snowfall = rec {
|
||||
raw-config = config;
|
||||
|
||||
config = {
|
||||
root = ./.;
|
||||
src = ./.;
|
||||
namespace = "snowfall";
|
||||
lib-dir = "snowfall-lib";
|
||||
};
|
||||
|
||||
internal-lib =
|
||||
let
|
||||
lib = mkLib {
|
||||
src = ./.;
|
||||
|
||||
inputs = inputs // {
|
||||
self = { };
|
||||
};
|
||||
};
|
||||
in
|
||||
builtins.removeAttrs
|
||||
lib.snowfall
|
||||
[ "internal" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
{ pkgs, lib, options, config, inputs, ... }:
|
||||
args@{ pkgs, lib, options, config, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) types mkOption mkDefault foldl optionalAttrs optional;
|
||||
|
||||
cfg = config.snowfallorg;
|
||||
|
||||
inputs = args.inputs or { };
|
||||
|
||||
user-names = builtins.attrNames cfg.user;
|
||||
|
||||
create-system-users = system-users: name:
|
||||
|
|
@ -58,16 +60,19 @@ in
|
|||
config = mkOption {
|
||||
# HM-compatible options taken from:
|
||||
# https://github.com/nix-community/home-manager/blob/0ee5ab611dc1fbb5180bd7d88d2aeb7841a4d179/nixos/common.nix#L14
|
||||
# @NOTE(jakehamilton): This has been adapted to support documentation generation without
|
||||
# having home-manager options fully declared.
|
||||
type = types.submoduleWith {
|
||||
specialArgs = {
|
||||
osConfig = config;
|
||||
modulesPath = "${inputs.home-manager}/modules";
|
||||
} // config.home-manager.extraSpecialArgs;
|
||||
modulesPath = "${inputs.home-manager or "/"}/modules";
|
||||
} // (config.home-manager.extraSpecialArgs or { });
|
||||
modules = [
|
||||
({ lib, modulesPath, ... }: {
|
||||
({ lib, modulesPath, ... }:
|
||||
if inputs ? home-manager then {
|
||||
imports = import "${modulesPath}/modules.nix" {
|
||||
inherit pkgs lib;
|
||||
useNixpkgsModule = !config.home-manager.useGlobalPkgs;
|
||||
useNixpkgsModule = !(config.home-manager.useGlobalPkgs or false);
|
||||
};
|
||||
|
||||
config = {
|
||||
|
|
@ -79,8 +84,8 @@ in
|
|||
|
||||
nix.package = config.nix.package;
|
||||
};
|
||||
})
|
||||
] ++ config.home-manager.sharedModules;
|
||||
} else { })
|
||||
] ++ (config.home-manager.sharedModules or [ ]);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,7 +8,13 @@ user-options:
|
|||
let
|
||||
raw-snowfall-config = user-options.snowfall or { };
|
||||
snowfall-config = raw-snowfall-config // {
|
||||
src = user-options.src;
|
||||
root = raw-snowfall-config.root or user-options.src;
|
||||
namespace = raw-snowfall-config.namespace or "internal";
|
||||
meta = {
|
||||
name = raw-snowfall-config.meta.name or null;
|
||||
title = raw-snowfall-config.meta.title or null;
|
||||
};
|
||||
};
|
||||
|
||||
user-inputs = user-options.inputs // { src = user-options.src; };
|
||||
|
|
@ -53,7 +59,9 @@ let
|
|||
core-inputs-libs = get-libs (without-self core-inputs);
|
||||
user-inputs-libs = get-libs (without-self user-inputs);
|
||||
|
||||
snowfall-lib-root = "${core-inputs.src}/lib";
|
||||
# @NOTE(jakehamilton): This root is different to accomodate the creation
|
||||
# of a fake user-lib in order to run documentation on this flake.
|
||||
snowfall-lib-root = "${core-inputs.src}/snowfall-lib";
|
||||
snowfall-lib-dirs =
|
||||
let
|
||||
files = builtins.readDir snowfall-lib-root;
|
||||
|
|
@ -71,7 +71,7 @@ rec {
|
|||
|
||||
mkFlake = full-flake-options:
|
||||
let
|
||||
package-namespace = full-flake-options.package-namespace or "internal";
|
||||
package-namespace = full-flake-options.package-namespace or snowfall-config.namespace or "internal";
|
||||
custom-flake-options = flake.without-snowfall-options full-flake-options;
|
||||
alias = full-flake-options.alias or { };
|
||||
homes = snowfall-lib.home.create-homes (full-flake-options.homes or { });
|
||||
|
|
@ -149,6 +149,12 @@ rec {
|
|||
};
|
||||
|
||||
outputsBuilder = outputs-builder;
|
||||
|
||||
_snowfall = {
|
||||
config = snowfall-config;
|
||||
raw-config = full-flake-options.snowfall or { };
|
||||
user-lib = snowfall-lib.internal.user-lib;
|
||||
};
|
||||
};
|
||||
|
||||
flake-utils-plus-outputs =
|
||||
|
|
@ -31,14 +31,21 @@ in
|
|||
{
|
||||
home = rec {
|
||||
# Modules in home-manager expect `hm` to be available directly on `lib` itself.
|
||||
home-lib = snowfall-lib.internal.system-lib.extend (final: prev:
|
||||
home-lib =
|
||||
# @NOTE(jakehamilton): This prevents an error during evaluation if the input does
|
||||
# not exist.
|
||||
if user-inputs ? home-manager then
|
||||
snowfall-lib.internal.system-lib.extend
|
||||
(final: prev:
|
||||
# @NOTE(jakehamilton): This order is important, this library's extend and other utilities must write
|
||||
# _over_ the original `system-lib`.
|
||||
snowfall-lib.internal.system-lib
|
||||
// prev
|
||||
// {
|
||||
hm = snowfall-lib.internal.system-lib.home-manager.hm;
|
||||
});
|
||||
})
|
||||
else
|
||||
{ };
|
||||
|
||||
# Get the user and host from a combined string.
|
||||
# Type: String -> Attrs
|
||||
|
|
@ -42,7 +42,7 @@ let
|
|||
|
||||
system-lib = snowfall-lib.attrs.merge-shallow [
|
||||
base-lib
|
||||
{ internal = user-lib; }
|
||||
{ "${snowfall-config.namespace}" = user-lib; }
|
||||
];
|
||||
in
|
||||
{
|
||||
|
|
@ -40,7 +40,17 @@ in
|
|||
in
|
||||
{
|
||||
name = builtins.unsafeDiscardStringContext (snowfall-lib.path.get-parent-directory package);
|
||||
drv = callPackageWith extra-inputs package { };
|
||||
drv =
|
||||
let
|
||||
pkg = callPackageWith extra-inputs package { };
|
||||
in
|
||||
pkg // {
|
||||
meta = (pkg.meta or { }) // {
|
||||
snowfall = {
|
||||
path = package;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
packages-metadata = builtins.map create-package-metadata user-packages;
|
||||
merge-packages = packages: metadata:
|
||||
Loading…
Add table
Add a link
Reference in a new issue