diff --git a/flake.nix b/flake.nix index d5bb2c4..6158616 100644 --- a/flake.nix +++ b/flake.nix @@ -48,7 +48,13 @@ inputs.sops-nix.homeManagerModules.sops ./home/hosts/eris.nix ]; - extraSpecialArgs = { inherit inputs; }; + extraSpecialArgs = { + inherit inputs; + lib = import ./home/lib/origami404.nix { + hmSource = inputs.home-manager; + npLib = nixpkgs-linux.lib; + }; + }; }; "origami@metis" = home-manager.lib.homeManagerConfiguration { @@ -58,7 +64,13 @@ inputs.sops-nix.homeManagerModules.sops ./home/hosts/metis.nix ]; - extraSpecialArgs = { inherit inputs; }; + extraSpecialArgs = { + inherit inputs; + lib = import ./home/lib/origami404.nix { + hmSource = inputs.home-manager; + npLib = nixpkgs-linux.lib; + }; + }; }; "origami@hypnos" = home-manager-darwin.lib.homeManagerConfiguration { @@ -68,7 +80,13 @@ inputs.sops-nix.homeManagerModules.sops ./home/hosts/hypnos.nix ]; - extraSpecialArgs = { inherit inputs; }; + extraSpecialArgs = { + inherit inputs; + lib = import ./home/lib/origami404.nix { + hmSource = inputs.home-manager-darwin; + npLib = nixpkgs-darwin.lib; + }; + }; }; }; }; diff --git a/home/lib/origami404.nix b/home/lib/origami404.nix new file mode 100644 index 0000000..6adc452 --- /dev/null +++ b/home/lib/origami404.nix @@ -0,0 +1,22 @@ +{ hmSource, npLib }: +let + standaloneRoot = ../standalone; + baseLib = import "${hmSource}/modules/lib/stdlib-extended.nix" npLib; +in +baseLib.extend (final: prev: { + origami404 = (prev.origami404 or { }) // { + standaloneToHome = arg: + let + rel = if prev.isString arg then arg else arg.rel; + realpath = if prev.isString arg then rel else (arg.realpath or rel); + src = standaloneRoot + "/${rel}"; + isDir = prev.filesystem.pathIsDirectory src; + in + { + "${realpath}" = { + source = src; + recursive = isDir; + }; + }; + }; +}) diff --git a/home/modules/ssh.nix b/home/modules/ssh.nix index 4300204..d767856 100644 --- a/home/modules/ssh.nix +++ b/home/modules/ssh.nix @@ -5,10 +5,7 @@ defaultSopsFile = ../../secrets/ssh-config.yaml; }; - home.file.".ssh" = { - source = ./ssh; - recursive = true; - }; + home.file = lib.origami404.standaloneToHome ".ssh"; home.activation.sshDirPerms = lib.hm.dag.entryAfter [ "writeBoundary" ] '' if [ -d "$HOME/.ssh" ]; then diff --git a/home/modules/zsh.nix b/home/modules/zsh.nix index 6c7a371..ca4a367 100644 --- a/home/modules/zsh.nix +++ b/home/modules/zsh.nix @@ -8,10 +8,8 @@ }; home.shell.enableZshIntegration = true; - home.file.".zsh.d" = { - source = ./zsh/.zsh.d; - recursive = true; - }; - home.file.".zshrc.o4".source = ./zsh/.zshrc; + home.file = + (lib.origami404.standaloneToHome ".zsh.d") + // (lib.origami404.standaloneToHome { rel = ".zshrc"; realpath = ".zshrc.o4"; }); programs.zsh.initContent = "source $HOME/.zshrc.o4"; } diff --git a/home/modules/ssh/ssh/id_ed25519.pub b/home/standalone/.ssh/id_ed25519.pub similarity index 100% rename from home/modules/ssh/ssh/id_ed25519.pub rename to home/standalone/.ssh/id_ed25519.pub diff --git a/home/modules/zsh/.zsh.d/completion.zsh b/home/standalone/.zsh.d/completion.zsh similarity index 100% rename from home/modules/zsh/.zsh.d/completion.zsh rename to home/standalone/.zsh.d/completion.zsh diff --git a/home/modules/zsh/.zsh.d/develop.zsh b/home/standalone/.zsh.d/develop.zsh similarity index 100% rename from home/modules/zsh/.zsh.d/develop.zsh rename to home/standalone/.zsh.d/develop.zsh diff --git a/home/modules/zsh/.zsh.d/grml-zshrc b/home/standalone/.zsh.d/grml-zshrc similarity index 100% rename from home/modules/zsh/.zsh.d/grml-zshrc rename to home/standalone/.zsh.d/grml-zshrc diff --git a/home/modules/zsh/.zsh.d/misc.zsh b/home/standalone/.zsh.d/misc.zsh similarity index 100% rename from home/modules/zsh/.zsh.d/misc.zsh rename to home/standalone/.zsh.d/misc.zsh diff --git a/home/modules/zsh/.zsh.d/modern-utils.zsh b/home/standalone/.zsh.d/modern-utils.zsh similarity index 100% rename from home/modules/zsh/.zsh.d/modern-utils.zsh rename to home/standalone/.zsh.d/modern-utils.zsh diff --git a/home/modules/zsh/.zsh.d/nix.zsh b/home/standalone/.zsh.d/nix.zsh similarity index 100% rename from home/modules/zsh/.zsh.d/nix.zsh rename to home/standalone/.zsh.d/nix.zsh diff --git a/home/modules/zsh/.zsh.d/pdf.zsh b/home/standalone/.zsh.d/pdf.zsh similarity index 100% rename from home/modules/zsh/.zsh.d/pdf.zsh rename to home/standalone/.zsh.d/pdf.zsh diff --git a/home/modules/zsh/.zsh.d/rsync.zsh b/home/standalone/.zsh.d/rsync.zsh similarity index 100% rename from home/modules/zsh/.zsh.d/rsync.zsh rename to home/standalone/.zsh.d/rsync.zsh diff --git a/home/modules/zsh/.zshrc b/home/standalone/.zshrc similarity index 100% rename from home/modules/zsh/.zshrc rename to home/standalone/.zshrc