pkgs/mkSymlinks: add method to create arbitrary symlinks

This commit is contained in:
Infinidoge 2024-02-19 13:56:36 -05:00
parent 71ae9d9630
commit b43b922e78
Signed by: Infinidoge
SSH key fingerprint: SHA256:oAMyvotlNFraMmZmr+p6AxnNfW/GioTs1pOn3V4tQ7A
2 changed files with 24 additions and 0 deletions

View file

@ -3,6 +3,7 @@
ears-cli = pkgs.callPackage ./ears-cli.nix { };
hexagon = pkgs.callPackage ./hexagon.nix { };
mcaselector = pkgs.callPackage ./mcaselector.nix { };
mkSymlinks = pkgs.callPackage ./mk-symlinks.nix { };
neocities = pkgs.callPackage ./neocities { };
nix-modrinth-prefetch = pkgs.callPackage ./nix-modrinth-prefetch.nix { };
olympus = pkgs.callPackage ./olympus.nix { };

23
pkgs/mk-symlinks.nix Normal file
View file

@ -0,0 +1,23 @@
{ lib, stdenv }:
{ name, symlinks }:
let
normalized = lib.mapAttrs' (n: v: lib.nameValuePair (lib.path.subpath.normalise n) "${v}") symlinks;
linkCommands = lib.mapAttrsToList
(n: v: ''
mkdir -p $out/$(dirname ${n})
ln -s ${v} $out/${n}
'')
normalized;
in
stdenv.mkDerivation {
name = "firefox";
phases = [ "installPhase" ];
preferLocalBuild = true;
allowSubstitutes = false;
installPhase = ''
mkdir $out
${lib.concatStringsSep "\n" linkCommands}
'';
}