Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move packageWithOverrides to configuration #10

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
result
58 changes: 41 additions & 17 deletions modules/services/caml-crush/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,9 @@
# List of libnames wrappers to generate
libnames = builtins.attrNames cfg.pkcs11Modules;

packageWithOverrides = (cfg.package.overrideAttrs
(prev: {
configureFlags =
prev.configureFlags
++ [
"--with-libnames=${builtins.concatStringsSep "," libnames}"
"--with-client-socket=${cfg.clientSocket}"
]
++ lib.optionals cfg.disableFilter [
"--without-filter"
];
}))
.override {ocamlClient = cfg.enableOcamlClient;};

mkPkcs11ToolWrapper = libname:
pkgs.writeShellScriptBin "pkcs11-tool-caml-crush-${libname}" ''
exec "${pkgs.opensc}/bin/pkcs11-tool" --module "${packageWithOverrides}/lib/caml-crush/libp11client${libname}.so" $@
exec "${pkgs.opensc}/bin/pkcs11-tool" --module "${cfg.packageWithOverrides}/lib/caml-crush/libp11client${libname}.so" $@
'';
in {
options.ghaf.services.caml-crush = {
Expand Down Expand Up @@ -124,6 +110,44 @@ in {
description = lib.mdDoc "The package to use for the caml-crush.";
};

packageWithOverrides = lib.mkOption {
type = lib.types.package;
default = (cfg.package.overrideAttrs
(prev: {
configureFlags =
prev.configureFlags
++ [
"--with-libnames=${builtins.concatStringsSep "," libnames}"
"--with-client-socket=${cfg.clientSocket}"
]
++ lib.optionals cfg.disableFilter [
"--without-filter"
];
}))
.override {ocamlClient = cfg.enableOcamlClient;};
defaultText = lib.literalExpression ''
(cfg.package.overrideAttrs
(prev: {
configureFlags =
prev.configureFlags
++ [
"--with-libnames=${builtins.concatStringsSep "," libnames}"
"--with-client-socket=${cfg.clientSocket}"
]
++ lib.optionals cfg.disableFilter [
"--without-filter"
];
}))
.override {ocamlClient = cfg.enableOcamlClient;};
'';
description = lib.mdDoc ''
The package, where overrides from this module's settings have been
applied to the derivation.

Useful if you need to get the library for example.
'';
};

user = lib.mkOption {
type = lib.types.str;
default = defaultUser;
Expand Down Expand Up @@ -172,15 +196,15 @@ in {
systemd.services.caml-crush = {
enable = true;
description = "Caml Crush: an OCaml PKCS#11 filtering proxy";
path = [packageWithOverrides];
path = [cfg.packageWithOverrides];
serviceConfig = {
User = cfg.user;
Group = cfg.group;
Type = "simple";
StandardOutput = "journal";
StandardError = "journal";
ExecStart = lib.concatStringsSep " " [
"${packageWithOverrides}/bin/pkcs11proxyd"
"${cfg.packageWithOverrides}/bin/pkcs11proxyd"
"-fg"
"-conf"
"${pkcs11proxydConf}"
Expand Down
Loading