summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ro/rollup/patches2/0006-lib-Merge-with-the-extraLib.patch
blob: 1cca069c38aa0511c606d3055b260d33de67d7ae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
From b30b9eed670d9f02eccb1120f18cbf084caf32f0 Mon Sep 17 00:00:00 2001
From: Benedikt Peetz <benedikt.peetz@b-peetz.de>
Date: Mon, 2 Nov 2026 19:56:15 +0100
Subject: [PATCH 6/7] lib: Merge with the `extraLib`

---
 lib/default.nix | 126 ------------------------------------------------
 1 file changed, 126 deletions(-)
 delete mode 100644 lib/default.nix

diff --git a/lib/default.nix b/lib/default.nix
deleted file mode 100644
index 1cdbf936..00000000
--- a/lib/default.nix
+++ /dev/null
@@ -1,126 +0,0 @@
-# nixos-config - My current NixOS configuration
-#
-# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-# This file is part of my nixos-config.
-#
-# You should have received a copy of the License along with this program.
-# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
-{lib}: rec {
-  /*
-  Converts `number` from a binary number to a decimal one.
-
-  The input is indented to be a number composed only of `1`s and `0` (e.g., 10010.)
-
-  # Type
-
-  binaryToDecimal :: Int -> Int
-
-  # Arguments
-
-  number
-  : The sequence of `1`s and `0`s defining a binary number, in little endian.
-
-  # Examples
-
-  binaryToDecimal 1001
-  => 9
-  */
-  binaryToDecimal = number: let
-    binaryList =
-      builtins.map lib.strings.toInt (lib.lists.reverseList (lib.strings.stringToCharacters (builtins.toString number)));
-  in
-    builtins.foldl' (acc: num: acc + num) 0
-    (lib.lists.imap0 (index: elem: elem * (pow 2 index)) binaryList);
-
-  /*
-  Converts `string` to a (probably) unique numerical id.
-
-  This is achieved by hashing the string and returning the first six hex-digits
-  converted to a base 10 number.
-
-  # Type
-
-  idFromString :: String -> Int
-
-  # Arguments
-
-  string
-  : The string to use as seed for the id generation.
-
-  # Examples
-
-  idFromString "3d-printer"
-  => 10365713
-  */
-  idFromString = string: let
-    inputSeed =
-      builtins.concatStringsSep ""
-      (lib.lists.take 6
-        (lib.strings.stringToCharacters (builtins.hashString "sha256" string)));
-  in
-    lib.trivial.fromHexString inputSeed;
-
-  /*
-  source: https://github.com/NixOS/nix/issues/10387#issuecomment-2494597690
-
-  Raises the `base` to the power of `power`.
-
-  Considering the small input size and the lack of a built-in power function [2],
-  this naive power implementation should satisfy reasonable performance
-  requirements.
-
-  Due to the lack of a modulo and bitwise AND operator, it is questionable whether
-  the recursive exponentiation by squaring [1] implementation would even be
-  faster.
-
-  [1]: https://en.wikipedia.org/wiki/Exponentiation_by_squaring
-  [2]: https://github.com/NixOS/nix/issues/10387
-
-  # Type
-
-  pow :: Number -> Number -> Number
-
-  # Arguments
-
-  base
-  : The base number to be raised.
-
-  power
-  : The exponent to raise `base` to.
-
-  # Examples
-
-  pow 2 5
-  => 32
-  */
-  pow = base: power:
-    if power == 0
-    then 1
-    else if power > 0
-    then (base * (pow base (power - 1)))
-    else builtins.throw "Negative powers are not supported";
-
-  options = {
-    /*
-    Generate an enable option definition, that defaults to true.
-
-    This conveniently allows the composition of a “common” module set.
-
-    # Type
-
-    mkEnable :: String -> AttrSet
-
-    # Arguments
-
-    name
-    : The name to use in the option description.
-    */
-    mkEnable = name:
-      (lib.mkEnableOption name)
-      // {
-        default = true;
-      };
-  };
-}
-- 
2.55.0