mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-02-07 06:19:00 +00:00
Add library and desktop modules
This commit is contained in:
parent
a2ed2a95c9
commit
889742c402
@ -17,6 +17,7 @@
|
||||
enable = true;
|
||||
audio.enable = true;
|
||||
fonts.enable = true;
|
||||
hardware.enable = true;
|
||||
};
|
||||
dev = {
|
||||
enable = true;
|
||||
@ -35,6 +36,7 @@
|
||||
# Use the systemd-boot EFI boot loader.
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
boot.loader.efi.canTouchEfiVariables = true;
|
||||
|
||||
# Set your time zone.
|
||||
time.timeZone = "Asia/Manila";
|
||||
|
||||
@ -51,15 +53,6 @@
|
||||
networking.interfaces.enp1s0.useDHCP = true;
|
||||
networking.interfaces.wlp2s0.useDHCP = true;
|
||||
|
||||
# Enable CUPS to print documents.
|
||||
services.printing.enable = true;
|
||||
|
||||
# More power optimizations!
|
||||
powerManagement.powertop.enable = true;
|
||||
|
||||
# Enable touchpad support (enabled default in most desktopManager).
|
||||
hardware.opentabletdriver.enable = true;
|
||||
|
||||
environment.systemPackages = with pkgs; [ git wget brave lf fd ripgrep ];
|
||||
|
||||
# Some programs need SUID wrappers, can be configured further or are
|
||||
|
@ -93,48 +93,8 @@ in rec {
|
||||
let paths = lib.collect builtins.isPath attrs;
|
||||
in builtins.map (path: import path) paths;
|
||||
|
||||
/* Create a NixOS system through a given host folder.
|
||||
It will automate some of the things such as making the last component
|
||||
of the path as the hostname.
|
||||
|
||||
Signature:
|
||||
path -> attrset -> NixOS configuration
|
||||
Where:
|
||||
- `path` is a path to a Nix file for the host; the basename of the file
|
||||
is also used as the hostname
|
||||
- `attrset` is the attribute set to be included in the host configuration
|
||||
Returns:
|
||||
An attribute set from the `lib.nixosSystem` from `nixpkgs` flake.
|
||||
|
||||
Example:
|
||||
mkHost ./hosts/june {}
|
||||
=> { ... } # NixOS configuration attrset
|
||||
*/
|
||||
mkHost = file:
|
||||
attrs@{ system ? sys, ... }:
|
||||
lib.nixosSystem {
|
||||
inherit system;
|
||||
|
||||
# Additional attributes to be referred to our modules.
|
||||
specialArgs = { inherit lib system inputs; };
|
||||
|
||||
# We also set the following in order for priority.
|
||||
# Later modules will override previously imported modules.
|
||||
modules = [
|
||||
# Set the hostname.
|
||||
{ networking.hostName = builtins.baseNameOf file; }
|
||||
|
||||
# Put the given attribute set (except for the system).
|
||||
(lib.filterAttrs (n: v: !lib.elem n [ "system" ]) attrs)
|
||||
|
||||
# The entry point of the module.
|
||||
file
|
||||
]
|
||||
# Append with our custom modules from the modules folder.
|
||||
++ (lib.modulesToList (filesToAttr ../modules));
|
||||
};
|
||||
|
||||
/* Return an attribute set of valid users from a given list of users.
|
||||
This is a convenience function for getting users from the `./users` directory.
|
||||
|
||||
Signature:
|
||||
list -> attrset
|
||||
@ -143,12 +103,13 @@ in rec {
|
||||
- `attrset` is a set of valid users with the name as the key and the path as the value.
|
||||
Example:
|
||||
# Assuming only 'foo-dogsquared' is the existing user.
|
||||
getUsers [ "foo-dogsquared" "archie" "brad" ]
|
||||
# Get valid users from home-manager.
|
||||
getUsers "home-manager" [ "foo-dogsquared" "archie" "brad" ]
|
||||
=> { foo-dogsquared = /home/foo-dogsquared/projects/nixos-config/users/foo-dogsquared; }
|
||||
*/
|
||||
getUsers = users:
|
||||
getUsers = type: users:
|
||||
let
|
||||
userModules = filesToAttr ../users;
|
||||
userModules = filesToAttr ../users/${type};
|
||||
invalidUsernames = [ "config" "modules" ];
|
||||
in lib.filterAttrs (n: _: !lib.elem n invalidUsernames) userModules;
|
||||
|
||||
@ -169,7 +130,10 @@ in rec {
|
||||
|
||||
Examples:
|
||||
countAttrs (name: value: value) { d = true; f = true; a = false; }
|
||||
=> 2
|
||||
=> 2
|
||||
|
||||
countAttrs (name: value: value.enable) { d = { enable = true; }; f = { enable = false; package = [ ]; }; }
|
||||
=> 1
|
||||
*/
|
||||
countAttrs = pred: attrs:
|
||||
lib.count (attr: pred attr.name attr.value)
|
||||
|
@ -19,6 +19,9 @@ in
|
||||
inkscape # Illustration wannabe tool.
|
||||
gimp # Photo editing wannabe tool.
|
||||
krita # Digital art wannabe tool.
|
||||
|
||||
imagemagick # Ah yes, everyman's image manipulation tool.
|
||||
gmic # Don't let the gimmicks fool you, it's a magical image framework.
|
||||
];
|
||||
})
|
||||
|
||||
|
@ -11,6 +11,8 @@ in {
|
||||
audio.enable = lib.mkEnableOption
|
||||
"Enables all desktop audio-related services such as Pipewire.";
|
||||
fonts.enable = lib.mkEnableOption "Enables font-related config.";
|
||||
hardware.enable = lib.mkEnableOption
|
||||
"Enables the common hardware-related configuration.";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable (lib.mkMerge [
|
||||
@ -88,5 +90,16 @@ in {
|
||||
];
|
||||
};
|
||||
})
|
||||
|
||||
(lib.mkIf cfg.hardware.enable {
|
||||
# Enable tablet support with OpenTabletDriver.
|
||||
hardware.opentabletdriver.enable = true;
|
||||
|
||||
# More power optimizations!
|
||||
powerManagement.powertop.enable = true;
|
||||
|
||||
# Welp, this is surprising...
|
||||
services.printing.enable = true;
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user