Compare commits

...

8 commits

Author SHA1 Message Date
Bruno BELANYI 673ead7863 home: ssh: add missing 'mkIf cfg.enable'
All checks were successful
continuous-integration/drone/push Build is passing
2021-09-24 01:21:57 +02:00
Bruno BELANYI 3d10461a6e home: remove unused arguments 2021-09-24 01:21:57 +02:00
Bruno BELANYI 75312c747b modules: remove unused arguments 2021-09-24 01:21:57 +02:00
Bruno BELANYI 68be7743ad machines: remove unused arguments 2021-09-24 01:21:57 +02:00
Bruno BELANYI 9d362655e2 pkgs: remove unused arguments 2021-09-24 01:21:57 +02:00
Bruno BELANYI 604b99a7ac lib: remove 'with self;' 2021-09-24 01:21:57 +02:00
Bruno BELANYI 8467fda721 lib: modules: refactor 'mapModules'
Introduce the recursive version of this function, then refactor to
reduce repetition.
2021-09-24 01:21:57 +02:00
Bruno BELANYI bad9b8a06b lib: modules: document 'mapModules' 2021-09-24 00:26:28 +02:00
11 changed files with 52 additions and 26 deletions

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ config, lib, ... }:
let
cfg = config.my.home.mail.msmtp;
in

View file

@ -7,7 +7,7 @@ in
enable = mkDisableOption "ssh configuration";
};
config.programs.ssh = {
config.programs.ssh = lib.mkIf cfg.enable {
enable = true;
matchBlocks = {

View file

@ -12,8 +12,7 @@ let
};
mylib = makeExtensible (self:
with self; mapModules ./.
(file: import file { inherit self lib pkgs inputs; })
mapModules ./. (file: import file { inherit self lib pkgs inputs; })
);
in
mylib.extend (self: super:

View file

@ -3,21 +3,48 @@ let
inherit (builtins) readDir pathExists;
inherit (lib) hasPrefix hasSuffix nameValuePair removeSuffix;
inherit (self.attrs) mapFilterAttrs;
implOptionalRecursion = recurse:
let
recurseStep =
if recurse
then (n: path: fn: nameValuePair n (impl path fn))
else (_: _: _: nameValuePair "" null);
impl = dir: fn:
mapFilterAttrs
(n: _: n != "" && !(hasPrefix "_" n))
(n: v:
let
path = "${toString dir}/${n}";
in
if v == "directory"
then
if pathExists "${path}/default.nix"
then nameValuePair n (fn path)
else recurseStep n path fn
else if v == "regular" && n != "default.nix" && hasSuffix ".nix" n
then nameValuePair (removeSuffix ".nix" n) (fn path)
else nameValuePair "" null)
(readDir dir);
in
impl;
in
{
mapModules = dir: fn:
mapFilterAttrs
(n: v:
v != null &&
!(hasPrefix "_" n))
(n: v:
let path = "${toString dir}/${n}"; in
if v == "directory" && pathExists "${path}/default.nix"
then nameValuePair n (fn path)
else if v == "regular" &&
n != "default.nix" &&
hasSuffix ".nix" n
then nameValuePair (removeSuffix ".nix" n) (fn path)
else nameValuePair "" null)
(readDir dir);
# Find all nix modules in a directory, discard any prefixed with "_",
# map a function to each resulting path, and generate an attribute set
# to associate module name to resulting value.
#
# mapModules ::
# path
# (path -> any)
# attrs
mapModules = implOptionalRecursion false;
# Recursive version of mapModules.
#
# mapModulesRec ::
# path
# (path -> any)
# attrs
mapModulesRec = implOptionalRecursion true;
}

View file

@ -2,7 +2,7 @@
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, ... }:
{ ... }:
{
imports = [

View file

@ -1,4 +1,4 @@
{ lib, ... }:
{ ... }:
{
config.my.services = {
wireguard = {

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ config, lib, ... }:
let
cfg = config.my.hardware.upower;
in

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ config, lib, ... }:
let
cfg = config.my.services.paperless;
in

View file

@ -1,5 +1,5 @@
# A simple podcast fetcher
{ config, lib, pkgs, ... }:
{ config, lib, ... }:
let
cfg = config.my.services.podgrab;
in

View file

@ -1,4 +1,4 @@
{ lib, fetchurl, gnulib, stdenv }:
{ lib, fetchurl, stdenv }:
stdenv.mkDerivation rec {
pname = "nolimips";
version = "0.11";

View file

@ -1,4 +1,4 @@
{ lib, fetchFromGitHub, gawk, stdenvNoCC, unified-hosts-lists }:
{ lib, gawk, stdenvNoCC, unified-hosts-lists }:
stdenvNoCC.mkDerivation rec {
name = "unbound-zones-adblock";
version = unified-hosts-lists.version;