X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=modules%2Fsecrets.nix;h=a2424e920fd78eb62021fb70bfb4db8bedb53e73;hb=HEAD;hp=808b15c5bdeb886347a8f9c34f69891495e0999f;hpb=17f6eae9907a122d4472da727ae8b1ac1c40c027;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/modules/secrets.nix b/modules/secrets.nix deleted file mode 100644 index 808b15c..0000000 --- a/modules/secrets.nix +++ /dev/null @@ -1,65 +0,0 @@ -{ lib, pkgs, config, ... }: -{ - options.secrets = { - keys = lib.mkOption { - type = lib.types.listOf lib.types.unspecified; - default = []; - description = "Keys to upload to server"; - }; - location = lib.mkOption { - type = lib.types.path; - default = "/var/secrets"; - description = "Location where to put the keys"; - }; - }; - config = let - location = config.secrets.location; - keys = config.secrets.keys; - empty = pkgs.runCommand "empty" { preferLocalBuild = true; } "mkdir -p $out && touch $out/done"; - dumpKey = v: '' - mkdir -p secrets/$(dirname ${v.dest}) - echo -n ${lib.strings.escapeShellArg v.text} > secrets/${v.dest} - cat >> mods < 0) { - system.activationScripts.secrets = { - deps = [ "users" "wrappers" ]; - text = '' - install -m0750 -o root -g keys -d ${location} - if [ -f /run/keys/secrets.tar ]; then - if [ ! -f ${location}/currentSecrets ] || ! sha512sum -c --status "${location}/currentSecrets"; then - echo "rebuilding secrets" - TMP=$(${pkgs.coreutils}/bin/mktemp -d) - if [ -n "$TMP" ]; then - install -m0750 -o root -g keys -d $TMP - ${pkgs.gnutar}/bin/tar --strip-components 1 -C $TMP -xf /run/keys/secrets.tar - sha512sum /run/keys/secrets.tar > $TMP/currentSecrets - find $TMP -type d -exec chown root:keys {} \; -exec chmod o-rx {} \; - ${pkgs.rsync}/bin/rsync -O -c -av --delete $TMP/ ${location} - rm -rf $TMP - fi - fi - fi - ''; - }; - deployment.keys."secrets.tar" = { - permissions = "0400"; - # keyFile below is not evaluated at build time by nixops, so the - # `secrets` path doesn’t necessarily exist when uploading the - # keys, and nixops is unhappy. - user = "root${builtins.substring 10000 1 secrets}"; - group = "root"; - keyFile = "${secrets}"; - }; - }; -}