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`.
|
# `lib.flake-utils-plus.mkApp`.
|
||||||
# Usage: mkLib { inherit inputs; src = ./.; }
|
# Usage: mkLib { inherit inputs; src = ./.; }
|
||||||
# result: lib
|
# 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`.
|
# A convenience wrapper to create the library and then call `lib.mkFlake`.
|
||||||
# Usage: mkFlake { inherit inputs; src = ./.; ... }
|
# Usage: mkFlake { inherit inputs; src = ./.; ... }
|
||||||
|
|
@ -50,5 +50,30 @@
|
||||||
homeModules = {
|
homeModules = {
|
||||||
user = ./modules/home/user/default.nix;
|
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
|
let
|
||||||
inherit (lib) types mkOption mkDefault foldl optionalAttrs optional;
|
inherit (lib) types mkOption mkDefault foldl optionalAttrs optional;
|
||||||
|
|
||||||
cfg = config.snowfallorg;
|
cfg = config.snowfallorg;
|
||||||
|
|
||||||
|
inputs = args.inputs or { };
|
||||||
|
|
||||||
user-names = builtins.attrNames cfg.user;
|
user-names = builtins.attrNames cfg.user;
|
||||||
|
|
||||||
create-system-users = system-users: name:
|
create-system-users = system-users: name:
|
||||||
|
|
@ -58,16 +60,19 @@ in
|
||||||
config = mkOption {
|
config = mkOption {
|
||||||
# HM-compatible options taken from:
|
# HM-compatible options taken from:
|
||||||
# https://github.com/nix-community/home-manager/blob/0ee5ab611dc1fbb5180bd7d88d2aeb7841a4d179/nixos/common.nix#L14
|
# 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 {
|
type = types.submoduleWith {
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
osConfig = config;
|
osConfig = config;
|
||||||
modulesPath = "${inputs.home-manager}/modules";
|
modulesPath = "${inputs.home-manager or "/"}/modules";
|
||||||
} // config.home-manager.extraSpecialArgs;
|
} // (config.home-manager.extraSpecialArgs or { });
|
||||||
modules = [
|
modules = [
|
||||||
({ lib, modulesPath, ... }: {
|
({ lib, modulesPath, ... }:
|
||||||
|
if inputs ? home-manager then {
|
||||||
imports = import "${modulesPath}/modules.nix" {
|
imports = import "${modulesPath}/modules.nix" {
|
||||||
inherit pkgs lib;
|
inherit pkgs lib;
|
||||||
useNixpkgsModule = !config.home-manager.useGlobalPkgs;
|
useNixpkgsModule = !(config.home-manager.useGlobalPkgs or false);
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
|
@ -79,8 +84,8 @@ in
|
||||||
|
|
||||||
nix.package = config.nix.package;
|
nix.package = config.nix.package;
|
||||||
};
|
};
|
||||||
})
|
} else { })
|
||||||
] ++ config.home-manager.sharedModules;
|
] ++ (config.home-manager.sharedModules or [ ]);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,13 @@ user-options:
|
||||||
let
|
let
|
||||||
raw-snowfall-config = user-options.snowfall or { };
|
raw-snowfall-config = user-options.snowfall or { };
|
||||||
snowfall-config = raw-snowfall-config // {
|
snowfall-config = raw-snowfall-config // {
|
||||||
|
src = user-options.src;
|
||||||
root = raw-snowfall-config.root or 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; };
|
user-inputs = user-options.inputs // { src = user-options.src; };
|
||||||
|
|
@ -53,7 +59,9 @@ let
|
||||||
core-inputs-libs = get-libs (without-self core-inputs);
|
core-inputs-libs = get-libs (without-self core-inputs);
|
||||||
user-inputs-libs = get-libs (without-self user-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 =
|
snowfall-lib-dirs =
|
||||||
let
|
let
|
||||||
files = builtins.readDir snowfall-lib-root;
|
files = builtins.readDir snowfall-lib-root;
|
||||||
|
|
@ -71,7 +71,7 @@ rec {
|
||||||
|
|
||||||
mkFlake = full-flake-options:
|
mkFlake = full-flake-options:
|
||||||
let
|
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;
|
custom-flake-options = flake.without-snowfall-options full-flake-options;
|
||||||
alias = full-flake-options.alias or { };
|
alias = full-flake-options.alias or { };
|
||||||
homes = snowfall-lib.home.create-homes (full-flake-options.homes or { });
|
homes = snowfall-lib.home.create-homes (full-flake-options.homes or { });
|
||||||
|
|
@ -149,6 +149,12 @@ rec {
|
||||||
};
|
};
|
||||||
|
|
||||||
outputsBuilder = outputs-builder;
|
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 =
|
flake-utils-plus-outputs =
|
||||||
|
|
@ -31,14 +31,21 @@ in
|
||||||
{
|
{
|
||||||
home = rec {
|
home = rec {
|
||||||
# Modules in home-manager expect `hm` to be available directly on `lib` itself.
|
# 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
|
# @NOTE(jakehamilton): This order is important, this library's extend and other utilities must write
|
||||||
# _over_ the original `system-lib`.
|
# _over_ the original `system-lib`.
|
||||||
snowfall-lib.internal.system-lib
|
snowfall-lib.internal.system-lib
|
||||||
// prev
|
// prev
|
||||||
// {
|
// {
|
||||||
hm = snowfall-lib.internal.system-lib.home-manager.hm;
|
hm = snowfall-lib.internal.system-lib.home-manager.hm;
|
||||||
});
|
})
|
||||||
|
else
|
||||||
|
{ };
|
||||||
|
|
||||||
# Get the user and host from a combined string.
|
# Get the user and host from a combined string.
|
||||||
# Type: String -> Attrs
|
# Type: String -> Attrs
|
||||||
|
|
@ -42,7 +42,7 @@ let
|
||||||
|
|
||||||
system-lib = snowfall-lib.attrs.merge-shallow [
|
system-lib = snowfall-lib.attrs.merge-shallow [
|
||||||
base-lib
|
base-lib
|
||||||
{ internal = user-lib; }
|
{ "${snowfall-config.namespace}" = user-lib; }
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
@ -40,7 +40,17 @@ in
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
name = builtins.unsafeDiscardStringContext (snowfall-lib.path.get-parent-directory package);
|
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;
|
packages-metadata = builtins.map create-package-metadata user-packages;
|
||||||
merge-packages = packages: metadata:
|
merge-packages = packages: metadata:
|
||||||
Loading…
Add table
Add a link
Reference in a new issue