sane.programs: allow programs to define files, as per sane.fs

This commit is contained in:
2023-04-24 06:49:56 +00:00
parent e7f02c057e
commit 337fb9e9d9
2 changed files with 11 additions and 3 deletions

View File

@@ -7,5 +7,5 @@
sopsFile = ../../../secrets/universal/aerc_accounts.conf; sopsFile = ../../../secrets/universal/aerc_accounts.conf;
format = "binary"; format = "binary";
}; };
sane.user.fs.".config/aerc/accounts.conf" = sane-lib.fs.wantedSymlinkTo config.sops.secrets.aerc_accounts.path; sane.programs.aerc.fs.".config/aerc/accounts.conf" = sane-lib.fs.wantedSymlinkTo config.sops.secrets.aerc_accounts.path;
} }

View File

@@ -1,4 +1,4 @@
{ config, lib, pkgs, sane-lib, ... }: { config, lib, options, pkgs, sane-lib, ... }:
let let
inherit (builtins) any attrValues elem map; inherit (builtins) any attrValues elem map;
inherit (lib) inherit (lib)
@@ -87,6 +87,11 @@ let
default = []; default = [];
description = "list of home-relative paths to persist (in encrypted format) for this package"; description = "list of home-relative paths to persist (in encrypted format) for this package";
}; };
fs = mkOption {
type = types.attrs;
default = {};
description = "files to populate when this program is enabled";
};
}; };
config = { config = {
@@ -105,14 +110,17 @@ let
environment.systemPackages = optional environment.systemPackages = optional
(p.package != null && p.enableFor.system) (p.package != null && p.enableFor.system)
p.package; p.package;
# conditionally add to user(s) PATH # conditionally add to user(s) PATH
users.users = mapAttrs (user: en: { users.users = mapAttrs (user: en: {
packages = optional (p.package != null && en) p.package; packages = optional (p.package != null && en) p.package;
}) p.enableFor.user; }) p.enableFor.user;
# conditionally persist relevant user dirs
# conditionally persist relevant user dirs and create files
sane.users = mapAttrs (user: en: optionalAttrs en { sane.users = mapAttrs (user: en: optionalAttrs en {
persist.plaintext = p.dir; persist.plaintext = p.dir;
persist.private = p.private; persist.private = p.private;
fs = p.fs;
}) p.enableFor.user; }) p.enableFor.user;
}) cfg; }) cfg;
in in