Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
outputs =
{ self }:
{
nixosModules = import ./modules;
finixModules = import ./modules;

lib.finixSystem =
{
Expand All @@ -15,9 +15,12 @@
}:
let
config = lib.evalModules {
class = "nixos";
specialArgs = lib.recursiveUpdate { modules = self.nixosModules; } specialArgs;
modules = [ self.nixosModules.default ] ++ modules;
class = "finix";
specialArgs = lib.recursiveUpdate { modules = self.finixModules; } specialArgs;
modules = [
self.finixModules.default
]
++ modules;
};
in
config
Expand Down
8 changes: 7 additions & 1 deletion modules/filesystems/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,13 @@ in
# <file system> <mount point> <type> <options> <dump> <pass>

# filesystems
${makeFstabEntries (lib.filter (fs: !lib.elem fs.fsType [ "luks" "lvm" ]) fileSystems) { }}
${makeFstabEntries (lib.filter (
fs:
!lib.elem fs.fsType [
"luks"
"lvm"
]
) fileSystems) { }}

# swap devices
${lib.concatMapStrings makeSwapEntry config.swapDevices}
Expand Down
16 changes: 9 additions & 7 deletions modules/filesystems/fuse.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ in
};
in
{
boot = (fuseEnable true ''
Whether to enable support for the `fuse` filesystem.
'') // {
initrd = fuseEnable false ''
Whether to enable support for the `fuse` filesystem in the initial ramdisk.
'';
};
boot =
(fuseEnable true ''
Whether to enable support for the `fuse` filesystem.
'')
// {
initrd = fuseEnable false ''
Whether to enable support for the `fuse` filesystem in the initial ramdisk.
'';
};
};

config = lib.mkIf (cfg.enable || cfgInitrd.enable) {
Expand Down
29 changes: 17 additions & 12 deletions modules/filesystems/luks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

packages = lib.mkOption {
type = with lib.types; listOf package;
default = [pkgs.cryptsetup];
default = [ pkgs.cryptsetup ];
description = ''
Packages providing LUKS utilities in the initial ramdisk.
'';
Expand All @@ -35,7 +35,7 @@

packages = lib.mkOption {
type = with lib.types; listOf package;
default = [pkgs.cryptsetup];
default = [ pkgs.cryptsetup ];
description = ''
Packages providing LUKS utilities.
'';
Expand Down Expand Up @@ -63,17 +63,22 @@
"algif_skcipher"
"cryptd"
"input_leds"
] ++ lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "7.0") [ "aes_generic" ];
]
++ lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "7.0") [
"aes_generic"
];

