This commit is contained in:
Patrick 2023-09-05 23:01:07 +02:00
parent adf3ceb9cb
commit d21693d584
Signed by: patrick
GPG key ID: 451F95EFB8BECD0F
6 changed files with 55 additions and 44 deletions

View file

@ -18,6 +18,8 @@
../../modules/hardware/yubikey.nix
../../modules/hardware/zfs.nix
../../modules/optional/streamdeck.nix
./net.nix
./fs.nix

View file

@ -13,7 +13,7 @@
}
];
extraSpecialArgs = {
nixosConfig = config;
#nixosConfig = config;
};
};
# HM zsh needs this or else the startup order is fucked

View file

@ -0,0 +1,4 @@
{
# broken on nixpkgs currently. How fun
#programs.streamdeck-ui.enable = true;
}

View file

@ -11,7 +11,8 @@
flip
attrNames
toString
flatten
mkMerge
concatMap
;
baseOptions = [
"x-systemd.idle-timeout=60"
@ -24,8 +25,8 @@ in {
{
options.home.smb = mkOption {
description = "Samba shares to be mountable under $HOME/smb";
default = {};
type = types.listOf types.submodule {
default = [];
type = types.listOf (types.submodule {
options = {
localPath = mkOption {
description = "The path under which the share will be mounted. Defaults to the remotePath";
@ -52,45 +53,49 @@ in {
type = types.boolean;
};
};
};
});
};
}
];
imports = flatten (
flip
map
(attrNames config.home-manager.users)
(
user: let
parentPath = "${config.home-manager.users.${user}.homeDir}/smb";
cfg = config.home-manager.users.user.smb;
in
flip map cfg (
cfg: {
environment.systemPackages = [pkgs.cifs-utils];
fileSystems = {
"${parentPath}/${cfg.localpath or cfg.remotePath}" = let
options =
baseOptions
++ [
"uid=${toString config.users.users.${user}.uid}"
"gid=${toString config.users.groups.${user}.gid}"
"credentials=${cfg.credentials}"
"${
if cfg.automatic
then ""
else "noauto"
}"
];
in {
inherit options;
device = "//${cfg.address}/${cfg.remotePath}";
fsType = "cifs";
};
};
}
)
)
);
imports = [
{
environment.systemPackages = [pkgs.cifs-utils];
fileSystems =
mkMerge
(
flip
concatMap
(attrNames config.home-manager.users)
(
user: let
parentPath = "${config.home-manager.users.${user}.home.homeDirectory}/smb";
cfg = config.home-manager.users.${user}.home.smb;
in
flip map cfg (
cfg: {
"${parentPath}/${cfg.localpath or cfg.remotePath}" = let
options =
baseOptions
++ [
"uid=${toString config.users.users.${user}.uid}"
"gid=${toString config.users.groups.${user}.gid}"
"credentials=${cfg.credentials}"
"${
if cfg.automatic
then ""
else "noauto"
}"
];
in {
inherit options;
device = "//${cfg.address}/${cfg.remotePath}";
fsType = "cifs";
};
}
)
)
);
}
];
}

View file

@ -25,6 +25,7 @@
# xournalpp needs this or else it will crash
gnome3.adwaita-icon-theme
];
age.secrets.smb-creds.rekeyFile = ../../secrets/smb.cred.age;
home-manager.users.patrick = {
imports = [

View file

@ -1,8 +1,7 @@
{config, ...}: {
age.secrets.smb-creds.rekeyFile = ../../secrets/smb.cred.age;
{nixosConfig, ...}: {
home.smb = let
address = "192.168.178.2";
credentials = config.age.secrets.smb-creds.path;
credentials = nixosConfig.age.secrets.smb-creds.path;
in [
{
inherit address credentials;