mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-25 09:36:14 +01:00
Enable the extension of lib
Signed-off-by: Magic_RB <magic_rb@redalder.org>
This commit is contained in:
parent
734e9ab6a4
commit
3b5a09f9cb
21
flake.nix
21
flake.nix
|
@ -36,10 +36,12 @@
|
|||
udp-over-tcp.flake = false;
|
||||
};
|
||||
|
||||
outputs = inputs@{ flake-parts, self, ... }:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } ({ config, ... }: {
|
||||
outputs = inputs@{ flake-parts, self, secret, ... }:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } ({ config, lib', ... }: {
|
||||
imports = [
|
||||
modules/nixngConfigurations.nix
|
||||
modules/lib_overlays.nix
|
||||
lib/load_secrets.nix
|
||||
|
||||
nixos/systems/omen
|
||||
nixos/systems/heater
|
||||
|
@ -83,9 +85,19 @@
|
|||
inputs.uterranix.flakeModule
|
||||
];
|
||||
|
||||
_module.args.lib' =
|
||||
let
|
||||
inherit (inputs.nixpkgs) lib;
|
||||
inherit (inputs.nixpkgs.lib)
|
||||
extend;
|
||||
in
|
||||
lib.foldl (acc: x: acc.extend x) lib (with config.flake.libOverlays; [
|
||||
loadSecrets
|
||||
]);
|
||||
|
||||
flake.hydraJobs =
|
||||
let
|
||||
inherit (lib)
|
||||
inherit (lib')
|
||||
mapAttrs;
|
||||
in
|
||||
{
|
||||
|
@ -96,6 +108,7 @@
|
|||
uterranix.config = [
|
||||
./terranix/default.nix
|
||||
{
|
||||
_module.args.secret = secret;
|
||||
_module.args.vars = {
|
||||
flake_rev = self.rev or null;
|
||||
flake_sha = self.sha or null;
|
||||
|
@ -137,7 +150,7 @@
|
|||
{
|
||||
packages =
|
||||
let
|
||||
inherit (lib)
|
||||
inherit (lib')
|
||||
attrValues;
|
||||
pkgs' = pkgs.appendOverlays (attrValues config.flake.overlays);
|
||||
in
|
||||
|
|
14
lib/load_secrets.nix
Normal file
14
lib/load_secrets.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
# SPDX-FileCopyrightText: 2022 Richard Brežák <richard@brezak.sk>
|
||||
#
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
{ lib, ... }:
|
||||
{
|
||||
flake.libOverlays.loadSecrets =
|
||||
final: prev: (lib.traceVal {
|
||||
loadSecrets = path:
|
||||
if builtins.pathExists "${path}/default.nix" then
|
||||
import path { lib = final; }
|
||||
else
|
||||
{};
|
||||
});
|
||||
}
|
38
modules/lib_overlays.nix
Normal file
38
modules/lib_overlays.nix
Normal file
|
@ -0,0 +1,38 @@
|
|||
{ lib, flake-parts-lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
mkOption
|
||||
types
|
||||
;
|
||||
inherit (flake-parts-lib)
|
||||
mkSubmoduleOptions
|
||||
;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
flake = mkSubmoduleOptions {
|
||||
libOverlays = mkOption {
|
||||
# uniq -> ordered: https://github.com/NixOS/nixpkgs/issues/147052
|
||||
# also update description when done
|
||||
type = types.lazyAttrsOf (types.uniq (types.functionTo (types.functionTo (types.lazyAttrsOf types.unspecified))));
|
||||
# This eta expansion exists for the sole purpose of making nix flake check happy.
|
||||
apply = lib.mapAttrs (_k: f: final: prev: f final prev);
|
||||
default = { };
|
||||
example = lib.literalExpression or lib.literalExample ''
|
||||
{
|
||||
default = final: prev: {};
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
An attribute set of lib overlays, they're similar to normal
|
||||
[overlays](https://nixos.org/manual/nixpkgs/stable/#chap-overlays).
|
||||
|
||||
Note that the overlays themselves are not mergeable. While overlays
|
||||
can be composed, the order of composition is significant, but the
|
||||
module system does not guarantee sufficiently deterministic
|
||||
definition ordering, across versions and when changing `imports`.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
# SPDX-FileCopyrightText: 2022 Richard Brežák <richard@brezak.sk>
|
||||
#
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
{ inputs, lib, config, ... }:
|
||||
{ inputs, lib', config, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
inherit (lib')
|
||||
flip
|
||||
mapAttrs
|
||||
singleton;
|
||||
|
@ -17,11 +17,7 @@ in
|
|||
specialArgs = {
|
||||
config' = config';
|
||||
inputs' = inputs;
|
||||
secret =
|
||||
if builtins.pathExists "${inputs.secret}/default.nix" then
|
||||
import inputs.secret { inherit lib; }
|
||||
else
|
||||
{};
|
||||
secret = lib'.loadSecrets inputs.secret;
|
||||
};
|
||||
|
||||
modules = singleton
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# SPDX-FileCopyrightText: 2022 Richard Brežák <richard@brezak.sk>
|
||||
#
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
{ inputs, lib, config, secret, ... }:
|
||||
{ inputs, lib', config, secret, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
inherit (lib')
|
||||
flip
|
||||
mapAttrs
|
||||
singleton;
|
||||
|
@ -13,15 +13,12 @@ in
|
|||
{
|
||||
flake.nixosConfigurations.heater = inputs.nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
lib = lib';
|
||||
|
||||
specialArgs = {
|
||||
config' = config';
|
||||
inputs' = inputs;
|
||||
secret =
|
||||
if builtins.pathExists "${inputs.secret}/default.nix" then
|
||||
import inputs.secret { inherit lib; }
|
||||
else
|
||||
{};
|
||||
secret = lib'.loadSecrets;
|
||||
};
|
||||
modules = singleton
|
||||
({ pkgs, config, ... }:
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# SPDX-FileCopyrightText: 2022 Richard Brežák <richard@brezak.sk>
|
||||
#
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
{ inputs, lib, config, ... }:
|
||||
{ inputs, lib', config, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
inherit (lib')
|
||||
flip
|
||||
mapAttrs
|
||||
singleton;
|
||||
|
@ -13,15 +13,12 @@ in
|
|||
{
|
||||
flake.nixosConfigurations.liveusb = inputs.nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
lib = lib';
|
||||
|
||||
specialArgs = {
|
||||
config' = config';
|
||||
inputs' = inputs;
|
||||
secret =
|
||||
if builtins.pathExists "${inputs.secret}/default.nix" then
|
||||
import inputs.secret { inherit lib; }
|
||||
else
|
||||
{};
|
||||
secret = lib'.loadSecrets inputs.secrets;
|
||||
};
|
||||
|
||||
modules = singleton
|
||||
|
|
|
@ -1,27 +1,25 @@
|
|||
# SPDX-FileCopyrightText: 2022 Richard Brežák <richard@brezak.sk>
|
||||
#
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
{ inputs, lib, config, secret, ... }:
|
||||
{ inputs, lib', config, secret, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
inherit (lib')
|
||||
flip
|
||||
mapAttrs
|
||||
singleton;
|
||||
singleton
|
||||
loadSecrets;
|
||||
|
||||
config' = config;
|
||||
in
|
||||
{
|
||||
flake.nixosConfigurations.omen = inputs.nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
lib = lib';
|
||||
|
||||
specialArgs = {
|
||||
config' = config';
|
||||
inputs' = inputs;
|
||||
secret =
|
||||
if builtins.pathExists "${inputs.secret}/default.nix" then
|
||||
import inputs.secret { inherit lib; }
|
||||
else
|
||||
{};
|
||||
secret = loadSecrets inputs.secret;
|
||||
};
|
||||
|
||||
modules = singleton
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# SPDX-FileCopyrightText: 2022 Richard Brežák <richard@brezak.sk>
|
||||
#
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
{ inputs, lib, config, ... }:
|
||||
{ inputs, lib', config, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
inherit (lib')
|
||||
flip
|
||||
mapAttrs
|
||||
singleton;
|
||||
|
@ -17,11 +17,7 @@ in
|
|||
specialArgs = {
|
||||
config' = config';
|
||||
inputs' = inputs;
|
||||
secret =
|
||||
if builtins.pathExists "${inputs.secret}/default.nix" then
|
||||
import inputs.secret { inherit lib; }
|
||||
else
|
||||
{};
|
||||
secret = lib'.loadSecrets inputs.secret;
|
||||
};
|
||||
|
||||
modules = singleton
|
||||
|
|
Loading…
Reference in a new issue