flake: reformat with nixfmt
This commit is contained in:
parent
a79e641851
commit
eaf4f56ac0
117 changed files with 2667 additions and 1592 deletions
212
lib/default.nix
212
lib/default.nix
|
@ -1,107 +1,133 @@
|
|||
{ lib }:
|
||||
lib.makeExtensible (self:
|
||||
with lib;
|
||||
rec {
|
||||
flattenListSet = imports: (flatten (concatLists (attrValues imports)));
|
||||
flattenSetList = attrSet: (mapAttrs (name: value: flatten value) attrSet);
|
||||
lib.makeExtensible (
|
||||
self:
|
||||
with lib;
|
||||
rec {
|
||||
flattenListSet = imports: (flatten (concatLists (attrValues imports)));
|
||||
flattenSetList = attrSet: (mapAttrs (name: value: flatten value) attrSet);
|
||||
|
||||
# ["/home/user/" "/.screenrc"] -> ["home" "user" ".screenrc"]
|
||||
splitPath = paths:
|
||||
(filter
|
||||
(s: builtins.typeOf s == "string" && s != "")
|
||||
(concatMap (builtins.split "/") paths)
|
||||
);
|
||||
# ["/home/user/" "/.screenrc"] -> ["home" "user" ".screenrc"]
|
||||
splitPath =
|
||||
paths:
|
||||
(filter (s: builtins.typeOf s == "string" && s != "") (concatMap (builtins.split "/") paths));
|
||||
|
||||
# ["home" "user" ".screenrc"] -> "home/user/.screenrc"
|
||||
dirListToPath = dirList: (concatStringsSep "/" dirList);
|
||||
# ["home" "user" ".screenrc"] -> "home/user/.screenrc"
|
||||
dirListToPath = dirList: (concatStringsSep "/" dirList);
|
||||
|
||||
# ["/home/user/" "/.screenrc"] -> "/home/user/.screenrc"
|
||||
concatPaths = paths:
|
||||
let
|
||||
prefix = optionalString (hasPrefix "/" (head paths)) "/";
|
||||
path = dirListToPath (splitPath paths);
|
||||
in
|
||||
prefix + path;
|
||||
# ["/home/user/" "/.screenrc"] -> "/home/user/.screenrc"
|
||||
concatPaths =
|
||||
paths:
|
||||
let
|
||||
prefix = optionalString (hasPrefix "/" (head paths)) "/";
|
||||
path = dirListToPath (splitPath paths);
|
||||
in
|
||||
prefix + path;
|
||||
|
||||
sanitizeName = name:
|
||||
replaceStrings
|
||||
[ "." ] [ "" ]
|
||||
(sanitizeDerivationName (removePrefix "/" name));
|
||||
sanitizeName = name: replaceStrings [ "." ] [ "" ] (sanitizeDerivationName (removePrefix "/" name));
|
||||
|
||||
mapGenAttrs = list: func: attrs:
|
||||
lib.genAttrs list (name: func (if builtins.typeOf attrs == "lambda" then attrs name else attrs));
|
||||
mapGenAttrs =
|
||||
list: func: attrs:
|
||||
lib.genAttrs list (name: func (if builtins.typeOf attrs == "lambda" then attrs name else attrs));
|
||||
|
||||
dirsOf = dir: lib.attrNames (lib.filterAttrs (file: type: type == "directory") (builtins.readDir dir));
|
||||
dirsOf =
|
||||
dir: lib.attrNames (lib.filterAttrs (file: type: type == "directory") (builtins.readDir dir));
|
||||
|
||||
# Only useful for functors
|
||||
recMap = f: list:
|
||||
if list == [ ] then f
|
||||
else recMap (f (head list)) (tail list)
|
||||
;
|
||||
# Only useful for functors
|
||||
recMap = f: list: if list == [ ] then f else recMap (f (head list)) (tail list);
|
||||
|
||||
chain = {
|
||||
func = id;
|
||||
__functor = self: input:
|
||||
if (typeOf input) == "lambda"
|
||||
then self // { func = e: input (self.func e); }
|
||||
else self.func input;
|
||||
};
|
||||
chain = {
|
||||
func = id;
|
||||
__functor =
|
||||
self: input:
|
||||
if (typeOf input) == "lambda" then self // { func = e: input (self.func e); } else self.func input;
|
||||
};
|
||||
|
||||
spread = function: list: if list == [ ] then function else spread (function (head list)) (tail list);
|
||||
spread =
|
||||
function: list: if list == [ ] then function else spread (function (head list)) (tail list);
|
||||
|
||||
isFunction = obj: (typeOf obj) == "lambda" || ((typeOf obj) == "set" && obj ? __functor);
|
||||
isFunction = obj: (typeOf obj) == "lambda" || ((typeOf obj) == "set" && obj ? __functor);
|
||||
|
||||
# Takes a function and makes it lazy, by consuming arguments and applying it to the inner function first
|
||||
# before calling the original function
|
||||
# if the inner object is not actually a function, then just calls the original function
|
||||
lazy = func: inner: if !(isFunction inner) then func inner else {
|
||||
inherit func;
|
||||
app = inner;
|
||||
__functor = self: input:
|
||||
let app = self.app input; in
|
||||
if isFunction app then self // { inherit app; }
|
||||
else self.func app;
|
||||
};
|
||||
# Takes a function and makes it lazy, by consuming arguments and applying it to the inner function first
|
||||
# before calling the original function
|
||||
# if the inner object is not actually a function, then just calls the original function
|
||||
lazy =
|
||||
func: inner:
|
||||
if !(isFunction inner) then
|
||||
func inner
|
||||
else
|
||||
{
|
||||
inherit func;
|
||||
app = inner;
|
||||
__functor =
|
||||
self: input:
|
||||
let
|
||||
app = self.app input;
|
||||
in
|
||||
if isFunction app then self // { inherit app; } else self.func app;
|
||||
};
|
||||
|
||||
toBase64 = text:
|
||||
let
|
||||
inherit (lib) sublist mod stringToCharacters concatMapStrings;
|
||||
inherit (lib.strings) charToInt;
|
||||
inherit (builtins) substring foldl' genList elemAt length concatStringsSep stringLength;
|
||||
lookup = stringToCharacters "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
sliceN = size: list: n: sublist (n * size) size list;
|
||||
pows = [ (64 * 64 * 64) (64 * 64) 64 1 ];
|
||||
intSextets = i: map (j: mod (i / j) 64) pows;
|
||||
compose = f: g: x: f (g x);
|
||||
intToChar = elemAt lookup;
|
||||
convertTripletInt = sliceInt: concatMapStrings intToChar (intSextets sliceInt);
|
||||
sliceToInt = foldl' (acc: val: acc * 256 + val) 0;
|
||||
convertTriplet = compose convertTripletInt sliceToInt;
|
||||
join = concatStringsSep "";
|
||||
convertLastSlice = slice:
|
||||
let
|
||||
len = length slice;
|
||||
in
|
||||
if len == 1
|
||||
then (substring 0 2 (convertTripletInt ((sliceToInt slice) * 256 * 256))) + "=="
|
||||
else if len == 2
|
||||
then (substring 0 3 (convertTripletInt ((sliceToInt slice) * 256))) + "="
|
||||
else "";
|
||||
len = stringLength text;
|
||||
nFullSlices = len / 3;
|
||||
bytes = map charToInt (stringToCharacters text);
|
||||
tripletAt = sliceN 3 bytes;
|
||||
head = genList (compose convertTriplet tripletAt) nFullSlices;
|
||||
tail = convertLastSlice (tripletAt nFullSlices);
|
||||
in
|
||||
join (head ++ [ tail ]);
|
||||
toBase64 =
|
||||
text:
|
||||
let
|
||||
inherit (lib)
|
||||
sublist
|
||||
mod
|
||||
stringToCharacters
|
||||
concatMapStrings
|
||||
;
|
||||
inherit (lib.strings) charToInt;
|
||||
inherit (builtins)
|
||||
substring
|
||||
foldl'
|
||||
genList
|
||||
elemAt
|
||||
length
|
||||
concatStringsSep
|
||||
stringLength
|
||||
;
|
||||
lookup = stringToCharacters "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
sliceN =
|
||||
size: list: n:
|
||||
sublist (n * size) size list;
|
||||
pows = [
|
||||
(64 * 64 * 64)
|
||||
(64 * 64)
|
||||
64
|
||||
1
|
||||
];
|
||||
intSextets = i: map (j: mod (i / j) 64) pows;
|
||||
compose =
|
||||
f: g: x:
|
||||
f (g x);
|
||||
intToChar = elemAt lookup;
|
||||
convertTripletInt = sliceInt: concatMapStrings intToChar (intSextets sliceInt);
|
||||
sliceToInt = foldl' (acc: val: acc * 256 + val) 0;
|
||||
convertTriplet = compose convertTripletInt sliceToInt;
|
||||
join = concatStringsSep "";
|
||||
convertLastSlice =
|
||||
slice:
|
||||
let
|
||||
len = length slice;
|
||||
in
|
||||
if len == 1 then
|
||||
(substring 0 2 (convertTripletInt ((sliceToInt slice) * 256 * 256))) + "=="
|
||||
else if len == 2 then
|
||||
(substring 0 3 (convertTripletInt ((sliceToInt slice) * 256))) + "="
|
||||
else
|
||||
"";
|
||||
len = stringLength text;
|
||||
nFullSlices = len / 3;
|
||||
bytes = map charToInt (stringToCharacters text);
|
||||
tripletAt = sliceN 3 bytes;
|
||||
head = genList (compose convertTriplet tripletAt) nFullSlices;
|
||||
tail = convertLastSlice (tripletAt nFullSlices);
|
||||
in
|
||||
join (head ++ [ tail ]);
|
||||
|
||||
disko = import ./disko.nix { inherit lib; };
|
||||
filesystems = import ./filesystems.nix { inherit lib self; };
|
||||
} // (
|
||||
import ./digga.nix { inherit lib; }
|
||||
) // (
|
||||
import ./hosts.nix { inherit lib; }
|
||||
) // (
|
||||
import ./options.nix { inherit lib; }
|
||||
))
|
||||
disko = import ./disko.nix { inherit lib; };
|
||||
filesystems = import ./filesystems.nix { inherit lib self; };
|
||||
}
|
||||
// (import ./digga.nix { inherit lib; })
|
||||
// (import ./hosts.nix { inherit lib; })
|
||||
// (import ./options.nix { inherit lib; })
|
||||
)
|
||||
|
|
195
lib/digga.nix
195
lib/digga.nix
|
@ -4,63 +4,58 @@
|
|||
let
|
||||
flattenTree' =
|
||||
/*
|
||||
*
|
||||
Synopsis: flattenTree' _cond_ _sep_ _tree_
|
||||
*
|
||||
Synopsis: flattenTree' _cond_ _sep_ _tree_
|
||||
|
||||
Flattens a _tree_ of the shape that is produced by rakeLeaves.
|
||||
_cond_ determines when to stop recursing
|
||||
_sep_ is the separator to join the path with
|
||||
Flattens a _tree_ of the shape that is produced by rakeLeaves.
|
||||
_cond_ determines when to stop recursing
|
||||
_sep_ is the separator to join the path with
|
||||
|
||||
Output Format:
|
||||
An attrset with names in the spirit of the Reverse DNS Notation form
|
||||
that fully preserve information about grouping from nesting.
|
||||
Output Format:
|
||||
An attrset with names in the spirit of the Reverse DNS Notation form
|
||||
that fully preserve information about grouping from nesting.
|
||||
|
||||
Example input:
|
||||
```
|
||||
{
|
||||
a = {
|
||||
b = {
|
||||
c = <path>;
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
Example input:
|
||||
```
|
||||
{
|
||||
a = {
|
||||
b = {
|
||||
c = <path>;
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
Example output:
|
||||
```
|
||||
{
|
||||
"a.b.c" = <path>;
|
||||
}
|
||||
```
|
||||
*
|
||||
*/
|
||||
cond:
|
||||
sep:
|
||||
tree:
|
||||
Example output:
|
||||
```
|
||||
{
|
||||
"a.b.c" = <path>;
|
||||
}
|
||||
```
|
||||
*
|
||||
*/
|
||||
cond: sep: tree:
|
||||
let
|
||||
op = sum: path: val:
|
||||
op =
|
||||
sum: path: val:
|
||||
let
|
||||
pathStr = builtins.concatStringsSep sep path; # dot-based reverse DNS notation
|
||||
in
|
||||
if cond val
|
||||
then
|
||||
# builtins.trace "${toString val} matches condition"
|
||||
if cond val then
|
||||
# builtins.trace "${toString val} matches condition"
|
||||
(sum // { "${pathStr}" = val; })
|
||||
else if builtins.isAttrs val
|
||||
then
|
||||
# builtins.trace "${builtins.toJSON val} is an attrset"
|
||||
# recurse into that attribute set
|
||||
else if builtins.isAttrs val then
|
||||
# builtins.trace "${builtins.toJSON val} is an attrset"
|
||||
# recurse into that attribute set
|
||||
(recurse sum path val)
|
||||
else
|
||||
# ignore that value
|
||||
# builtins.trace "${toString path} is something else"
|
||||
# ignore that value
|
||||
# builtins.trace "${toString path} is something else"
|
||||
sum;
|
||||
|
||||
recurse = sum: path: val:
|
||||
builtins.foldl'
|
||||
(sum: key: op sum (path ++ [ key ]) val.${key})
|
||||
sum
|
||||
(builtins.attrNames val);
|
||||
recurse =
|
||||
sum: path: val:
|
||||
builtins.foldl' (sum: key: op sum (path ++ [ key ]) val.${key}) sum (builtins.attrNames val);
|
||||
in
|
||||
recurse { } [ ] tree;
|
||||
|
||||
|
@ -68,40 +63,41 @@ let
|
|||
|
||||
rakeLeaves =
|
||||
/*
|
||||
*
|
||||
Synopsis: rakeLeaves _path_
|
||||
*
|
||||
Synopsis: rakeLeaves _path_
|
||||
|
||||
Recursively collect the nix files of _path_ into attrs.
|
||||
Recursively collect the nix files of _path_ into attrs.
|
||||
|
||||
Output Format:
|
||||
An attribute set where all `.nix` files and directories with `default.nix` in them
|
||||
are mapped to keys that are either the file with .nix stripped or the folder name.
|
||||
All other directories are recursed further into nested attribute sets with the same format.
|
||||
Output Format:
|
||||
An attribute set where all `.nix` files and directories with `default.nix` in them
|
||||
are mapped to keys that are either the file with .nix stripped or the folder name.
|
||||
All other directories are recursed further into nested attribute sets with the same format.
|
||||
|
||||
Example file structure:
|
||||
```
|
||||
./core/default.nix
|
||||
./base.nix
|
||||
./main/dev.nix
|
||||
./main/os/default.nix
|
||||
```
|
||||
Example file structure:
|
||||
```
|
||||
./core/default.nix
|
||||
./base.nix
|
||||
./main/dev.nix
|
||||
./main/os/default.nix
|
||||
```
|
||||
|
||||
Example output:
|
||||
```
|
||||
{
|
||||
core = ./core;
|
||||
base = base.nix;
|
||||
main = {
|
||||
dev = ./main/dev.nix;
|
||||
os = ./main/os;
|
||||
};
|
||||
}
|
||||
```
|
||||
*
|
||||
*/
|
||||
Example output:
|
||||
```
|
||||
{
|
||||
core = ./core;
|
||||
base = base.nix;
|
||||
main = {
|
||||
dev = ./main/dev.nix;
|
||||
os = ./main/os;
|
||||
};
|
||||
}
|
||||
```
|
||||
*
|
||||
*/
|
||||
dirPath:
|
||||
let
|
||||
seive = file: type:
|
||||
seive =
|
||||
file: type:
|
||||
# Only rake `.nix` files or directories
|
||||
(type == "regular" && lib.hasSuffix ".nix" file) || (type == "directory");
|
||||
|
||||
|
@ -111,12 +107,11 @@ let
|
|||
let
|
||||
path = dirPath + "/${file}";
|
||||
in
|
||||
if
|
||||
(type == "regular")
|
||||
|| (type == "directory" && builtins.pathExists (path + "/default.nix"))
|
||||
then path
|
||||
if (type == "regular") || (type == "directory" && builtins.pathExists (path + "/default.nix")) then
|
||||
path
|
||||
# recurse on directories that don't contain a `default.nix`
|
||||
else rakeLeaves path;
|
||||
else
|
||||
rakeLeaves path;
|
||||
};
|
||||
|
||||
files = lib.filterAttrs seive (builtins.readDir dirPath);
|
||||
|
@ -125,42 +120,44 @@ let
|
|||
|
||||
flattenLeaves = dir: flattenTree (rakeLeaves dir);
|
||||
|
||||
getFqdn = c:
|
||||
getFqdn =
|
||||
c:
|
||||
let
|
||||
net = c.config.networking;
|
||||
fqdn =
|
||||
if (net ? domain) && (net.domain != null)
|
||||
then "${net.hostName}.${net.domain}"
|
||||
else net.hostName;
|
||||
if (net ? domain) && (net.domain != null) then "${net.hostName}.${net.domain}" else net.hostName;
|
||||
in
|
||||
fqdn;
|
||||
in
|
||||
{
|
||||
inherit rakeLeaves flattenTree flattenTree' flattenLeaves;
|
||||
inherit
|
||||
rakeLeaves
|
||||
flattenTree
|
||||
flattenTree'
|
||||
flattenLeaves
|
||||
;
|
||||
|
||||
leaves = dir: builtins.attrValues (flattenLeaves dir);
|
||||
|
||||
mkHomeConfigurations = systemConfigurations:
|
||||
mkHomeConfigurations =
|
||||
systemConfigurations:
|
||||
/*
|
||||
*
|
||||
Synopsis: mkHomeConfigurations _systemConfigurations_
|
||||
*
|
||||
Synopsis: mkHomeConfigurations _systemConfigurations_
|
||||
|
||||
Generate the `homeConfigurations` attribute expected by `home-manager` cli
|
||||
from _nixosConfigurations_ or _darwinConfigurations_ in the form
|
||||
_user@hostname_.
|
||||
*
|
||||
*/
|
||||
Generate the `homeConfigurations` attribute expected by `home-manager` cli
|
||||
from _nixosConfigurations_ or _darwinConfigurations_ in the form
|
||||
_user@hostname_.
|
||||
*
|
||||
*/
|
||||
let
|
||||
op = attrs: c:
|
||||
op =
|
||||
attrs: c:
|
||||
attrs
|
||||
// (
|
||||
lib.mapAttrs'
|
||||
(user: v: {
|
||||
name = "${user}@${getFqdn c}";
|
||||
value = v.home;
|
||||
})
|
||||
c.config.home-manager.users
|
||||
);
|
||||
// (lib.mapAttrs' (user: v: {
|
||||
name = "${user}@${getFqdn c}";
|
||||
value = v.home;
|
||||
}) c.config.home-manager.users);
|
||||
mkHmConfigs = lib.foldl op { };
|
||||
in
|
||||
mkHmConfigs (builtins.attrValues systemConfigurations);
|
||||
|
|
|
@ -34,62 +34,84 @@ rec {
|
|||
|
||||
mkTmpfs' = mountOptions: size: mode: {
|
||||
fsType = "tmpfs";
|
||||
mountOptions = mountOptions ++ [ "size=${size}" "mode=${mode}" ];
|
||||
mountOptions = mountOptions ++ [
|
||||
"size=${size}"
|
||||
"mode=${mode}"
|
||||
];
|
||||
};
|
||||
mkTmpfs = size: mkTmpfs' defaultMountOptions size "755";
|
||||
|
||||
# btrfs
|
||||
|
||||
mkBtrfsPart' = base: mountpoint: content': {
|
||||
content = {
|
||||
inherit mountpoint;
|
||||
type = "btrfs";
|
||||
} // content';
|
||||
} // base;
|
||||
mkBtrfsPart' =
|
||||
base: mountpoint: content':
|
||||
{
|
||||
content = {
|
||||
inherit mountpoint;
|
||||
type = "btrfs";
|
||||
} // content';
|
||||
}
|
||||
// base;
|
||||
mkBtrfsPart = size: mkBtrfsPart' { inherit size; };
|
||||
mkBtrfsPartEndAt = end: mkBtrfsPart' { inherit end; };
|
||||
|
||||
mkBtrfsSubvols' = mountOptions: mapAttrs (n: v: {
|
||||
mountpoint = n;
|
||||
mountOptions = mountOptions ++ (optionals (v ? mountOptions) v.mountOptions);
|
||||
} // (removeAttrs v [ "mountOptions" ]));
|
||||
mkBtrfsSubvols' =
|
||||
mountOptions:
|
||||
mapAttrs (
|
||||
n: v:
|
||||
{
|
||||
mountpoint = n;
|
||||
mountOptions = mountOptions ++ (optionals (v ? mountOptions) v.mountOptions);
|
||||
}
|
||||
// (removeAttrs v [ "mountOptions" ])
|
||||
);
|
||||
mkBtrfsSubvols = mkBtrfsSubvols' defaultMountOptions;
|
||||
|
||||
# ZFS
|
||||
|
||||
mkZPart' = base: content: pool: {
|
||||
content = {
|
||||
type = "zfs";
|
||||
inherit pool;
|
||||
} // content;
|
||||
} // base;
|
||||
mkZPart' =
|
||||
base: content: pool:
|
||||
{
|
||||
content = {
|
||||
type = "zfs";
|
||||
inherit pool;
|
||||
} // content;
|
||||
}
|
||||
// base;
|
||||
mkZPart = size: mkZPart' { inherit size; } { };
|
||||
mkZPartEndAt = end: mkZPart' { inherit end; } { };
|
||||
|
||||
mkZDisk = id: pool: mkDisk id {
|
||||
partitions = {
|
||||
zfs = mkZPart "100%" pool;
|
||||
mkZDisk =
|
||||
id: pool:
|
||||
mkDisk id {
|
||||
partitions = {
|
||||
zfs = mkZPart "100%" pool;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
mkZPool' = mountOptions: name: options: {
|
||||
type = "zpool";
|
||||
mode = "raidz";
|
||||
mountpoint = "/media/${name}";
|
||||
rootFsOptions = {
|
||||
mountpoint = "legacy";
|
||||
compression = "zstd";
|
||||
atime = "off";
|
||||
};
|
||||
inherit mountOptions;
|
||||
} // options;
|
||||
mkZPool' =
|
||||
mountOptions: name: options:
|
||||
{
|
||||
type = "zpool";
|
||||
mode = "raidz";
|
||||
mountpoint = "/media/${name}";
|
||||
rootFsOptions = {
|
||||
mountpoint = "legacy";
|
||||
compression = "zstd";
|
||||
atime = "off";
|
||||
};
|
||||
inherit mountOptions;
|
||||
}
|
||||
// options;
|
||||
mkZPool = mkZPool' defaultMountOptions;
|
||||
mkZPools = mapAttrs mkZPool;
|
||||
|
||||
mkZfs' = mountOptions: mountpoint: options: {
|
||||
type = "zfs_fs";
|
||||
inherit mountpoint mountOptions;
|
||||
options = { mountpoint = "legacy"; } // options;
|
||||
options = {
|
||||
mountpoint = "legacy";
|
||||
} // options;
|
||||
};
|
||||
mkZfs = mkZfs' defaultMountOptions;
|
||||
|
||||
|
@ -98,5 +120,7 @@ rec {
|
|||
inherit size content;
|
||||
};
|
||||
|
||||
markNeededForBoot = flip genAttrs (_: { neededForBoot = true; });
|
||||
markNeededForBoot = flip genAttrs (_: {
|
||||
neededForBoot = true;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -10,25 +10,33 @@ rec {
|
|||
|
||||
neededForBoot = self.lazy (fs: fs // { neededForBoot = true; });
|
||||
|
||||
mkFilesystemDev' = f: d: c: o:
|
||||
mkFilesystemDev' =
|
||||
f: d: c: o:
|
||||
neededForBoot (mkFilesystemDev f d c o);
|
||||
|
||||
mkFilesystem = fsType: uuid:
|
||||
mkFilesystemDev fsType (diskByUuid uuid);
|
||||
mkFilesystem = fsType: uuid: mkFilesystemDev fsType (diskByUuid uuid);
|
||||
|
||||
mkFilesystem' = f: d: c: o:
|
||||
mkFilesystem' =
|
||||
f: d: c: o:
|
||||
neededForBoot (mkFilesystemDev f d c o);
|
||||
|
||||
|
||||
mkEFI = uuid: neededForBoot {
|
||||
device = diskByUuid uuid;
|
||||
fsType = "vfat";
|
||||
};
|
||||
mkTmpfs = name: size: neededForBoot {
|
||||
device = name;
|
||||
fsType = "tmpfs";
|
||||
options = [ "defaults" "size=${size}" "mode=755" ];
|
||||
};
|
||||
mkEFI =
|
||||
uuid:
|
||||
neededForBoot {
|
||||
device = diskByUuid uuid;
|
||||
fsType = "vfat";
|
||||
};
|
||||
mkTmpfs =
|
||||
name: size:
|
||||
neededForBoot {
|
||||
device = name;
|
||||
fsType = "tmpfs";
|
||||
options = [
|
||||
"defaults"
|
||||
"size=${size}"
|
||||
"mode=755"
|
||||
];
|
||||
};
|
||||
mkBtrfs' = options: uuid: extraOptions: {
|
||||
device = diskByUuid uuid;
|
||||
fsType = "btrfs";
|
||||
|
|
|
@ -1,12 +1,21 @@
|
|||
{ lib }:
|
||||
|
||||
{
|
||||
mkHost = attrs@{ modules ? [ ], ... }: name: path: lib.nixosSystem (attrs // {
|
||||
modules = [
|
||||
{
|
||||
networking.hostName = lib.mkDefault name;
|
||||
mkHost =
|
||||
attrs@{
|
||||
modules ? [ ],
|
||||
...
|
||||
}:
|
||||
name: path:
|
||||
lib.nixosSystem (
|
||||
attrs
|
||||
// {
|
||||
modules = [
|
||||
{
|
||||
networking.hostName = lib.mkDefault name;
|
||||
}
|
||||
(import path)
|
||||
] ++ attrs.modules;
|
||||
}
|
||||
(import path)
|
||||
] ++ attrs.modules;
|
||||
});
|
||||
);
|
||||
}
|
||||
|
|
|
@ -3,25 +3,30 @@ let
|
|||
inherit (lib) mkOption types flatten;
|
||||
in
|
||||
rec {
|
||||
mkOpt = type: default:
|
||||
mkOption { inherit type default; };
|
||||
mkOpt = type: default: mkOption { inherit type default; };
|
||||
|
||||
mkOpt' = type: default: description:
|
||||
mkOpt' =
|
||||
type: default: description:
|
||||
mkOption { inherit type default description; };
|
||||
|
||||
mkBoolOpt = default: mkOption {
|
||||
inherit default;
|
||||
type = types.bool;
|
||||
example = true;
|
||||
};
|
||||
mkBoolOpt =
|
||||
default:
|
||||
mkOption {
|
||||
inherit default;
|
||||
type = types.bool;
|
||||
example = true;
|
||||
};
|
||||
|
||||
mkBoolOpt' = default: description: mkOption {
|
||||
inherit default description;
|
||||
type = types.bool;
|
||||
example = true;
|
||||
};
|
||||
mkBoolOpt' =
|
||||
default: description:
|
||||
mkOption {
|
||||
inherit default description;
|
||||
type = types.bool;
|
||||
example = true;
|
||||
};
|
||||
|
||||
coercedPackageList = with types;
|
||||
coercedPackageList =
|
||||
with types;
|
||||
let
|
||||
packageListType = listOf (either package packageListType);
|
||||
in
|
||||
|
@ -29,7 +34,11 @@ rec {
|
|||
|
||||
packageListOpt = mkOpt coercedPackageList [ ];
|
||||
|
||||
addPackageLists = lib.mapAttrs (name: value: value // {
|
||||
packages = packageListOpt;
|
||||
});
|
||||
addPackageLists = lib.mapAttrs (
|
||||
name: value:
|
||||
value
|
||||
// {
|
||||
packages = packageListOpt;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue