Add myutils to base system
So I can import it everywhere.
This commit is contained in:
parent
47056f3df8
commit
7530a91823
2 changed files with 19 additions and 0 deletions
16
lib/myutils.nix
Normal file
16
lib/myutils.nix
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
{ lib, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
stripTabs = text: let
|
||||||
|
# Whether all lines start with a tab (or is empty)
|
||||||
|
shouldStripTab = lines: builtins.all (line: (line == "") || (pkgs.lib.strings.hasPrefix " " line)) lines;
|
||||||
|
# Strip a leading tab from all lines
|
||||||
|
stripTab = lines: builtins.map (line: pkgs.lib.strings.removePrefix " " line) lines;
|
||||||
|
# Strip tabs recursively until there are none
|
||||||
|
stripTabs = lines: if (shouldStripTab lines) then (stripTabs (stripTab lines)) else lines;
|
||||||
|
in
|
||||||
|
# Split into lines. Strip leading tabs. Concat back to string.
|
||||||
|
builtins.concatStringsSep "\n" (stripTabs (pkgs.lib.strings.splitString "\n" text));
|
||||||
|
in {
|
||||||
|
stripTabs = stripTabs;
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
{ config, configFiles, lib, pkgs, ... }:
|
{ config, configFiles, lib, pkgs, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
|
# Add my custom utilities
|
||||||
|
_module.args.myutils = import ../../lib/myutils.nix { lib = lib; pkgs = pkgs; };
|
||||||
|
|
||||||
boot.tmp.cleanOnBoot = true;
|
boot.tmp.cleanOnBoot = true;
|
||||||
environment.systemPackages = map lib.lowPrio [
|
environment.systemPackages = map lib.lowPrio [
|
||||||
pkgs.curl
|
pkgs.curl
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue