1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

treewide: remove with lib (#6735)

Continuation of `with lib;` cleanup.
This commit is contained in:
Austin Horstman 2025-03-31 22:32:16 -05:00 committed by GitHub
parent ccd7df836e
commit 0b491b460f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
200 changed files with 2421 additions and 2817 deletions

View file

@ -1,8 +1,7 @@
{ config, lib, pkgs, ... }:
with lib;
let
inherit (lib) mkOption types;
cfg = config.programs.sftpman;
jsonFormat = pkgs.formats.json { };
@ -67,13 +66,13 @@ let
};
};
in {
meta.maintainers = with maintainers; [ fugi ];
meta.maintainers = with lib.maintainers; [ fugi ];
options.programs.sftpman = {
enable = mkEnableOption
enable = lib.mkEnableOption
"sftpman, an application that handles sshfs/sftp file systems mounting";
package = mkPackageOption pkgs "sftpman" { nullable = true; };
package = lib.mkPackageOption pkgs "sftpman" { nullable = true; };
defaultSshKey = mkOption {
type = types.nullOr types.str;
@ -92,13 +91,15 @@ in {
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
assertions = [
(let
hasMissingKey = _: mount:
mount.authType == "publickey" && mount.sshKey == null;
mountsWithMissingKey = attrNames (filterAttrs hasMissingKey cfg.mounts);
mountsWithMissingKeyStr = concatStringsSep ", " mountsWithMissingKey;
mountsWithMissingKey =
lib.attrNames (lib.filterAttrs hasMissingKey cfg.mounts);
mountsWithMissingKeyStr =
lib.concatStringsSep ", " mountsWithMissingKey;
in {
assertion = mountsWithMissingKey == [ ];
message = ''
@ -109,8 +110,8 @@ in {
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile = mapAttrs' (name: value:
nameValuePair "sftpman/mounts/${name}.json" {
xdg.configFile = lib.mapAttrs' (name: value:
lib.nameValuePair "sftpman/mounts/${name}.json" {
source =
jsonFormat.generate "sftpman-${name}.json" (value // { id = name; });
}) cfg.mounts;