This repository has been archived by the owner on Apr 6, 2020. It is now read-only.
/
nixpkgs.patch
106 lines (96 loc) · 4.6 KB
/
nixpkgs.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
diff --git a/nixos/modules/services/databases/postgresql.nix b/nixos/modules/services/databases/postgresql.nix
index 7bba4dacddc..4ede5edb6da 100644
--- a/nixos/modules/services/databases/postgresql.nix
+++ b/nixos/modules/services/databases/postgresql.nix
@@ -319,12 +319,15 @@ in
# Wait for PostgreSQL to be ready to accept connections.
postStart =
''
- PSQL="${pkgs.sudo}/bin/sudo -u ${cfg.superUser} psql --port=${toString cfg.port}"
+ PSQL="${pkgs.deroot}/bin/deroot ${cfg.superUser} psql --port=${toString cfg.port}"
+ echo waiting for daemon to come online
while ! $PSQL -d postgres -c "" 2> /dev/null; do
if ! kill -0 "$MAINPID"; then exit 1; fi
sleep 0.1
+ echo slept
done
+ echo its up
if test -e "${cfg.dataDir}/.first_startup"; then
${optionalString (cfg.initialScript != null) ''
diff --git a/nixos/modules/services/monitoring/prometheus/exporters/postgres.nix b/nixos/modules/services/monitoring/prometheus/exporters/postgres.nix
index 1ece73a1159..681c017e9a1 100644
--- a/nixos/modules/services/monitoring/prometheus/exporters/postgres.nix
+++ b/nixos/modules/services/monitoring/prometheus/exporters/postgres.nix
@@ -37,10 +37,7 @@ in
DynamicUser = false;
User = mkIf cfg.runAsLocalSuperUser (mkForce "postgres");
ExecStart = ''
- ${pkgs.prometheus-postgres-exporter}/bin/postgres_exporter \
- --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
- --web.telemetry-path ${cfg.telemetryPath} \
- ${concatStringsSep " \\\n " cfg.extraFlags}
+ ${pkgs.prometheus-postgres-exporter}/bin/postgres_exporter --web.listen-address ${cfg.listenAddress}:${toString cfg.port} --web.telemetry-path ${cfg.telemetryPath} ${concatStringsSep " " cfg.extraFlags}
'';
};
};
diff --git a/nixos/modules/services/security/oauth2_proxy.nix b/nixos/modules/services/security/oauth2_proxy.nix
index bb03f7fc9e4..e1bb652ec0d 100644
--- a/nixos/modules/services/security/oauth2_proxy.nix
+++ b/nixos/modules/services/security/oauth2_proxy.nix
@@ -77,7 +77,7 @@ let
(mapAttrsToList (name: value: mapConfig (key + "-" + name) value) attr) else
if (builtins.typeOf attr) == "list" then concatMapStringsSep " " (mapConfig key) attr else
if (builtins.typeOf attr) == "bool" then "--${key}=${boolToString attr}" else
- if (builtins.typeOf attr) == "string" then "--${key}='${attr}'" else
+ if (builtins.typeOf attr) == "string" then ''--${key}="${attr}"'' else
"--${key}=${toString attr}")
else "";
@@ -553,11 +553,11 @@ in
path = [ cfg.package ];
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
+ script = "exec ${cfg.package.bin}/bin/oauth2_proxy ${configString}";
serviceConfig = {
User = "oauth2_proxy";
Restart = "always";
- ExecStart = "${cfg.package.bin}/bin/oauth2_proxy ${configString}";
EnvironmentFile = mkIf (cfg.keyFile != null) cfg.keyFile;
};
};
diff --git a/nixos/modules/testing/service-runner.nix b/nixos/modules/testing/service-runner.nix
index 17d5e337690..a6f67e418df 100644
--- a/nixos/modules/testing/service-runner.nix
+++ b/nixos/modules/testing/service-runner.nix
@@ -4,7 +4,10 @@ with lib;
let
- makeScript = name: service: pkgs.writeScript "${name}-runner"
+ makeScript = name: service:
+ let
+ dropRoot = if service.serviceConfig ? User then "/bin/deroot ${service.serviceConfig.User} " else "";
+ in pkgs.writeScript "${name}-runner"
''
#! ${pkgs.perl}/bin/perl -w -I${pkgs.perlPackages.FileSlurp}/${pkgs.perl.libPrefix}
@@ -47,6 +50,10 @@ let
$ENV{'${n}'} = '${v}';
'') service.environment)}
+ ${optionalString (service.serviceConfig ? WorkingDirectory) ''
+ chdir "${toString service.serviceConfig.WorkingDirectory}";
+ ''}
+
# Run the ExecStartPre program. FIXME: this could be a list.
my $preStart = '${service.serviceConfig.ExecStartPre or ""}';
if ($preStart ne "") {
@@ -56,9 +63,12 @@ let
};
# Run the ExecStart program.
- my $cmd = '${service.serviceConfig.ExecStart}';
- print STDERR "running ExecStart: $cmd\n";
- my $mainPid = run $cmd;
+ my $cmd = <<'END_MESSAGE';
+ ${dropRoot}${service.serviceConfig.ExecStart}
+ END_MESSAGE
+ ($goodcmd = $cmd) =~ s/\\\n/ /g;
+ print STDERR "running ExecStart: $goodcmd\n";
+ my $mainPid = run $goodcmd;
$ENV{'MAINPID'} = $mainPid;
# Catch SIGINT, propagate to the main program.