From d21693d58404473bfd2afaa59236b2aa1fd83112 Mon Sep 17 00:00:00 2001 From: Patrick Date: Tue, 5 Sep 2023 23:01:07 +0200 Subject: [PATCH] WIP --- hosts/desktopnix/default.nix | 2 + modules/config/home-manager.nix | 2 +- modules/optional/streamdeck.nix | 4 ++ modules/smb-mounts.nix | 85 +++++++++++++++++---------------- users/patrick/default.nix | 1 + users/patrick/smb.nix | 5 +- 6 files changed, 55 insertions(+), 44 deletions(-) create mode 100644 modules/optional/streamdeck.nix diff --git a/hosts/desktopnix/default.nix b/hosts/desktopnix/default.nix index 8a21355..e86a1d6 100644 --- a/hosts/desktopnix/default.nix +++ b/hosts/desktopnix/default.nix @@ -18,6 +18,8 @@ ../../modules/hardware/yubikey.nix ../../modules/hardware/zfs.nix + ../../modules/optional/streamdeck.nix + ./net.nix ./fs.nix diff --git a/modules/config/home-manager.nix b/modules/config/home-manager.nix index 8ef9e88..4917951 100644 --- a/modules/config/home-manager.nix +++ b/modules/config/home-manager.nix @@ -13,7 +13,7 @@ } ]; extraSpecialArgs = { - nixosConfig = config; + #nixosConfig = config; }; }; # HM zsh needs this or else the startup order is fucked diff --git a/modules/optional/streamdeck.nix b/modules/optional/streamdeck.nix new file mode 100644 index 0000000..4a08858 --- /dev/null +++ b/modules/optional/streamdeck.nix @@ -0,0 +1,4 @@ +{ + # broken on nixpkgs currently. How fun + #programs.streamdeck-ui.enable = true; +} diff --git a/modules/smb-mounts.nix b/modules/smb-mounts.nix index da13f0f..267b0f2 100644 --- a/modules/smb-mounts.nix +++ b/modules/smb-mounts.nix @@ -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"; + }; + } + ) + ) + ); + } + ]; } diff --git a/users/patrick/default.nix b/users/patrick/default.nix index 089d9d5..1253d4f 100644 --- a/users/patrick/default.nix +++ b/users/patrick/default.nix @@ -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 = [ diff --git a/users/patrick/smb.nix b/users/patrick/smb.nix index d2b499d..80b8418 100644 --- a/users/patrick/smb.nix +++ b/users/patrick/smb.nix @@ -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;