Skip to content

Commit 7145f2d

Browse files
Ryan Trinkledanielfullmer
authored andcommitted
Add security.pki.certificateFiles option
1 parent 1075210 commit 7145f2d

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ let
5757
./modules/etc.nix
5858
./modules/framework.nix
5959
./modules/hosts.nix
60+
./modules/security-pki.nix
6061
./modules/kernel.nix
6162
./modules/microg.nix
6263
./modules/pixel

modules/security-pki.nix

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# SPDX-FileCopyrightText: 2022 Daniel Fullmer and robotnix contributors
2+
# SPDX-License-Identifier: MIT
3+
4+
{ config, pkgs, lib, ... }:
5+
6+
let
7+
inherit (lib) mkIf mkOption types;
8+
in
9+
{
10+
options = {
11+
security.pki.certificateFiles = mkOption {
12+
default = [];
13+
type = types.listOf types.path;
14+
description = "A list of files containing trusted root certificates in PEM format. These are added as system-level trust anchors.";
15+
};
16+
};
17+
18+
config = mkIf (config.security.pki.certificateFiles != []) {
19+
source.dirs."system/ca-certificates".postPatch = lib.concatMapStringsSep "\n" (certFile: ''
20+
cp -v ${lib.escapeShellArg "${certFile}"} $out/files/$(${pkgs.openssl}/bin/openssl x509 -inform PEM -subject_hash_old -in ${lib.escapeShellArg "${certFile}"} -noout).0
21+
'') config.security.pki.certificateFiles;
22+
};
23+
}

0 commit comments

Comments
 (0)