mirror of
https://github.com/sadan4/dotfiles.git
synced 2025-06-09 22:13:02 -04:00
work
This commit is contained in:
parent
f5431cbae8
commit
3b9f424694
7 changed files with 95 additions and 40 deletions
28
common/util/paths.nix
Normal file
28
common/util/paths.nix
Normal file
|
@ -0,0 +1,28 @@
|
|||
{ lib, ... }:
|
||||
let
|
||||
array = import ./array.nix { };
|
||||
in
|
||||
{
|
||||
path = rec {
|
||||
split = { path }: builtins.split "/" "${path}";
|
||||
removeSuffix = suffix: path: lib.removeSuffix suffix "${path}";
|
||||
# ====
|
||||
basename =
|
||||
{
|
||||
path,
|
||||
suffix ? "",
|
||||
}:
|
||||
let
|
||||
basename = if array.length (split path) >= 2 then array.tail (split path);
|
||||
in
|
||||
removeSuffix suffix basename;
|
||||
# nix doesnt support windows
|
||||
delimiter = ":";
|
||||
dirname =
|
||||
path:
|
||||
let
|
||||
ending = basename { inherit path; };
|
||||
in
|
||||
removeSuffix ending path;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue