Skip to content

Commit

Permalink
Merge pull request #69 from Melkor333/master
Browse files Browse the repository at this point in the history
Fix letsencrypt tests, user type definition and getSubmodules function
  • Loading branch information
qknight authored Sep 22, 2020
2 parents 3a0767f + fea08a7 commit 05701ee
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 26 deletions.
10 changes: 5 additions & 5 deletions modules/services/TLS/test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
with pkgs.lib;

let
commonConfig = <nixpkgs/nixos/tests/common/letsencrypt/common.nix>;
snakeoil-certs = import (<nixpkgs/nixos/tests/common/letsencrypt/snakeoil-certs.nix>);
commonConfig = <nixpkgs/nixos/tests/common/acme/client>;
snakeoil-certs = import (<nixpkgs/nixos/tests/common/acme/server/snakeoil-certs.nix>);
in rec {
name = "nixcloud.TLS";

nodes = rec {
letsencrypt = <nixpkgs/nixos/tests/common/letsencrypt>;
acme = <nixpkgs/nixos/tests/common/acme/server>;

webserver = { config, pkgs, nodes, ... }: {
imports = [ commonConfig ];
Expand Down Expand Up @@ -258,12 +258,12 @@ in rec {
};

testScript = ''
$letsencrypt->waitForUnit("default.target");
$acme->waitForUnit("default.target");
$webserver->waitForUnit("default.target");
$client->waitForUnit("default.target");
$letsencrypt->waitForUnit("multi-user.target");
$acme->waitForUnit("multi-user.target");
# if the nixcloud.reverse-proxy doesn't make it, we don't need to go on
$webserver->waitForUnit("nixcloud.reverse-proxy.service");
Expand Down
9 changes: 5 additions & 4 deletions modules/services/reverse-proxy/test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,11 @@ in

services.httpd = {
enable = true;
listen = [{
port = 60000;
ip = "*";
}];
virtualHosts = {
"example.com" = {
listen = [{port = 60000; ip = "*";}];
};
};
adminAddr="[email protected]";
};

Expand Down
4 changes: 1 addition & 3 deletions modules/web/core/base.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ let
optionNames = lib.attrNames (lib.filterAttrs (lib.const isUnit) reEval);
in lib.genAttrs optionNames (name: toplevel.options.systemd.${name});

getSubModules = opt: let
subModules = opt.type.getSubModules;
in map (m: m.submodule) subModules;
getSubModules = opt: opt.type.functor.wrapped.functor.payload.modules;

availableInstanceDependencies = [
"after" "before" "bindsTo" "conflicts" "partOf" "requiredBy" "requires"
Expand Down
24 changes: 10 additions & 14 deletions modules/web/core/webserver.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ in {

webserver.userOptions = lib.mkOption {
default = {};
type = let
submodules = toplevel.options.users.users.type.getSubModules;
in lib.types.submodule (map (m: m.submodule) submodules);
type = lib.types.submodule toplevel.options.users.users.type.functor.wrapped.getSubModules;
description = ''
Additional options for the user, see <option>users.users</option> for
possible values.
Expand All @@ -78,9 +76,7 @@ in {

webserver.groupOptions = lib.mkOption {
default = {};
type = let
submodules = toplevel.options.users.groups.type.getSubModules;
in lib.types.submodule (map (m: m.submodule) submodules);
type = lib.types.submodule toplevel.options.users.groups.type.functor.wrapped.getSubModules;
description = ''
Additional options for the group, see <option>users.groups</option> for
possible values.
Expand Down Expand Up @@ -114,15 +110,15 @@ in {
}
];

users.${config.webserver.user} = lib.mkMerge [
(lib.mkForce { inherit (config.webserver) name group; })
(lib.modules.mkAliasAndWrapDefsWithPriority lib.id config.webserver.userOptions)
];



users.${config.webserver.user} = {
inherit (config.webserver) group;
} // removeAttrs config.webserver.userOptions [ "name" "group" ];

groups.${config.webserver.group} =
removeAttrs config.webserver.groupOptions [ "name" ];
groups.${config.webserver.group} = lib.mkMerge [
(lib.mkForce { inherit (config.webserver) name; })
(lib.modules.mkAliasAndWrapDefsWithPriority lib.id config.webserver.groupOptions)
];
})
(lib.mkIf (config.enable && needsWebServerInit) {
systemd.services.webserver-init = {
Expand Down

0 comments on commit 05701ee

Please sign in to comment.