boot.initrd.fileSystemImportCommands = lib.mkOrder 500 (lib.concatStringsSep "\n" (
lib.mapAttrsToList (
name: dev:
let
fsOpts = lib.concatStringsSep " " dev.options;
in
"cryptsetup open ${fsOpts} ${dev.device} ${name}"
) (lib.filterAttrs (_: fs: fs.fsType == "luks") config.fileSystems)
));
boot.initrd.fileSystemImportCommands = lib.mkOrder 500 (
lib.concatStringsSep "\n" (
lib.mapAttrsToList (
name: dev:
let
fsOpts = lib.concatStringsSep " " dev.options;
in
"cryptsetup open ${fsOpts} ${dev.device} ${name}"
) (lib.filterAttrs (_: fs: fs.fsType == "luks") config.fileSystems)
)
);
})
];
}
10 changes: 5 additions & 5 deletions modules/filesystems/lvm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pkgs,
lib,
...
}:
}:
{
options = {
boot.initrd.supportedFilesystems.lvm = {
Expand All @@ -17,7 +17,7 @@

packages = lib.mkOption {
type = with lib.types; listOf package;
default = [pkgs.lvm2];
default = [ pkgs.lvm2 ];
description = ''
Packages providing LVM utilities in the initial ramdisk.
'';
Expand All @@ -35,7 +35,7 @@

packages = lib.mkOption {
type = with lib.types; listOf package;
default = [pkgs.lvm2];
default = [ pkgs.lvm2 ];
description = ''
Packages providing lvm utilities.
'';
Expand All @@ -45,11 +45,11 @@

config = lib.mkMerge [
(lib.mkIf config.boot.supportedFilesystems.lvm.enable {
boot.kernelModules = ["dm_mod"];
boot.kernelModules = [ "dm_mod" ];
})

(lib.mkIf config.boot.initrd.supportedFilesystems.lvm.enable {
boot.initrd.kernelModules = ["dm_mod"];
boot.initrd.kernelModules = [ "dm_mod" ];

boot.initrd.fileSystemImportCommands = lib.mkOrder 600 (
if config.services.udev.enable || !config.services.mdevd.enable then
Expand Down
8 changes: 7 additions & 1 deletion modules/finit/initrd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ in

${lib.concatMapStringsSep "\n" mkMount (
lib.filter (lib.getAttr "neededForBoot") (
lib.filter (fs: !lib.elem fs.fsType [ "luks" "lvm" ]) (lib.attrValues config.fileSystems)
lib.filter (
fs:
!lib.elem fs.fsType [
"luks"
"lvm"
]
) (lib.attrValues config.fileSystems)
)
)}
'';
Expand Down
1 change: 1 addition & 0 deletions modules/nixos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
./terminal-exec.nix
./packages.nix
./ca.nix
./interop.nix
];
}
33 changes: 33 additions & 0 deletions modules/nixos/interop.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
lib,
config,
...
}:
{
options.nixos = lib.mkOption {
default = { };
type = lib.types.submoduleWith {
modules = [
(
{ config, lib, ... }:
{
options.options = lib.mkOption {
type = lib.types.listOf lib.types.deferredModule;
default = [ ];
};

options.config = lib.mkOption {
type = lib.types.submoduleWith {
modules = config.options;
class = "nixos";
};
default = { };
};
}
)
];
};
};

imports = [ config.nixos.config ];
}
2 changes: 1 addition & 1 deletion modules/nixos/meta-maintainers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ in
maintainers = mkOption {
type = listOfMaintainers;
default = [ ];
example = lib.literalExpression ''[ lib.maintainers.alice lib.maintainers.bob ]'';
example = lib.literalExpression "[ lib.maintainers.alice lib.maintainers.bob ]";
description = ''
List of maintainers of each module.
This option should be defined at most once per module.
Expand Down
19 changes: 13 additions & 6 deletions modules/programs/zzz/providers.resume-and-suspend.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ let
in
padding + s;

mkHook = mode: k: v:
mkHook =
mode: k: v:
let
name = "zzz.d/${zeroPad 4 v.priority}-${k}.sh";
script = pkgs.writeShellScript k ''
Expand All @@ -24,7 +25,8 @@ let
in
lib.nameValuePair name { source = script; };

mkResumeHook = k: v:
mkResumeHook =
k: v:
let
name = "zzz.d/${zeroPad 4 v.priority}-${k}.sh";
script = pkgs.writeShellScript k ''
Expand All @@ -44,12 +46,17 @@ in
config = lib.mkIf (config.providers.resumeAndSuspend.backend == "zzz") {
environment.etc =
let
filtered = event: lib.filterAttrs (_: v: v.enable && v.event == event) config.providers.resumeAndSuspend.hooks;
filtered =
event: lib.filterAttrs (_: v: v.enable && v.event == event) config.providers.resumeAndSuspend.hooks;

suspend = lib.mapAttrs' (k: v: mkHook "suspend" k v) (filtered "suspend");
hibernate = lib.mapAttrs' (k: v: mkHook "hibernate" k v) (filtered "hibernate");
suspend = lib.mapAttrs' (k: v: mkHook "suspend" k v) (filtered "suspend");
hibernate = lib.mapAttrs' (k: v: mkHook "hibernate" k v) (filtered "hibernate");
resume = lib.mapAttrs' (k: v: mkResumeHook k v) (filtered "resume");
in
lib.mkMerge [ suspend hibernate resume ];
lib.mkMerge [
suspend
hibernate
resume
];
};
}