From 01e44c1f7f6b66cf0a51ae28d85bb70fce8f5886 Mon Sep 17 00:00:00 2001 From: colin Date: Tue, 3 Jan 2023 14:18:57 +0000 Subject: [PATCH] flake.nix: remove unused specialArgs --- flake.nix | 1 - modules/lib/default.nix | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 modules/lib/default.nix diff --git a/flake.nix b/flake.nix index 6901f9c2..5d88e10a 100644 --- a/flake.nix +++ b/flake.nix @@ -54,7 +54,6 @@ in (nixosSystem { # by default the local system is the same as the target, employing emulation when they differ system = target; - specialArgs = { inherit mobile-nixos home-manager impermanence; }; modules = [ ./modules (import ./hosts/instantiate.nix name) diff --git a/modules/lib/default.nix b/modules/lib/default.nix new file mode 100644 index 00000000..3155611b --- /dev/null +++ b/modules/lib/default.nix @@ -0,0 +1,21 @@ +{ lib, utils, ... }: + +rec { + path = { + # split the string path into a list of string components. + # root directory "/" becomes the empty list []. + # implicitly performs normalization so that: + # split "a//b/" => ["a" "b"] + # split "/a/b" => ["a" "b"] + split = str: builtins.filter (seg: (builtins.isString seg) && seg != "" ) (builtins.split "/" str); + # return a string path, with leading slash but no trailing slash + joinAbs = comps: "/" + (builtins.concatStringsSep "/" comps); + concat = paths: path.joinAbs (builtins.concatLists (builtins.map path.split paths)); + # normalize the given path + norm = str: path.joinAbs (path.split str); + # return the parent directory. doesn't care about leading/trailing slashes. + # the parent of "/" is "/". + parent = str: path.norm (builtins.dirOf (path.norm str)); + hasParent = str: (path.parent str) != (path.norm str); + }; +}