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 let
cfg = config.my.home.mail.msmtp; cfg = config.my.home.mail.msmtp;
in in

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,4 +1,4 @@
{ lib, fetchurl, gnulib, stdenv }: { lib, fetchurl, stdenv }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "nolimips"; pname = "nolimips";
version = "0.11"; 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 { stdenvNoCC.mkDerivation rec {
name = "unbound-zones-adblock"; name = "unbound-zones-adblock";
version = unified-hosts-lists.version; version = unified-hosts-lists.version;