Modules/Agenix: Change to system module
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@ -10,4 +10,4 @@ result
|
|||||||
config/neovim/store
|
config/neovim/store
|
||||||
home/modules/ags/config/types
|
home/modules/ags/config/types
|
||||||
home/modules/ags/config/tsconfig.json
|
home/modules/ags/config/tsconfig.json
|
||||||
home/modules/agenix/secrets.nix
|
system/modules/agenix/secrets.nix
|
||||||
|
@ -300,6 +300,25 @@
|
|||||||
file = lib.mkMerge [
|
file = lib.mkMerge [
|
||||||
{
|
{
|
||||||
".ssh/id_ed25519.pub".text = "${publicKeys.${username}.ssh}";
|
".ssh/id_ed25519.pub".text = "${publicKeys.${username}.ssh}";
|
||||||
|
|
||||||
|
# The user will be able to decrypt .age files using agenix.
|
||||||
|
# On each user/machine, this should generate a corresponding secrets.nix
|
||||||
|
"${config.paths.nixflake}/system/modules/agenix/secrets.nix".text = let
|
||||||
|
mkSecret = key: name: "\"${name}.age\".publicKeys = [\"${key}\"];";
|
||||||
|
in ''
|
||||||
|
# NOTE: This file will contain keys depending on the host/by which user it was built on.
|
||||||
|
{
|
||||||
|
${lib.optionalString
|
||||||
|
# If this user defined any secrets...
|
||||||
|
(builtins.hasAttr "${username}" nixosConfig.modules.agenix.secrets)
|
||||||
|
# ...we will add them to the current secrets.nix,
|
||||||
|
# s.t. agenix can be used to encrypt the secret.
|
||||||
|
(builtins.concatStringsSep "\n"
|
||||||
|
(builtins.map
|
||||||
|
(mkSecret publicKeys.${username}.ssh)
|
||||||
|
nixosConfig.modules.agenix.secrets.${username}))}
|
||||||
|
}
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
(lib.mkIf nixosConfig.modules.desktopportal.termfilechooser.enable {
|
(lib.mkIf nixosConfig.modules.desktopportal.termfilechooser.enable {
|
||||||
".config/xdg-desktop-portal-termfilechooser/config".text = ''
|
".config/xdg-desktop-portal-termfilechooser/config".text = ''
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
nixosConfig,
|
nixosConfig,
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
username,
|
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
imports = [
|
imports = [
|
||||||
@ -13,8 +12,6 @@
|
|||||||
|
|
||||||
config = {
|
config = {
|
||||||
modules = {
|
modules = {
|
||||||
# agenix.secrets.${username} = [];
|
|
||||||
|
|
||||||
hyprland = {
|
hyprland = {
|
||||||
kb-layout = "us";
|
kb-layout = "us";
|
||||||
kb-variant = "altgr-intl";
|
kb-variant = "altgr-intl";
|
||||||
|
@ -11,15 +11,6 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
modules = {
|
|
||||||
agenix.secrets.${username} = [
|
|
||||||
"heidi-discord-token"
|
|
||||||
"kopia-password"
|
|
||||||
"kopia-server-username"
|
|
||||||
"kopia-server-password"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
docker-compose
|
docker-compose
|
||||||
];
|
];
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
# Obsolete modules are kept in "1_deprecated" for reference.
|
# Obsolete modules are kept in "1_deprecated" for reference.
|
||||||
|
|
||||||
# My own HM modules
|
# My own HM modules
|
||||||
./agenix
|
|
||||||
./beets
|
./beets
|
||||||
./chromium
|
./chromium
|
||||||
./color
|
./color
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
nixosConfig,
|
|
||||||
lib,
|
lib,
|
||||||
mylib,
|
mylib,
|
||||||
pkgs,
|
pkgs,
|
||||||
@ -13,25 +12,9 @@ in {
|
|||||||
options.modules.agenix = import ./options.nix {inherit lib mylib;};
|
options.modules.agenix = import ./options.nix {inherit lib mylib;};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
# The user will be able to decrypt .age files using agenix.
|
# NOTE: See the generated secrets.nix file in home/christoph/default.nix
|
||||||
# On each user/machine, this should generate a corresponding secrets.nix
|
|
||||||
home.file."${config.paths.nixflake}/home/modules/agenix/secrets.nix".text = let
|
|
||||||
mkSecret = key: name: "\"${name}.age\".publicKeys = [\"${key}\"];";
|
|
||||||
in ''
|
|
||||||
# NOTE: This file will contain keys depending on the host/by which user it was built on.
|
|
||||||
{
|
|
||||||
${lib.optionalString
|
|
||||||
# If this user defined any secrets...
|
|
||||||
(builtins.hasAttr "${username}" agenix.secrets)
|
|
||||||
# ...we will add them to the current secrets.nix,
|
|
||||||
# s.t. agenix can be used to encrypt the secret.
|
|
||||||
(builtins.concatStringsSep "\n"
|
|
||||||
(builtins.map
|
|
||||||
(mkSecret publicKeys.${username}.ssh)
|
|
||||||
agenix.secrets.${username}))}
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
|
|
||||||
|
# Register generated secrets to the age system module
|
||||||
age.secrets = let
|
age.secrets = let
|
||||||
mkSecretIfExists = name:
|
mkSecretIfExists = name:
|
||||||
# If this user has already encrypted the secret...
|
# If this user has already encrypted the secret...
|
@ -2,13 +2,7 @@
|
|||||||
lib,
|
lib,
|
||||||
mylib,
|
mylib,
|
||||||
...
|
...
|
||||||
}: let
|
}: {
|
||||||
mkSecret = file:
|
|
||||||
lib.mkOption {
|
|
||||||
type = lib.types.path;
|
|
||||||
default = file;
|
|
||||||
};
|
|
||||||
in {
|
|
||||||
secrets = lib.mkOption {
|
secrets = lib.mkOption {
|
||||||
type = lib.types.attrs;
|
type = lib.types.attrs;
|
||||||
description = "The secret files managed by agenix (and their associated keys)";
|
description = "The secret files managed by agenix (and their associated keys)";
|
||||||
@ -25,9 +19,4 @@ in {
|
|||||||
|
|
||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
heidi-discord-token = mkSecret ./heidi-discord-token.age;
|
|
||||||
kopia-user-password = mkSecret ./kopia-user-password.age;
|
|
||||||
kopia-server-user = mkSecret ./kopia-server-user.age;
|
|
||||||
kopia-server-password = mkSecret ./kopia-server-password.age;
|
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
{...}: {
|
{...}: {
|
||||||
imports = [
|
imports = [
|
||||||
|
./agenix
|
||||||
./bootloader
|
./bootloader
|
||||||
./desktopportal
|
./desktopportal
|
||||||
./docker
|
./docker
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
mylib,
|
mylib,
|
||||||
pkgs,
|
pkgs,
|
||||||
|
username,
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
imports = [
|
imports = [
|
||||||
@ -11,6 +12,8 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
modules = {
|
modules = {
|
||||||
|
# agenix.secrets.${username} = [];
|
||||||
|
|
||||||
network = {
|
network = {
|
||||||
useNetworkManager = true;
|
useNetworkManager = true;
|
||||||
|
|
||||||
|
@ -36,6 +36,13 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
modules = {
|
modules = {
|
||||||
|
agenix.secrets.${username} = [
|
||||||
|
"heidi-discord-token"
|
||||||
|
"kopia-password"
|
||||||
|
"kopia-server-username"
|
||||||
|
"kopia-server-password"
|
||||||
|
];
|
||||||
|
|
||||||
network = {
|
network = {
|
||||||
useNetworkManager = false;
|
useNetworkManager = false;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user