From dd4f3fd46b5eba4154a56da8697da763d4c21b2f Mon Sep 17 00:00:00 2001 From: Grey Jones Date: Sun, 30 Aug 2026 02:08:51 +0100 Subject: [PATCH] homeFilesFromStringAttrs: first implementation --- flake.nix | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index ae7ba3a..02fd23e 100644 --- a/flake.nix +++ b/flake.nix @@ -5,7 +5,7 @@ nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; }; - outputs = { self, nixpkgs }: { + outputs = { self, nixpkgs }: rec { mkIfElse = with nixpkgs.lib; p: yes: no: mkMerge [ (mkIf p yes) (mkIf (!p) no) @@ -18,6 +18,15 @@ ln -s ${source} ${target} ''; - attrByStrPath = strPath: set: nixpkgs.lib.attrsets.attrByPath (nixpkgs.lib.strings.splitString "." strPath) null set; + attrByStrPath = strPath: set: nixpkgs.lib.attrByPath (nixpkgs.lib.strings.splitString "." strPath) null set; + + setAttrByStrPath = strPath: value: nixpkgs.lib.setAttrByPath (nixpkgs.lib.strings.splitString "." strPath) value; + + homeFilesFromStringAttrs = { dir, attrs, exec ? false }: map (x: (map (y: { + "${dir}/${x}" = { + text = y; + executable = exec; + }; + }) builtins.attrValues attrs) ) builtins.attrNames attrs; }; }