difftreelog
fix documentation generator fix
in: trunk
3 files changed
modules/nixos/secrets.nixdiffbeforeafterboth--- a/modules/nixos/secrets.nix
+++ b/modules/nixos/secrets.nix
@@ -7,7 +7,7 @@
}: let
inherit (builtins) hashString;
inherit (lib.stringsWithDeps) stringAfter;
- inherit (lib.options) mkOption;
+ inherit (lib.options) mkOption literalExpression;
inherit (lib.lists) optional;
inherit (lib.attrsets) mapAttrs;
inherit (lib.modules) mkIf;
@@ -78,6 +78,7 @@
type = str;
description = "Group of the secret";
default = sysConfig.users.users.${config.owner}.group;
+ defaultText = literalExpression "config.users.users.$${owner}.group";
};
};
});
modules/nixpkgs.nixdiffbeforeafterboth--- a/modules/nixpkgs.nix
+++ b/modules/nixpkgs.nix
@@ -4,7 +4,7 @@
config,
...
}: let
- inherit (lib.options) mkOption;
+ inherit (lib.options) mkOption literalExpression;
inherit (lib.types) path;
inherit (lib.modules) mkRemovedOptionModule;
inherit (fleetLib.options) mkHostsOption;
@@ -39,6 +39,7 @@
'';
type = path;
default = config.nixpkgs.buildUsing;
+ defaultText = literalExpression "config.nixpkgs.buildUsing";
};
# imports = [
# (mkRemovedOptionModule ["nixpkgs" "overlays"] "this option needs to be specified at nixosModules level")
modules/secrets.nixdiffbeforeafterboth1{2 lib,3 config,4 ...5}: let6 inherit (lib.options) mkOption;7 inherit (lib.types) unspecified nullOr listOf str bool attrsOf submodule;8 inherit (lib.strings) concatStringsSep;9 inherit (lib.attrsets) mapAttrs;1011 sharedSecret = {config, ...}: {12 options = {13 expectedOwners = mkOption {14 type = nullOr (listOf str);15 description = ''16 List of hosts to encrypt secret for. null if managed by user (= via owners field from fleet.nix)1718 Secrets would be decrypted and stored to /run/secrets/$\{name} on owners19 '';20 default = null;21 };22 # TODO: Aren't those options may be just desugared to data/expectedData?23 regenerateOnOwnerAdded = mkOption {24 type = bool;25 description = ''26 Is this secret owner-dependent, and needs to be regenerated on ownership set change, or it may be just reencrypted.2728 You want to have this option set to true, when this secret contains some reference to its owners, i.e x509 SANs.29 '';30 };31 regenerateOnOwnerRemoved = mkOption {32 default = config.regenerateOnOwnerAdded;33 type = bool;34 description = ''35 Should this secret be removed on owner removal, or it may be just reencrypted3637 Most probably its value should be equal to regenerateOnOwnerAdded, override only if you know what are you doing.38 Contrary to regenerateOnOwnerAdded, you may want to set this option to false, when host permissions are revoked39 in some other way than by this secret ownership, I.e by firewall/etc.40 '';41 };42 generator = mkOption {43 type = nullOr unspecified;44 description = "Derivation to evaluate for secret generation";45 default = null;46 };47 };48 };49in {50 options = {51 sharedSecrets = mkOption {52 type = attrsOf (submodule sharedSecret);53 default = {};54 description = "Shared secrets";55 };56 };57 config = {58 hosts =59 mapAttrs (_: secretMap: {60 nixos.secrets = mapAttrs (_: s: removeAttrs s ["createdAt" "expiresAt"]) secretMap;61 })62 config.data.hostSecrets;63 nixpkgs.overlays = [64 (final: prev: {65 mkSecretGenerators = {recipients}: rec {66 # TODO: Merge both generators to one with consistent options syntax?67 # Impure generator is built on local machine, then built closure is copied to remote machine,68 # and then it is ran in inpure context, so that this generator may access HSMs and other things.69 mkImpureSecretGenerator = {70 script,71 # If set - script will be run on remote machine, otherwise it will be run with fleet project in CWD72 # (Some secrets-encryption-in-git/managed PKI solution is expected)73 impureOn ? null,74 }:75 (prev.writeShellScript "impureGenerator.sh" ''76 #!/bin/sh77 set -eu7879 export GENERATOR_HELPER_IDENTITIES="${concatStringsSep"\n"recipients}";80 export PATH=${final.fleet-generator-helper}/bin:$PATH8182 # TODO: Provide tempdir from outside, to make it securely erasurable as needed?83 tmp=mktemp-d84 cd $tmp85 # cd /var/empty8687 created_at=date-u"%Y-%m-%dT%H:%M:%S.%NZ"8889 ${script}9091 if ! test -d $out; then92 echo "impure generator script did not produce expected \$out output"93 exit 194 fi9596 echo -n $created_at > $out/created_at97 echo -n SUCCESS > $out/marker98 '')99 .overrideAttrs (old: {100 passthru = {101 inherit impureOn;102 generatorKind = "impure";103 };104 });105 # Pure generators are disabled for now106 mkSecretGenerator = {script}: mkImpureSecretGenerator {inherit script;};107108 # TODO: Implement consistent naming109 # Pure secret generator is supposed to be run entirely by nix, using `__impure` derivation type...110 # But for now, it is ran the same way as `impureSecretGenerator`, but on the local machine.111 # mkSecretGenerator = {script}:112 # (prev.writeShellScript "generator.sh" ''113 # #!/bin/sh114 # set -eu115 # # TODO: make nix daemon build secret, not just the script.116 # cd /var/empty117 #118 # created_at=$(date -u +"%Y-%m-%dT%H:%M:%S.%NZ")119 #120 # ${script}121 # if ! test -d $out; then122 # echo "impure generator script did not produce expected \$out output"123 # exit 1124 # fi125 #126 # echo -n $created_at > $out/created_at127 # echo -n SUCCESS > $out/marker128 # '')129 # .overrideAttrs (old: {130 # passthru = {131 # generatorKind = "pure";132 # };133 # # TODO: make nix daemon build secret, not just the script.134 # # __impure = true;135 # });136 };137 })138 ];139 };140}1{2 lib,3 config,4 ...5}: let6 inherit (lib.options) mkOption literalExpression;7 inherit (lib.types) unspecified nullOr listOf str bool attrsOf submodule;8 inherit (lib.strings) concatStringsSep;9 inherit (lib.attrsets) mapAttrs;1011 sharedSecret = {config, ...}: {12 options = {13 expectedOwners = mkOption {14 type = nullOr (listOf str);15 description = ''16 List of hosts to encrypt secret for. null if managed by user (= via owners field from fleet.nix)1718 Secrets would be decrypted and stored to /run/secrets/$\{name} on owners19 '';20 default = null;21 };22 # TODO: Aren't those options may be just desugared to data/expectedData?23 regenerateOnOwnerAdded = mkOption {24 type = bool;25 description = ''26 Is this secret owner-dependent, and needs to be regenerated on ownership set change, or it may be just reencrypted.2728 You want to have this option set to true, when this secret contains some reference to its owners, i.e x509 SANs.29 '';30 };31 regenerateOnOwnerRemoved = mkOption {32 default = config.regenerateOnOwnerAdded;33 defaultText = literalExpression "regenerateOnOwnerAdded";34 type = bool;35 description = ''36 Should this secret be removed on owner removal, or it may be just reencrypted3738 Most probably its value should be equal to regenerateOnOwnerAdded, override only if you know what are you doing.39 Contrary to regenerateOnOwnerAdded, you may want to set this option to false, when host permissions are revoked40 in some other way than by this secret ownership, I.e by firewall/etc.41 '';42 };43 generator = mkOption {44 type = nullOr unspecified;45 description = "Derivation to evaluate for secret generation";46 default = null;47 };48 };49 };50in {51 options = {52 sharedSecrets = mkOption {53 type = attrsOf (submodule sharedSecret);54 default = {};55 description = "Shared secrets";56 };57 };58 config = {59 hosts =60 mapAttrs (_: secretMap: {61 nixos.secrets = mapAttrs (_: s: removeAttrs s ["createdAt" "expiresAt"]) secretMap;62 })63 config.data.hostSecrets;64 nixpkgs.overlays = [65 (final: prev: {66 mkSecretGenerators = {recipients}: rec {67 # TODO: Merge both generators to one with consistent options syntax?68 # Impure generator is built on local machine, then built closure is copied to remote machine,69 # and then it is ran in inpure context, so that this generator may access HSMs and other things.70 mkImpureSecretGenerator = {71 script,72 # If set - script will be run on remote machine, otherwise it will be run with fleet project in CWD73 # (Some secrets-encryption-in-git/managed PKI solution is expected)74 impureOn ? null,75 }:76 (prev.writeShellScript "impureGenerator.sh" ''77 #!/bin/sh78 set -eu7980 export GENERATOR_HELPER_IDENTITIES="${concatStringsSep"\n"recipients}";81 export PATH=${final.fleet-generator-helper}/bin:$PATH8283 # TODO: Provide tempdir from outside, to make it securely erasurable as needed?84 tmp=mktemp-d85 cd $tmp86 # cd /var/empty8788 created_at=date-u"%Y-%m-%dT%H:%M:%S.%NZ"8990 ${script}9192 if ! test -d $out; then93 echo "impure generator script did not produce expected \$out output"94 exit 195 fi9697 echo -n $created_at > $out/created_at98 echo -n SUCCESS > $out/marker99 '')100 .overrideAttrs (old: {101 passthru = {102 inherit impureOn;103 generatorKind = "impure";104 };105 });106 # Pure generators are disabled for now107 mkSecretGenerator = {script}: mkImpureSecretGenerator {inherit script;};108109 # TODO: Implement consistent naming110 # Pure secret generator is supposed to be run entirely by nix, using `__impure` derivation type...111 # But for now, it is ran the same way as `impureSecretGenerator`, but on the local machine.112 # mkSecretGenerator = {script}:113 # (prev.writeShellScript "generator.sh" ''114 # #!/bin/sh115 # set -eu116 # # TODO: make nix daemon build secret, not just the script.117 # cd /var/empty118 #119 # created_at=$(date -u +"%Y-%m-%dT%H:%M:%S.%NZ")120 #121 # ${script}122 # if ! test -d $out; then123 # echo "impure generator script did not produce expected \$out output"124 # exit 1125 # fi126 #127 # echo -n $created_at > $out/created_at128 # echo -n SUCCESS > $out/marker129 # '')130 # .overrideAttrs (old: {131 # passthru = {132 # generatorKind = "pure";133 # };134 # # TODO: make nix daemon build secret, not just the script.135 # # __impure = true;136 # });137 };138 })139 ];140 };141}